WO2022068466A1 - Automatic focusing method and device, and camera - Google Patents

Automatic focusing method and device, and camera Download PDF

Info

Publication number
WO2022068466A1
WO2022068466A1 PCT/CN2021/113969 CN2021113969W WO2022068466A1 WO 2022068466 A1 WO2022068466 A1 WO 2022068466A1 CN 2021113969 W CN2021113969 W CN 2021113969W WO 2022068466 A1 WO2022068466 A1 WO 2022068466A1
Authority
WO
WIPO (PCT)
Prior art keywords
camera
target
image
focusing
current position
Prior art date
Application number
PCT/CN2021/113969
Other languages
French (fr)
Chinese (zh)
Inventor
陶旭磊
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202110135129.3A external-priority patent/CN114363504A/en
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022068466A1 publication Critical patent/WO2022068466A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules

Definitions

  • the present application relates to the field of video surveillance, and in particular, to an automatic focusing method, device and camera.
  • the focusing module of the camera usually adopts a "climbing algorithm" when focusing.
  • the focus value (FV) of the image changes with the movement of the focusing motor, showing a hill-like appearance. Gaussian-like shape, the peak of the hill corresponds to the position of the focus motor corresponding to the sharp point of the image.
  • the specific focusing process is as follows: the focusing module controls the focusing motor to move to the initial direction within a certain range, and compares the global FV of each frame of images before and after the movement. After the focusing motor moves, if the FV becomes larger, it continues to move to the initial direction. Focus motor, if FV becomes smaller, move the focus motor in the opposite direction.
  • the focus module continuously monitors the change of FV, and when the maximum value of FV is detected, it controls the focus motor to move to the position corresponding to the maximum value to complete the focus.
  • the time of each focusing is at least 1 second or more.
  • the target in the dynamic scene is very likely to have a large displacement, so that the clear point of the image changes.
  • the focused position of the focus motor is on a non-sharp point, resulting in a blurred image of the target.
  • the focusing module in the above method is likely to focus on non-targets such as trees and the ground, which will also cause the image of the target to be blurred. It can be seen that the above-mentioned focusing method results in low imaging resolution and low focusing efficiency.
  • the present application provides an automatic focusing method, device and camera, which can ensure clear imaging of a target object in dynamic scenes and scenes with multiple object distances.
  • the technical solution is as follows:
  • an automatic focusing method includes: acquiring at least two frames of images including a target object, the at least two frames of images are obtained by capturing images of a captured area by the camera; for the at least two frames of images For each image, determine the target area where the target object is located in each image, and obtain the FV corresponding to each target area; based on the obtained at least two FVs, obtain the target position of the focusing motor in the camera , control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, and the FV corresponding to the target position meets the target focusing condition.
  • the automatic focusing method when there is a target object in the shooting area of the camera, the automatic focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines the target where the target object is located in each frame of image. Then only the FV of the target area in each frame of image is calculated to obtain the target position to make the target object clearly imaged. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances. The camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency.
  • the camera when the camera is focusing, it needs to acquire multiple frames of images, and calculate the FV of the entire image of each frame of image. Control the focus motor to move and return to the motor position corresponding to the maximum FV. That is to say, in the related art, the camera is based on the sharpness of the entire shooting area, and does not consider whether the target object in the shooting area is clearly imaged, which can easily cause the image of the target object to be blurred. Moreover, this method needs to control the focus. The motor continuously moves to multiple motor positions, and then a motor position is determined from the multiple motor positions, and then the focusing motor is controlled to return to the determined motor position, which takes a long time and the focusing efficiency is not high.
  • the acquisition includes at least two frames of images of the target object, including: acquiring the current position of the focus motor in the camera, and based on the current position, acquiring at least one reference position between the at least one reference position and the current position.
  • the distance is the adjustment step; control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
  • the acquiring the current position of the focus motor in the camera includes one of the following:
  • the current position of the focus motor in the camera is acquired, and the current position is taken as the current position.
  • a current position can be obtained, which is convenient for subsequent focusing cycles through the current position. That is to say, in this auto-focusing method, as long as the camera can detect the target object, it will continue to focus on the cycle, and a current position will be obtained during each focusing process. If the target object is detected for the first time, it will be obtained by prediction. a current position, and then perform the first focusing on the basis of the current position.
  • the current position of the focusing motor is obtained, that is, when the focusing motor completes the first focusing position, and then perform a second focus based on this position, and so on, and so on, until the camera no longer detects the target object.
  • a detection period may also be set, and if the target object is detected within the detection period, the cycle will continue, and if the detection period ends, no further detection will be performed.
  • the obtaining the current position through prediction includes: obtaining a predicted object distance between the camera and the target object; and obtaining the current position based on the predicted object distance and the focal length of the camera.
  • the camera can give an estimated object distance by predicting the object distance between the camera and the target object, which is convenient to give an initial position of the focus motor, and the focus motor is at this position When the target object can achieve a certain degree of clear imaging.
  • the adjustment step is half the focal depth.
  • the obtaining at least one reference position based on the current position includes: obtaining one reference position on both sides of the current position based on the current position.
  • the focusing module obtains two reference positions on the basis of the current position, which greatly reduces the focusing time. For example, it is only 0.16 seconds. During this time period, it can be approximately considered that the target object is stationary. Based on this, the accuracy of the target position can be ensured to the greatest extent, and the focusing efficiency can be improved.
  • acquiring the target position of the focus motor in the camera based on the obtained at least two FVs includes: acquiring an association relationship between each FV and the position of the focus motor in the camera; based on each FV, The current position and the at least one reference position obtain the target position of the focus motor in the camera through the association relationship.
  • the determining the target area where the target object is located in each image includes: inputting each image into a detection model, and the detection model is configured to output the each image according to the input each image.
  • a detection result of an image the detection result includes target area information of the target object in each image; the target area where the target object is located in each image is determined based on the detection result.
  • the target area where the target object is located in the image is determined in real time by the detection model, which improves the accuracy of determining the target area and further ensures the clarity of the target object. imaging.
  • an automatic focusing device comprising:
  • an image acquisition module configured to acquire at least two frames of images including the target object, the at least two frames of images are obtained by image capturing of the captured area by the camera;
  • the FV acquisition module is used for, for each of the at least two frames of images, to determine the target area where the target object is located in each of the images, and to acquire the focus value FV corresponding to each of the target areas;
  • the control module is configured to obtain the target position of the focusing motor in the camera based on the obtained at least two FVs, and control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the camera's On the photosensitive plane, the FV corresponding to the target position conforms to the target focusing condition.
  • the image acquisition module includes:
  • a first obtaining unit configured to obtain the current position of the focusing motor in the camera, and based on the current position, obtain at least one reference position, and the distance between the at least one reference position and the current position is the adjustment step;
  • a second acquisition unit configured to control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is located at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
  • the first acquiring unit is configured to acquire the current position by prediction in response to the camera detecting the target object for the first time; in response to the camera detecting the target object for the first time, acquire the current position of the focus motor in the camera.
  • the current position is taken as the current position.
  • the first obtaining unit is configured to obtain the predicted object distance between the camera and the target object; and obtain the current position based on the predicted object distance and the focal length of the camera.
  • the adjustment step is half the focal depth.
  • the first obtaining unit is configured to obtain the reference position on both sides of the current position based on the current position.
  • control module is used to obtain the association relationship between each FV and the position of the focus motor in the camera; based on each FV, the current position and the at least one reference position, obtain the association relationship through the association relationship.
  • the target position of the focus motor in the camera is used to obtain the association relationship between each FV and the position of the focus motor in the camera.
  • the FV acquisition module is used to input each image into a detection model, and the detection model is used to output the detection result of each image according to the inputted image, and the detection result includes the target.
  • Target area information of the object in each image determining the target area where the target object is located in each image based on the detection result.
  • an auto-focus camera in a third aspect, includes an image sensor and a processor, and the image sensor is configured to acquire at least two frames in the first aspect or any optional implementation manner of the first aspect image, the processor is configured to execute the autofocus method provided in the first aspect or any optional manner of the first aspect.
  • an automatic focusing device in a fourth aspect, includes a processor and a memory for storing at least one piece of program code, the at least one piece of program code is loaded and executed by the processor to make the automatic focusing The device executes the autofocus method provided in the first aspect or any optional manner of the first aspect.
  • a computer-readable storage medium is provided, the computer-readable storage medium is used to store at least one piece of program code, and the at least one piece of program code is loaded and executed by a processor, so that the computer executes the first aspect or the first aspect.
  • the automatic focusing method provided by any one of the optional manners in one aspect.
  • a computer program product or computer program comprising program code which, when run on an autofocus device, causes the autofocus device to perform the above-mentioned first aspect or the first aspect
  • the autofocus method provided in various optional implementations of .
  • FIG. 1 is a schematic diagram of the relationship between a focus value and a lens position provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a system architecture of an autofocus method provided by an embodiment of the present application
  • FIG. 3 is a flowchart of an automatic focusing method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of obtaining a reference position provided by an embodiment of the present application.
  • FIG. 5 is a flowchart of another autofocus method provided by an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of an automatic focusing device provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an automatic focusing device provided by an embodiment of the present application.
  • the embodiments of the present application provide an auto-focusing method, and the auto-focusing methods provided by the embodiments of the present application can be applied to scenes such as road monitoring and safe cities where the shooting environment needs to be focused to ensure that clear images can be collected .
  • scenarios to which the auto-focusing method provided in the embodiments of the present application can be applied include but are not limited to the following.
  • a bayonet device In order to monitor traffic conditions and vehicles passing on the road in real time, a bayonet device is usually installed on the road to realize real-time monitoring of all vehicles passing through the current road.
  • a camera is installed on the bayonet device to monitor the monitoring range. real-time image acquisition of the vehicle.
  • the camera can detect in real time whether a target vehicle enters the monitoring range according to the image collected by the camera, so as to trigger automatic focusing and realize real-time tracking and monitoring of the target vehicle. , to ensure a clear image of the target vehicle.
  • Safe City is a management system that can meet the needs of urban management, traffic management, emergency command, etc., and can also take into account the needs of image monitoring in aspects such as accident early warning and safety production monitoring.
  • image monitoring system online visual video monitoring can be implemented.
  • the automatic focusing method provided by the embodiment of the present application is applied to a camera in an image monitoring system, and the camera can monitor in real time whether a target object enters the monitoring range, so as to trigger automatic focusing and realize real-time tracking of the target object and monitoring to ensure clear imaging of the target object.
  • the auto-focusing method provided in the embodiments of the present application can be applied to various scenarios that require focusing, and the embodiments of the present application do not limit the application scenarios of the auto-focusing method.
  • the imaging principle of the camera is to use the lens to focus the light for imaging.
  • the focus of the light focusing does not necessarily fall on the photosensitive plane.
  • the focusing lens needs to be adjusted by the focusing motor so that the imaging point falls on the photosensitive plane, so that the camera picture is clear. Imaging, this process is the focusing process.
  • Depth of focus is the abbreviation for depth of focus.
  • the range of the focal point and the photosensitive plane is within a certain range, which is clear to the human eye, and the clear range of the focus is called the depth of focus.
  • Depth of field when an object is in focus, all the scenery from a certain distance in front of the object to a certain distance behind it should also be in focus. This distance from front to back is called the depth of field.
  • the object distance is approximately considered to be the distance from the object to be photographed to the first lens in front of the camera.
  • the focal length refers to the distance from the optical center of the lens in the camera to the imaging plane such as the film and the image sensor.
  • a multi-object-distance scene In a multi-object-distance scene, in the same scene, objects at different positions on the screen have different distances from the camera. This kind of scene is called a multi-object-distance scene.
  • Focus value also known as sharpness statistic
  • FIG. 1 is a schematic diagram of the relationship between a focus value and a lens position provided by an embodiment of the present application.
  • the focus evaluation function in FIG. 1 is also the focus value FV, which is usually in In a fixed scene, the FV of the image changes with the movement of the lens position, showing a Gaussian-like function shape like a hillside, and the lens position corresponding to the peak of the hillside corresponds to the clear point of the image.
  • the lens position is controlled by the focus motor.
  • the calculation methods of FV include gray gradient method and high frequency component method.
  • the climbing algorithm is a focusing algorithm that searches for the maximum value of FV within a certain range.
  • an initial motor movement direction will be given. After the motor moves, the FV before and after the movement are compared. If the FV becomes larger, the motor will continue to move in this direction, and if the FV becomes smaller, it will move in the opposite direction. motor.
  • the change of FV is constantly monitored. When the FV continues to increase, it means that the focus is constantly moving towards the photosensitive plane. When the FV drops, it means that the clear point has been reached, and the focusing process is over.
  • FIG. 2 is a system architecture of an auto-focusing method provided by an embodiment of the present application. As shown in FIG. 2 , the automatic focusing method provided in this embodiment of the present application is applied to the camera 200 .
  • the cameras 200 include, but are not limited to, analog cameras, network cameras, and high-definition cameras.
  • the camera 200 includes a lens 210 , an image sensor 220 , an image signal processing unit 230 , a focus motor 240 and a central processing unit 250 .
  • the lens 210 is mainly used to collect light on the photographed area.
  • the image sensor 220 is used to convert the optical signal into an image analog electrical signal.
  • the image sensor 220 involved in the embodiment of the present application includes a charge-coupled device (CCD) image sensor. It also includes image sensors based on complementary metal oxide semiconductor (complementary metal oxide semiconductor, CMOS) processes, also known as CMOS image sensors (CMOS image sensors), which are used in network cameras, digital cameras and other electronic optical devices. Core components. Certainly, other types of image sensors may also be included in some embodiments, and the types of the involved image sensors 220 are not limited in this embodiment of the present application.
  • the image signal processing unit 230 (image signal process, ISP) is mainly used for processing the signal output by the image sensor 220, and processing the image signal through a series of digital image processing algorithms to obtain the FV of the image.
  • the focusing motor 240 is used to drive the lens 210 to move, so that the imaging point falls on the image sensor 220, so as to realize clear image of the picture.
  • a central processing unit (CPU) 250 is used to control the movement of the focusing motor 240 according to the FV, so as to realize focusing.
  • FIG. 3 is a flowchart of an auto-focusing method provided by an embodiment of the present application.
  • the auto-focusing method is performed by the camera 200 shown in FIG. 2 .
  • the auto-focusing method can be applied to a camera 200 in the central processing unit 250.
  • the auto-focusing method includes the following steps.
  • the camera acquires at least two frames of images including the target object, and the at least two frames of images are acquired by the camera through image acquisition of the captured area.
  • the shooting area refers to an area where image acquisition needs to be performed.
  • the target object is the object that meets the autofocus conditions.
  • the target object is a moving object in the shooting area.
  • the target object is a motor vehicle, a non-motor vehicle, a pedestrian, etc., which is not limited in this application.
  • the target object is a preset designated object. For example, in a scenario involving motor vehicle monitoring, the vehicle that needs to be tracked in real time is set as the target object.
  • the manner in which the camera acquires at least two frames of images including the target object includes but is not limited to the following steps 311-314.
  • the camera detects that a target object exists in the shooting area of the camera.
  • the camera includes an image storage module and a detection module
  • the image storage module is used to store each frame of image obtained by the camera on the captured area
  • the detection module stores the image in the image storage module. Detection is performed to determine if a target object is present in the shot area.
  • N frames of images are collected every second, and each frame of images is stored in the image storage module, and the images in the image storage module are detected by the detection module every M frames.
  • N and M are both positive integers, and N is greater than M.
  • the camera collects 25 frames of images per second, and stores each frame of the collected images in the image storage module in real time, and the detection module detects the images in the image storage module every 3 frames. It should be noted that, usually within the time interval of 3 frames of images, it is approximately considered that the position of the target object in the moving state in the photographed area does not change. Therefore, in the embodiment of the present application, the detection module detects every 3 frames. once. In practical applications, the developer can set the detection module to detect each frame of images according to requirements, and the application does not limit the detection frequency of the detection module.
  • the camera is connected to the terminal through a wireless network or a wired network.
  • a designated application program runs on the terminal, and the designated application program is used to set the functions of the camera.
  • the designated application program provides a setting option of the smart detection mode, the user can operate the terminal to turn on the smart detection mode, and the terminal sends a corresponding turn-on instruction to the camera in response to the user's operation of turning on the smart detection mode, and the turn-on instruction It is used to trigger the detection module to perform intelligent detection on the images stored in the image storage module.
  • the camera detects whether there is a target object in the shooting area by using the detection model.
  • This optional implementation is described in detail below, including the following steps 3111 and 3112:
  • the camera inputs at least two frames of images into the detection model, where the at least two frames of images are acquired by the camera through image acquisition of the captured area.
  • the detection model is used to output the detection result of each image according to each input image.
  • the detection result is used to indicate whether the target object exists in each image. If there is a target object in the image, the detection result includes the target area information of the target object in each image.
  • the target area information includes the identification of the target object, the size of the target area, and the location of the target area in each image.
  • the detection model performs image semantic segmentation on an input frame of image, and classifies each pixel of the image to obtain the semantic category of each pixel to obtain an image segmentation result, and then based on the image segmentation result , and output the detection result of the image.
  • the image segmentation result includes the segmented image of the target object
  • the detection model can determine the target area information of the target object in the image based on the segmented image to output the detection result.
  • the detection model constructs a template for information such as edge contour, texture and gray level of each object in the image according to an input frame of image, and detects the target object by a template matching method. If the template of the object in the image matches the target object, the detection model determines the target area information based on the target area where the object is located in the image, so as to output the detection result.
  • the camera acquires the target area information.
  • the detection result output by the detection model includes the target area information of the target object in each image, it means that the target object currently exists in the area captured by the camera, the camera obtains the target area information, and executes the following step 312 .
  • the detection result output by the detection model does not include the target area information of the target object in each image, it means that there is currently no target object in the area captured by the camera, and the camera repeats this step 311 until the target is acquired Regional information.
  • the detection model may be a detection model based on a specified scene.
  • the detection model is used to detect pedestrians with certain characteristics in the image to output detection results.
  • this detection model is used to detect males appearing in images.
  • the detection model is used to detect specific vehicles in the image to output detection results.
  • this detection model is used to detect public transit vehicles that appear in images.
  • developers can train detection models according to requirements to obtain corresponding detection models, which are not limited in this application.
  • the camera detects whether there is a target object in the shooting area according to the image collected by the camera, and can determine the target area in the image in a targeted manner to obtain the target area information, which can not only become a priori for triggering automatic focusing information, and can also ensure clear imaging of the target object in the subsequent focusing process.
  • the camera acquires the current position of the focus motor in the camera.
  • this step 312 is performed by the focusing module in the camera. Wherein, this step 312 includes any of the following situations:
  • Case 1 In response to the camera detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera through prediction.
  • Case 2 In response to the camera not detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera, and uses the current position as the current position.
  • a current position can be obtained, which is convenient for subsequent focusing cycles through the current position. That is to say, as long as the camera can detect the target object, it will continue to focus on the cycle, and will obtain a current position during each focusing process. If the target object is detected for the first time, it will obtain a current position through prediction, and then in the The first focusing is performed on the basis of the current position. If the target object is detected for the second time, the current position of the focusing motor is obtained, that is, the position of the focusing motor when the first focusing is completed, and then the current position of the focusing motor is obtained.
  • a second focus is performed, and so on, and the cycle continues until the camera no longer detects the target object.
  • a detection period may also be set, and if the target object is detected within the detection period, the cycle will continue, and if the detection period ends, no further detection will be performed.
  • the camera acquires at least one reference position based on the current position, and the distance between the at least one reference position and the current position is an adjustment step.
  • this step 313 is performed by the focusing module in the camera.
  • the adjustment step length refers to the moving step length of the focus motor of the camera.
  • the adjustment step length is half the focal depth, which is not limited in this application.
  • the camera obtains a reference position on both sides of the current position, wherein the adjustment step is half a focal depth, and the focal depth is calculated based on the current position.
  • FIG. 4 is a schematic diagram of obtaining a reference position according to an embodiment of the present application.
  • the current position acquired by the camera is P1
  • the positions on both sides of the position P1 which are separated by half the focal depth are the reference positions P2 and P3, respectively.
  • the depth of focus is calculated by the following formula (1):
  • Depth of focus a ⁇ F ⁇ L ⁇ f
  • a is a fixed parameter of the camera, and the value of a is different for different models of cameras;
  • F is the aperture value of the camera;
  • L is the object distance, which can be determined by formula (7) and formula (8) in the subsequent step 3121. Calculated;
  • f is the focal length.
  • the camera can obtain W reference positions based on the current position, where W is a positive integer greater than 2. For example, on both sides of the current position, at every half depth of focus, obtain one reference position. With reference to the motor position, a total of 4 reference positions are obtained. This application does not limit this.
  • the camera controls the focus motor in the camera to move to the current position and the at least one reference position respectively, and acquires at least two frames of images when the focus motor in the camera is at the current position and the at least one reference position.
  • this step 314 is performed by the focusing module in the camera.
  • the at least two frames of images are obtained by image capturing of the captured area by the camera.
  • the camera acquires a frame of image of the corresponding position.
  • the camera determines a target area where the target object is located in each image, and acquires the FV corresponding to each target area.
  • this step 302 is performed by the focusing module in the camera.
  • FV is used to evaluate the image sharpness of the target area.
  • the calculation method of FV may adopt a gray gradient method or a high frequency component method, etc., which is not limited in this application.
  • the camera determines the target area where the target object is located in each image according to the target area information obtained in step 301, so as to obtain the target area corresponding to each area. the FV.
  • the camera inputs each image into a detection model, and the detection model is configured to output a detection result of each image according to each input image, the The detection result includes the target area information of the target object in each image. Then, according to the target area information in the detection result, the camera determines the target area where the target object is located in each image, so as to obtain the FV corresponding to each target area. It should be noted that, the implementation of the detection model has been described in the above step 301, so it will not be repeated here.
  • the embodiments of the present application do not limit the manner in which the camera determines the target area where the target object is located in each image. That is, the camera can determine according to the target area information obtained from step 301, and can also input each frame of image into a detection model for detection, so as to determine the target area information.
  • the second point that needs to be explained is that the above steps 301 and 302 can be executed synchronously, that is, whenever the camera controls the focus motor to move to a motor position, a frame of image is immediately acquired, and it is determined that the target object is located in the image. located in the target area, and calculate the FV corresponding to a target area.
  • the above steps are specifically described below by taking the camera acquiring two reference positions and adjusting the step size as half the focal depth as an example.
  • the above steps 301 and 302 can be replaced with the following steps 1 to 3:
  • Step 1 The camera controls the focus motor to move to the current position P1, obtains the first frame of image, and determines the target area where the target object is located in the first frame of image based on the target area information, and then calculates the first target.
  • the FV corresponding to the region.
  • Step 2 The camera controls the focusing motor with P1 as the starting point and half the focal depth as the adjustment step, moves forward to reach the reference position P2, obtains the second frame of image, and determines that the target object is in the second frame based on the target area information. The target area located in the frame image, and then calculate the FV corresponding to the second target area.
  • Step 3 The camera controls the focusing motor with P2 as the starting point and a focal depth as the adjustment step, moves in the reverse direction to reach the reference position P3, obtains the third frame of image, and determines the target object in the third frame based on the target area information The target area located in the image, and then calculate the FV corresponding to the third target area.
  • the camera can control the focus motor to first move in the reverse direction to reach P3, and then move forward to reach P2, which is not limited in this application.
  • the forward and reverse directions in the above steps are relative to the default moving direction of the focusing motor, and the default moving direction may be preset, which is not limited in this embodiment of the present application.
  • the following takes the camera to obtain the FV corresponding to a target area based on one frame of image as an example to illustrate:
  • the camera when it acquires a frame of image, it also acquires the FV of the entire area of the image.
  • a frame of image is divided into 255 sub-areas, and each sub-area corresponds to a sub-FV.
  • the FV corresponding to the target area can be calculated in various ways.
  • the camera can also obtain the average value of the FV of all sub-areas corresponding to the target area to calculate The average value is taken as the FV corresponding to the target area.
  • the embodiment of the present application does not limit the calculation method of the FV of the target area.
  • the camera acquires the target position of the focusing motor in the camera based on the obtained at least two FVs, and controls the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, The FV corresponding to the target position meets the target focus condition.
  • this step 303 is performed by the focusing module in the camera.
  • the target focusing condition means that the imaging of the target object meets the definition requirement.
  • the camera takes the obtained at least two FVs as the ordinate and the position of the focusing motor corresponding to the FVs as the abscissa, and obtains the target position through fitting.
  • the camera obtains the target position of the focus motor in the camera based on the obtained at least two FVs, including the following steps 3031 and 3032:
  • the camera acquires an association relationship between each FV and the position of the focus motor in the camera.
  • the camera obtains the target position of the focus motor in the camera based on each FV, the current position, and the at least one reference position and through the association relationship.
  • the current position of the focus motor of the camera is P1, and the reference positions are P2 and P3 respectively, and these three positions correspond to the FV of a target area respectively.
  • the camera obtains the relationship between each FV and the position of the focus motor in the camera, that is, the following formula (2). Further, based on the formula (2), the camera obtains the relational expressions between the motor positions P1, P2, P3 and the FV corresponding to each motor position, as shown in formulas (3) to (5).
  • y represents FV
  • x represents the motor position
  • a and c are variable parameters
  • b is the target position
  • x 1 , x 2 and x 3 respectively represent The current position P1 and the reference positions P2 and P3, y 1 , y 2 and y 3 respectively represent the FVs of the target areas corresponding to P1 , P2 and P3 .
  • the value of b can be calculated, and b is the target position of the focusing motor.
  • the first point that needs to be explained is that in the above steps, by calculating the FV corresponding to the target area, the influence of multiple object distances can be avoided, so that the camera can only focus on the target object, which greatly increases the imaging clarity of the target object. It is also possible to reduce the amount of data for image processing.
  • the camera obtains two reference positions on the basis of the current position, so that the time required for the camera to perform the above steps 301 to 303 is only 4 frames of time. For example, it is only 0.16 seconds.
  • the target object can be approximately considered to be in a stationary state. Based on this, the accuracy of the target position can be guaranteed to the greatest extent.
  • the focusing time is greatly reduced and the focusing efficiency is improved.
  • the third point that needs to be explained is that, after the above steps 301 to 303, when the camera detects that there is a target object in the area captured by the camera, automatic focusing is triggered, and the focusing module in the camera is switched from the idle state to the focusing state.
  • the above step 312 is replaced with: in response to the camera detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera through prediction.
  • the camera further includes a focusing module, which can be used to perform step 312, wherein, when the focusing module is in an idle state and the camera detects the target object, it is determined that the camera detects the target object for the first time, and the focusing module is idle Status means that the focus module is not currently in the focus process.
  • the focusing module detects whether the camera acquires the target area information every frame. If the camera acquires the target area information when the focusing module is in an idle state, it is determined that the camera detects the target object for the first time.
  • the camera acquires a predicted object distance between the camera and the target object.
  • the predicted object distance is calculated by the following formulas (7) and (8):
  • Object distance target guess length / ratio of detection frame to the entire screen / tangent function of field of view
  • the target guess length is the predicted value of the target object length.
  • the camera pre-sets the value of the target guess length. For example, when the mark of the target object in the target area information indicates that the target object is a vehicle, the target guess length is 2.2 meters (m). The specific value of the target guess length in this application is Not limited. It should be noted that the target guess length in the above formula (7) may also be the target guess height.
  • the camera pre-sets the value of the target guessing height. For example, when the target object identifier in the target area information indicates that the target object is a pedestrian, the target guessing height is 1.7m. In practical applications, a corresponding target guess length can be set according to requirements, which is not limited in this embodiment of the present application.
  • the ratio of the detection frame to the entire image refers to the ratio of the size of the target area to the entire image.
  • the camera calculates the area of the target area according to the size of the target area in the target area information, so as to obtain the ratio of the detection frame to the entire screen.
  • the field of view is calculated by formula (8), where the sensor size refers to the size of the imaging plane of the image sensor.
  • the camera acquires the current position of the focus motor in the camera based on the predicted object distance and the focal length of the camera.
  • the focal length of the camera is a real-time camera parameter that can be obtained directly.
  • the camera further includes a parameter storage module for storing various parameter information of the camera.
  • the parameter storage module stores a table for querying the position of the focusing motor, and the camera sends a query request to the parameter storage module according to the calculated predicted object distance and the current focal length of the camera, and the query request is used to predict the object distance and focal length according to The corresponding focusing motor position is queried, and the parameter storage module sends the corresponding focusing motor position to the focusing module based on the query request.
  • the camera gives an estimated object distance by predicting the object distance between the camera and the target object, so as to obtain an initial position of the focus motor, and when the focus motor is at the initial position, the target object A certain degree of clear imaging can be achieved.
  • the camera responds to the camera detecting the target object for the first time, and calculates the predicted object distance of the target object according to the target area where the target object is located. Based on this , obtain the current position of the focusing motor through prediction, and determine at least one reference position, finally obtain at least two FVs, and obtain the target position through fitting.
  • the camera controls the focusing motor to move to the target position the light focus of the focusing lens can fall on the photosensitive plane of the camera. Clear imaging can be achieved.
  • step 312 is replaced with: the camera, in response to the camera detecting the target object for the first time, obtains the current position of the focus motor in the camera, and uses the current position as the current position.
  • this step 312 is specifically performed by the focusing module in the camera, wherein when the focusing module is in the focusing state and the camera obtains the target area information, it is determined that the camera has not detected the target object for the first time.
  • the focusing module detects whether the target area information is received every frame, and if the focusing module continues to obtain the target area information when it is in the focused state, it is determined that the camera has not detected the target object for the first time.
  • the following takes the second acquisition of the target area information by the camera as an example for description:
  • the camera in response to the camera not detecting the target object for the first time, the camera obtains the current position of the focus motor, that is, in case 1, the target position in the above step 303 is taken as the target position.
  • this step 312 can also be replaced by the following steps 312A to 312C:
  • the camera controls the focus motor in the camera to move to the current position, and acquires a frame of image.
  • the focus module acquires a frame of image captured by the camera when the focus motor was at the current position during the last focusing process.
  • the camera determines a target area where the target object is located in each image, and obtains the FV corresponding to each target area.
  • the camera obtains the target position of the focusing motor in the camera based on the obtained two FVs, and controls the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, the The FV corresponding to the target position meets the target focus condition.
  • the camera obtains two frames of images, one frame is the image when the focus motor is at the current position during the current focusing process, and the other frame is when the focus motor is at the current position during the last focusing process. Based on this, the camera obtains the FV corresponding to the two target areas, and obtains the target position by comparing the numerical values of the two FVs.
  • the camera controls the focusing motor to move forward by half the focal depth adjustment step to obtain the target position;
  • the FV in this focusing process is greater than the FV in the previous focusing process, and the camera controls the focusing motor to reversely move half the focal depth adjustment step to obtain the target position.
  • the focusing module in the camera switches from the focused state to the idle state until the camera obtains the target area information again.
  • the automatic focusing method when there is a target object in the shooting area of the camera, the automatic focusing is triggered.
  • the camera acquires at least two frames of images including the target object, and respectively determines that the target object is in each frame of the image.
  • only the FV of the target area in each frame of image is calculated to obtain the target position for clear imaging of the target object.
  • the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances.
  • the camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the camera can continue to detect the target object, the camera will focus again on the basis of the previous focus, so as to continuously refresh the motor position of the focusing motor, and realize real-time tracking of the moving target object, thus ensuring dynamic scenes. clear imaging of the target object.
  • FIG. 5 is a flowchart of another automatic focusing method provided by an embodiment of the present application.
  • the automatic focusing method provided by the embodiment of the present application will be schematically described below with reference to FIG. 5 .
  • the automatic focusing method includes the following steps 501 to 505 .
  • the camera acquires 25 frames of images per second, and sends each frame of image to the camera platform, where the camera platform is also the CPU in the camera.
  • the detection module in the camera platform detects the target object in the image every 3 frames. Among them, the detection module will import the image as input into a trained detection model, and finally output the detection result of the detection model for the target object in the whole image. If the target object is detected, the detected target will be in the output result. area information, and transmit the detected target area information to the focusing module in the camera platform.
  • the focusing module in the camera platform detects whether the target area information of the detection module is received in each frame. If the focusing module receives the target area information of the detection module when it is in an idle state, it will trigger automatic focusing; after the focusing module completes one cycle, it will continue to detect whether it can still receive the prior information of the intelligent algorithm. , then continue the loop, if it cannot receive, then exit the loop and enter the idle state.
  • the focusing module receives the target area information when it is in an idle state, that is, the target object is detected for the first time, the predicted object distance will be estimated first according to the above formula (7), and then, according to the predicted object distance and the current focal length. Look up the table to obtain the corresponding motor position, and use the motor position as the current position.
  • the focusing module obtains a reference position on the left and right sides of the current position, respectively. Then the focusing module controls the focusing motor to move to the three positions in turn, and obtains the FV of the target area corresponding to the three positions at the same time, and then fits the target position of the clearest point according to the correlation shown in the above formula (2). , the focusing module controls the focusing motor to move to the target position to complete a focusing cycle.
  • the focusing module If the focusing module still receives the target area information after one cycle, that is to say, the target object is not detected for the first time, the focusing module will obtain the position decided by the focusing module after focusing last time, and use the position as the new current position again. , and repeat step 504 to obtain the FV of the target area, obtain the target position of the clearest point by fitting, and control the focusing motor to move to the target position again to complete the focusing cycle again.
  • the automatic focusing method when there is a target object in the shooting area of the camera, the automatic focusing is triggered.
  • the camera acquires at least two frames of images including the target object, and respectively determines that the target object is in each frame of the image.
  • only the FV of the target area in each frame of image is calculated to obtain the target position for clear imaging of the target object.
  • the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances.
  • the camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the camera can continue to detect the target object, the camera will focus again on the basis of the previous focus, so as to continuously refresh the motor position of the focusing motor, and realize real-time tracking of the moving target object, thus ensuring dynamic scenes. clear imaging of the target object.
  • FIG. 6 is a schematic structural diagram of an auto-focusing apparatus provided by an embodiment of the present application.
  • the auto-focusing apparatus is used to execute the steps of the above-mentioned auto-focusing method.
  • the auto-focusing apparatus 600 includes: an image acquisition module 601, FV acquisition module 602 and control module 603 .
  • An image acquisition module 601, configured to acquire at least two frames of images including the target object, the at least two frames of images are obtained by the camera on the captured area;
  • the FV acquisition module 602 is configured to, for each of the at least two frames of images, determine the target area where the target object is located in each of the images, and acquire the FV corresponding to each of the target areas;
  • the control module 603 is configured to obtain the target position of the focusing motor in the camera based on the obtained at least two FVs, and control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the camera On the photosensitive plane of , the FV corresponding to the target position meets the target focusing conditions.
  • the image acquisition module 601 includes:
  • a first obtaining unit configured to obtain the current position of the focusing motor in the camera, and based on the current position, obtain at least one reference position, and the distance between the at least one reference position and the current position is the adjustment step;
  • a second acquisition unit configured to control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is located at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
  • the first acquisition unit is configured to acquire the current position by prediction in response to the camera detecting the target object for the first time; acquire the current position in response to the camera detecting the target object for the first time The current position of the focus motor in the camera is taken as the current position.
  • the first obtaining unit is configured to obtain the predicted object distance between the camera and the target object; and obtain the current position based on the predicted object distance and the focal length of the camera.
  • the adjustment step is half the focal depth.
  • the first obtaining unit is configured to obtain the reference position on both sides of the current position based on the current position.
  • control module 603 is configured to acquire the association relationship between each FV and the position of the focus motor in the camera; based on each FV, the current position and the at least one reference position , and through the relationship, the target position of the focus motor in the camera is obtained.
  • the FV acquisition module 602 is configured to input each image into a detection model, and the detection model is configured to output the detection result of each image according to the inputted each image , the detection result includes the target area information of the target object in each image; the target area where the target object is located in each image is determined based on the detection result.
  • the auto-focusing device when there is a target object in the shooting area of the camera, auto-focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines the target where the target object is located in each frame of image. Then only the FV of the target area in each frame of image is calculated to obtain the target position to make the target object clearly imaged. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing device is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances.
  • the camera is made to automatically focus on the clear imaging of the target object at all times, so as to realize the clear imaging of the target object, which can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the target object can continue to be detected, the automatic focusing device will focus again on the basis of the previous focusing, so as to continuously refresh the motor position of the focusing motor, and realize the real-time tracking of the moving target object, so as to ensure dynamic Clear imaging of target objects in the scene.
  • FIG. 7 is a schematic structural diagram of an auto-focusing device provided by an embodiment of the present application.
  • the auto-focusing device 700 may vary due to different configurations or performances, and includes one or more processors 701 and one or more memories 702 , wherein at least one piece of program code is stored in the memory 702, and the at least one piece of program code is loaded and executed by the processor 701 to implement the steps in the above method embodiments.
  • the auto-focusing device 700 can also have components such as a wired or wireless network interface, a keyboard, and an input-output interface for input and output.
  • the auto-focusing device 700 also includes other components for realizing device functions, which will not be repeated here. .
  • a computer-readable storage medium such as a memory including program codes
  • the program codes can be executed by a processor in the terminal, so that the computer can perform the auto-focusing method in the above-mentioned embodiments.
  • the computer-readable storage medium is read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), magnetic tape , floppy disks and optical data storage devices.
  • an auto-focusing camera for example comprising an image sensor and a processor, wherein the image sensor is used to acquire at least two frames of images in the above-mentioned embodiments, and the processor is used to execute the above-mentioned embodiments Autofocus method in .
  • first, second and other words are used to distinguish the same or similar items with basically the same function and function, and it should be understood that between “first”, “second” and “nth” There are no logical or timing dependencies, and no restrictions on the number and execution order. It will also be understood that, although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, a first image may be referred to as a second image, and, similarly, a second image may be referred to as a first image, without departing from the scope of various described examples. Both the first image and the second image may be images, and in some cases, may be separate and distinct images.
  • the term “if” may be interpreted to mean “when” or “upon” or “in response to determining” or “in response to detecting.”
  • the phrases “if it is determined" or “if a [statement or event] is detected” can be interpreted to mean “when determining" or “in response to determining... ” or “on detection of [recited condition or event]” or “in response to detection of [recited condition or event]”.
  • the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware or any combination thereof.
  • software it can be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer program instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the procedures or functions according to the embodiments of the present application are generated in whole or in part.
  • the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer program instructions may be transmitted from a website site, computer, server or data center via Wired or wireless transmission to another website site, computer, server or data center.
  • the computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media integrated.
  • the available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, digital video discs (DVDs), or semiconductor media (eg, solid state drives), and the like.

Abstract

Disclosed is an automatic focusing technology, which belongs to the field of video monitoring. When there is a target object in a photographed area, a camera acquires at least two images including the target object, and then calculates an FV of a target area where the target object is located in each image, so as to obtain a target position for clearly imaging the target object, thereby achieving automatic focusing. Said method avoids the influence of multiple object distances, and increases the focusing efficiency.

Description

自动聚焦方法、装置及摄像机Autofocus method, device and camera 技术领域technical field
本申请涉及视频监控领域,特别涉及一种自动聚焦方法、装置及摄像机。The present application relates to the field of video surveillance, and in particular, to an automatic focusing method, device and camera.
背景技术Background technique
近年来,随着视频监控的不断发展,对摄像机提出了越来越多具有挑战性的要求,特别是对于摄像机的聚焦能力,要求其能实现动态场景和多物距场景下的全天候精确聚焦,这样才能保证摄像机所监控的场景中目标的清晰成像。目前,许多摄像机都配置有专门的聚焦模块,该聚焦模块能够通过控制聚焦电机来控制聚焦镜头的移动方向和移动步长,以使焦点落在感光平面上,实现聚焦。In recent years, with the continuous development of video surveillance, more and more challenging requirements have been placed on the camera, especially for the focusing ability of the camera, which is required to achieve all-weather precise focusing in dynamic scenes and scenes with multiple object distances. In this way, a clear image of the target in the scene monitored by the camera can be ensured. At present, many cameras are equipped with a special focusing module, which can control the moving direction and moving step of the focusing lens by controlling the focusing motor, so as to make the focus fall on the photosensitive plane and realize focusing.
相关技术中,摄像机的聚焦模块在聚焦时通常采用“爬坡算法”,在一个固定场景下,图像的聚焦值(focus value,FV)随着聚焦电机的移动而变化,呈现出像山坡一样的类高斯函数形状,山坡的峰值所对应的聚焦电机的位置对应于图像的清晰点。具体聚焦过程为:聚焦模块控制聚焦电机在一定范围内向初始方向移动,并对比移动前和移动后的每帧图像全局的FV,在聚焦电机移动后,如果FV变大则继续向该初始方向移动聚焦电机,如果FV变小则反方向移动聚焦电机。在聚焦电机的移动过程中,聚焦模块不断监测FV的变化,当监测到FV的最大值时,控制聚焦电机移动到与该最大值所对应的位置,完成聚焦。In the related art, the focusing module of the camera usually adopts a "climbing algorithm" when focusing. In a fixed scene, the focus value (FV) of the image changes with the movement of the focusing motor, showing a hill-like appearance. Gaussian-like shape, the peak of the hill corresponds to the position of the focus motor corresponding to the sharp point of the image. The specific focusing process is as follows: the focusing module controls the focusing motor to move to the initial direction within a certain range, and compares the global FV of each frame of images before and after the movement. After the focusing motor moves, if the FV becomes larger, it continues to move to the initial direction. Focus motor, if FV becomes smaller, move the focus motor in the opposite direction. During the movement of the focus motor, the focus module continuously monitors the change of FV, and when the maximum value of FV is detected, it controls the focus motor to move to the position corresponding to the maximum value to complete the focus.
然而,采用上述方法,每次聚焦的时间至少在1秒以上,多则数秒,在此时间段内,动态场景下的目标极有可能发生了较大的位移,从而图像的清晰点发生变化,聚焦电机聚焦后的位置处于非清晰点上,导致目标的成像模糊。另外,在多物距场景下,上述方法中的聚焦模块容易聚焦在树木、地面等非目标上,同样会导致目标的成像模糊。可见,上述聚焦方式导致成像的清晰度不高,聚焦效率较低。However, using the above method, the time of each focusing is at least 1 second or more. During this time period, the target in the dynamic scene is very likely to have a large displacement, so that the clear point of the image changes. The focused position of the focus motor is on a non-sharp point, resulting in a blurred image of the target. In addition, in a multi-object distance scenario, the focusing module in the above method is likely to focus on non-targets such as trees and the ground, which will also cause the image of the target to be blurred. It can be seen that the above-mentioned focusing method results in low imaging resolution and low focusing efficiency.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种自动聚焦方法、装置及摄像机,能够在动态场景和多物距场景下,保证目标对象的清晰成像。该技术方案如下:The present application provides an automatic focusing method, device and camera, which can ensure clear imaging of a target object in dynamic scenes and scenes with multiple object distances. The technical solution is as follows:
第一方面,提供了一种自动聚焦方法,该方法包括:获取包括目标对象的至少两帧图像,该至少两帧图像由该摄像机对所拍摄区域进行图像采集得到;对于该至少两帧图像中的每一图像,确定该目标对象在该每一图像中所位于的目标区域,获取每个该目标区域所对应的FV;基于获得的至少两个FV,获取该摄像机中的聚焦电机的目标位置,控制该摄像机中的聚焦电机移动至该目标位置,以使通过聚焦镜头的光线焦点落在该摄像机的感光平面上,该目标位置所对应的FV符合目标聚焦条件。In a first aspect, an automatic focusing method is provided, the method includes: acquiring at least two frames of images including a target object, the at least two frames of images are obtained by capturing images of a captured area by the camera; for the at least two frames of images For each image, determine the target area where the target object is located in each image, and obtain the FV corresponding to each target area; based on the obtained at least two FVs, obtain the target position of the focusing motor in the camera , control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, and the FV corresponding to the target position meets the target focusing condition.
在该自动聚焦方法中,当摄像机的拍摄区域中存在目标对象时,触发自动聚焦,此时摄像机获取包括目标对象的至少两帧图像,并分别确定目标对象在每一帧图像中所位于的目标区域,然后仅计算每一帧图像中目标区域的FV,得到以使目标对象清晰成像的目标位置,基于此,控制聚焦电机移动以实现聚焦。也就是说,该自动聚焦方法是以目标对象所在的目标区域的清晰度为基础,直接获取聚焦电机的目标位置,然后控制聚焦电机移动到该目标位置上,这样能够避免多物距的影响,使得摄像机时刻以目标对象的清晰成像为目标进行自动聚焦,实现目标对象的清晰成像,而且,这种方法能够大大缩短聚焦时间,提高聚焦效率。In the automatic focusing method, when there is a target object in the shooting area of the camera, the automatic focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines the target where the target object is located in each frame of image. Then only the FV of the target area in each frame of image is calculated to obtain the target position to make the target object clearly imaged. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances. The camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency.
而在相关技术中,摄像机在聚焦时,需要获取多帧图像,并计算每一帧图像的整个图像的FV,通过不断对比获取到的各个FV之间的大小关系,直到发现一个最大FV,再控制聚焦电机移动,回到该最大FV所对应的电机位置上。也就是说,在相关技术中,摄像机是以整个拍摄区域的清晰度为基础,并不考虑拍摄区域中目标对象是否清晰成像,这样极易导致目标对象成像模糊,而且,这种方式需要控制聚焦电机不断移动到多个电机位置上,然后从这多个电机位置中确定出一个电机位置,再控制聚焦电机回到该确定好的电机位置上,耗时较长,聚焦效率不高。In the related art, when the camera is focusing, it needs to acquire multiple frames of images, and calculate the FV of the entire image of each frame of image. Control the focus motor to move and return to the motor position corresponding to the maximum FV. That is to say, in the related art, the camera is based on the sharpness of the entire shooting area, and does not consider whether the target object in the shooting area is clearly imaged, which can easily cause the image of the target object to be blurred. Moreover, this method needs to control the focus. The motor continuously moves to multiple motor positions, and then a motor position is determined from the multiple motor positions, and then the focusing motor is controlled to return to the determined motor position, which takes a long time and the focusing efficiency is not high.
可选地,该获取包括目标对象的至少两帧图像,包括:获取该摄像机中的聚焦电机的当前位置,基于该当前位置,获取至少一个参考位置,该至少一个参考位置与该当前位置之间的距离为调整步长;控制该摄像机中的聚焦电机分别移动至该初始位置和该至少一个参考位置上,在该摄像机中的聚焦电机位于该当前位置以及该至少一个参考位置上时,该摄像机获取该至少两帧图像。Optionally, the acquisition includes at least two frames of images of the target object, including: acquiring the current position of the focus motor in the camera, and based on the current position, acquiring at least one reference position between the at least one reference position and the current position. The distance is the adjustment step; control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
可选地,该获取该摄像机中的聚焦电机的当前位置,包括下述一种:Optionally, the acquiring the current position of the focus motor in the camera includes one of the following:
响应于该摄像机首次检测到该目标对象,通过预测获取该当前位置;In response to the camera detecting the target object for the first time, obtaining the current position through prediction;
响应于该摄像机非首次检测到该目标对象,获取该摄像机中的聚焦电机当前所处的位置,将该当前所处的位置作为该当前位置。In response to the camera not detecting the target object for the first time, the current position of the focus motor in the camera is acquired, and the current position is taken as the current position.
基于上述可选地实现方式,无论摄像机是首次检测到目标对象还是非首次检测到目标对象,都能够获取到一个当前位置,便于后续通过该当前位置进行聚焦循环。也就是说,在该自动聚焦方法中,摄像机只要能够检测到目标对象,就会一直进行聚焦循环,在每一次聚焦过程中都会获取一个当前位置,如果是首次检测到目标对象,就通过预测获取一个当前位置,然后在该当前位置的基础上进行第一次聚焦,如果是第二次检测到目标对象,就获取聚焦电机当前所处的位置,也即是聚焦电机在完成第一次聚焦时所处的位置,然后在该位置的基础上进行第二次聚焦,以此类推,一直循环下去,直到摄像机不再检测到目标对象。可选地,也可设置一个检测周期,在检测周期内如果检测到目标对象则继续循环,如果检测周期结束,则不再检测。Based on the above optional implementation manner, no matter whether the camera detects the target object for the first time or not for the first time, a current position can be obtained, which is convenient for subsequent focusing cycles through the current position. That is to say, in this auto-focusing method, as long as the camera can detect the target object, it will continue to focus on the cycle, and a current position will be obtained during each focusing process. If the target object is detected for the first time, it will be obtained by prediction. a current position, and then perform the first focusing on the basis of the current position. If the target object is detected for the second time, the current position of the focusing motor is obtained, that is, when the focusing motor completes the first focusing position, and then perform a second focus based on this position, and so on, and so on, until the camera no longer detects the target object. Optionally, a detection period may also be set, and if the target object is detected within the detection period, the cycle will continue, and if the detection period ends, no further detection will be performed.
可选地,该通过预测获取该当前位置,包括:获取该摄像机与该目标对象之间的预测物距;基于该预测物距和该摄像机的焦距,获取该当前位置。Optionally, the obtaining the current position through prediction includes: obtaining a predicted object distance between the camera and the target object; and obtaining the current position based on the predicted object distance and the focal length of the camera.
基于上述可选地实现方式,摄像机通过对摄像机与目标对象之间的物距进行预测,能够给出一个估算的物距,便于给出一个初始的聚焦电机的位置,且聚焦电机处于该位置上时,目标对象能够实现一定程度上的清晰成像。Based on the above optional implementation manner, the camera can give an estimated object distance by predicting the object distance between the camera and the target object, which is convenient to give an initial position of the focus motor, and the focus motor is at this position When the target object can achieve a certain degree of clear imaging.
可选地,该调整步长为半个焦深。Optionally, the adjustment step is half the focal depth.
可选地,该基于该当前位置,获取至少一个参考位置,包括:基于该当前位置,在该当前位置两侧,各获取一个该参考位置。Optionally, the obtaining at least one reference position based on the current position includes: obtaining one reference position on both sides of the current position based on the current position.
基于上述可选地实现方式,聚焦模块在当前位置的基础上,获取到两个参考位置,大大减少了聚焦时间,例如,仅有0.16秒,在此时间段内,能够近似认为目标对象处于静止状态,基于此,能够最大程度保证目标位置的准确性,提高了聚焦效率。Based on the above optional implementation manner, the focusing module obtains two reference positions on the basis of the current position, which greatly reduces the focusing time. For example, it is only 0.16 seconds. During this time period, it can be approximately considered that the target object is stationary. Based on this, the accuracy of the target position can be ensured to the greatest extent, and the focusing efficiency can be improved.
可选地,该基于获得的至少两个FV,获取该摄像机中的聚焦电机的目标位置,包括:获取每个FV与该摄像机中的聚焦电机的位置之间的关联关系;基于每个FV、该当前位置以及该至少一个参考位置,通过该关联关系,获取该摄像机中的聚焦电机的目标位置。Optionally, acquiring the target position of the focus motor in the camera based on the obtained at least two FVs includes: acquiring an association relationship between each FV and the position of the focus motor in the camera; based on each FV, The current position and the at least one reference position obtain the target position of the focus motor in the camera through the association relationship.
可选地,该确定该目标对象在该每一图像中所位于的目标区域,包括:将该每一图像输入到检测模型中,该检测模型用于根据输入的该每一图像,输出该每一图像的检测结果,该检测结果中包括该目标对象在该每一图像中的目标区域信息;基于该检测结果确定该目标对象在该每一图像中所位于的目标区域。Optionally, the determining the target area where the target object is located in each image includes: inputting each image into a detection model, and the detection model is configured to output the each image according to the input each image. A detection result of an image, the detection result includes target area information of the target object in each image; the target area where the target object is located in each image is determined based on the detection result.
基于上述可选地实现方式,在获取到至少两帧图像后,通过检测模型来实时确定目标对象在图像中所位于的目标区域,提高了确定目标区域的准确性,进一步保证了目标对象的清晰成像。Based on the above optional implementation manner, after acquiring at least two frames of images, the target area where the target object is located in the image is determined in real time by the detection model, which improves the accuracy of determining the target area and further ensures the clarity of the target object. imaging.
第二方面,提供了一种自动聚焦装置,该装置包括:In a second aspect, an automatic focusing device is provided, the device comprising:
图像获取模块,用于获取包括目标对象的至少两帧图像,该至少两帧图像由该摄像机对所拍摄区域进行图像采集得到;an image acquisition module, configured to acquire at least two frames of images including the target object, the at least two frames of images are obtained by image capturing of the captured area by the camera;
FV获取模块,用于对于该至少两帧图像中的每一图像,确定该目标对象在该每一图像中所位于的目标区域,获取每个该目标区域所对应的聚焦值FV;The FV acquisition module is used for, for each of the at least two frames of images, to determine the target area where the target object is located in each of the images, and to acquire the focus value FV corresponding to each of the target areas;
控制模块,用于基于获得的至少两个FV,获取该摄像机中的聚焦电机的目标位置,控制该摄像机中的聚焦电机移动至该目标位置,以使通过聚焦镜头的光线焦点落在该摄像机的感光平面上,该目标位置所对应的FV符合目标聚焦条件。The control module is configured to obtain the target position of the focusing motor in the camera based on the obtained at least two FVs, and control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the camera's On the photosensitive plane, the FV corresponding to the target position conforms to the target focusing condition.
可选地,该图像获取模块包括:Optionally, the image acquisition module includes:
第一获取单元,用于获取该摄像机中的聚焦电机的当前位置,基于该当前位置,获取至少一个参考位置,该至少一个参考位置与该当前位置之间的距离为调整步长;a first obtaining unit, configured to obtain the current position of the focusing motor in the camera, and based on the current position, obtain at least one reference position, and the distance between the at least one reference position and the current position is the adjustment step;
第二获取单元,用于控制该摄像机中的聚焦电机分别移动至该初始位置和该至少一个参考位置上,在该摄像机中的聚焦电机位于该当前位置以及该至少一个参考位置上时,该摄像机获取该至少两帧图像。a second acquisition unit, configured to control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is located at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
可选地,该第一获取单元,用于响应于该摄像机首次检测到该目标对象,通过预测获取该当前位置;响应于该摄像机非首次检测到该目标对象,获取该摄像机中的聚焦电机当前所处的位置,将该当前所处的位置作为该当前位置。Optionally, the first acquiring unit is configured to acquire the current position by prediction in response to the camera detecting the target object for the first time; in response to the camera detecting the target object for the first time, acquire the current position of the focus motor in the camera. The current position is taken as the current position.
可选地,该第一获取单元,用于获取该摄像机与该目标对象之间的预测物距;基于该预测物距和该摄像机的焦距,获取该当前位置。Optionally, the first obtaining unit is configured to obtain the predicted object distance between the camera and the target object; and obtain the current position based on the predicted object distance and the focal length of the camera.
可选地,该调整步长为半个焦深。Optionally, the adjustment step is half the focal depth.
可选地,该第一获取单元,用于基于该当前位置,在该当前位置两侧,各获取一个该参考位置。Optionally, the first obtaining unit is configured to obtain the reference position on both sides of the current position based on the current position.
可选地,该控制模块用于获取每个FV与该摄像机中的聚焦电机的位置之间的关联关系;基于每个FV、该当前位置以及该至少一个参考位置,通过该关联关系,获取该摄像机中的聚焦电机的目标位置。Optionally, the control module is used to obtain the association relationship between each FV and the position of the focus motor in the camera; based on each FV, the current position and the at least one reference position, obtain the association relationship through the association relationship. The target position of the focus motor in the camera.
可选地,该FV获取模块用于将该每一图像输入到检测模型中,该检测模型用于根据输入的该每一图像,输出该每一图像的检测结果,该检测结果中包括该目标对象在该每一图像中的目标区域信息;基于该检测结果确定该目标对象在该每一图像中所位于的目标区域。Optionally, the FV acquisition module is used to input each image into a detection model, and the detection model is used to output the detection result of each image according to the inputted image, and the detection result includes the target. Target area information of the object in each image; determining the target area where the target object is located in each image based on the detection result.
第三方面,提供了一种自动聚焦摄像机,该自动聚焦摄像机包括图像传感器和处理器,该图像传感器用于获取上述第一方面或第一方面中任一种可选实现方式中的至少两帧图像,该处理器用于执行上述第一方面或第一方面中任一种可选方式所提供的自动聚焦方法。In a third aspect, an auto-focus camera is provided, the auto-focus camera includes an image sensor and a processor, and the image sensor is configured to acquire at least two frames in the first aspect or any optional implementation manner of the first aspect image, the processor is configured to execute the autofocus method provided in the first aspect or any optional manner of the first aspect.
第四方面,提供了一种自动聚焦设备,该自动聚焦设备包括处理器和存储器,该存储 器用于存储至少一段程序代码,该至少一段程序代码由该处理器加载并执行,以使得该自动聚焦设备执行上述第一方面或第一方面中任一种可选方式所提供的自动聚焦方法。In a fourth aspect, an automatic focusing device is provided, the automatic focusing device includes a processor and a memory for storing at least one piece of program code, the at least one piece of program code is loaded and executed by the processor to make the automatic focusing The device executes the autofocus method provided in the first aspect or any optional manner of the first aspect.
第五方面,提供了一种计算机可读存储介质,该计算机可读存储介质用于存储至少一段程序代码,该至少一段程序代码由处理器加载并执行,以使得计算机执行上述第一方面或第一方面中任一种可选方式所提供的自动聚焦方法。In a fifth aspect, a computer-readable storage medium is provided, the computer-readable storage medium is used to store at least one piece of program code, and the at least one piece of program code is loaded and executed by a processor, so that the computer executes the first aspect or the first aspect. The automatic focusing method provided by any one of the optional manners in one aspect.
第六方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括程序代码,当其在自动聚焦设备上运行时,使得该自动聚焦设备执行上述第一方面或第一方面的各种可选实现方式中提供的自动聚焦方法。In a sixth aspect, a computer program product or computer program is provided, the computer program product or computer program comprising program code which, when run on an autofocus device, causes the autofocus device to perform the above-mentioned first aspect or the first aspect The autofocus method provided in various optional implementations of .
附图说明Description of drawings
图1是本申请实施例提供的一种聚焦值与镜头位置的关系示意图;1 is a schematic diagram of the relationship between a focus value and a lens position provided by an embodiment of the present application;
图2是本申请实施例提供的一种自动聚焦方法的系统架构的示意图;FIG. 2 is a schematic diagram of a system architecture of an autofocus method provided by an embodiment of the present application;
图3是本申请实施例提供的一种自动聚焦方法的流程图;FIG. 3 is a flowchart of an automatic focusing method provided by an embodiment of the present application;
图4是本申请实施例提供的一种获取参考位置的示意图;4 is a schematic diagram of obtaining a reference position provided by an embodiment of the present application;
图5是本申请实施例提供的另一种自动聚焦方法的流程图;FIG. 5 is a flowchart of another autofocus method provided by an embodiment of the present application;
图6是本申请实施例提供的一种自动聚焦装置的结构示意图;6 is a schematic structural diagram of an automatic focusing device provided by an embodiment of the present application;
图7是本申请实施例提供的一种自动聚焦设备的结构示意图。FIG. 7 is a schematic structural diagram of an automatic focusing device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
在视频监控领域,如何聚焦是清晰成像的关键。对此,本申请实施例提供了一种自动聚焦方法,本申请实施例提供的自动聚焦方法能够应用在道路监控以及平安城市等需要对拍摄环境进行聚焦,以确保能够采集到清晰图像的场景中。示例性地,本申请实施例提供的自动聚焦方法能够应用的场景包括但不限于如下几种。In the field of video surveillance, how to focus is the key to clear imaging. In this regard, the embodiments of the present application provide an auto-focusing method, and the auto-focusing methods provided by the embodiments of the present application can be applied to scenes such as road monitoring and safe cities where the shooting environment needs to be focused to ensure that clear images can be collected . Exemplarily, scenarios to which the auto-focusing method provided in the embodiments of the present application can be applied include but are not limited to the following.
场景一、道路监控Scenario 1. Road monitoring
为了实时监控交通路况和道路中通过的车辆,通常会在道路上设置卡口装置,实现对通过当前道路的所有车辆的实时监控,在该卡口装置上安装有摄像机,用于对监控范围内的车辆进行实时图像采集。在该场景中,采用本申请实施例提供的自动聚焦方法,摄像机能够根据摄像机所采集到的图像,实时检测是否有目标车辆进入监控范围,以触发自动聚焦,实现对目标车辆的实时跟踪和监控,保证目标车辆的清晰成像。In order to monitor traffic conditions and vehicles passing on the road in real time, a bayonet device is usually installed on the road to realize real-time monitoring of all vehicles passing through the current road. A camera is installed on the bayonet device to monitor the monitoring range. real-time image acquisition of the vehicle. In this scenario, using the automatic focusing method provided by the embodiment of the present application, the camera can detect in real time whether a target vehicle enters the monitoring range according to the image collected by the camera, so as to trigger automatic focusing and realize real-time tracking and monitoring of the target vehicle. , to ensure a clear image of the target vehicle.
场景二、平安城市Scene 2. Safe City
平安城市是一种管理系统,能够满足城市管理、交通管理、应急指挥等需求,而且还可兼顾事故预警、安全生产监控等方面对图像监控的需求。通过图像监控系统,可实行网上可视化视频监控。在该场景中,将本申请实施例提供的自动聚焦方法应用于图像监控系统中的摄像机上,该摄像机能够实时监测是否有目标对象进入监控范围,以触发自动聚焦,实现对目标对象的实时跟踪和监控,保证目标对象的清晰成像。Safe City is a management system that can meet the needs of urban management, traffic management, emergency command, etc., and can also take into account the needs of image monitoring in aspects such as accident early warning and safety production monitoring. Through the image monitoring system, online visual video monitoring can be implemented. In this scenario, the automatic focusing method provided by the embodiment of the present application is applied to a camera in an image monitoring system, and the camera can monitor in real time whether a target object enters the monitoring range, so as to trigger automatic focusing and realize real-time tracking of the target object and monitoring to ensure clear imaging of the target object.
需要说明的是,上述场景仅为示例性的描述,本申请实施例提供的自动聚焦方法能够应用于多种需要进行聚焦的场景,本申请实施例对于自动聚焦方法的应用场景不作限定。It should be noted that the above scenarios are only exemplary descriptions, the auto-focusing method provided in the embodiments of the present application can be applied to various scenarios that require focusing, and the embodiments of the present application do not limit the application scenarios of the auto-focusing method.
为了更方便理解,在介绍本申请实施例提供的技术方案之前,下面对本申请实施例中涉及到的技术用语进行说明。For easier understanding, before introducing the technical solutions provided by the embodiments of the present application, the technical terms involved in the embodiments of the present application are described below.
聚焦,摄像机的成像原理是利用透镜聚焦光线成像,在这个过程中光线聚焦的焦点不一定落在感光平面上,需要通过聚焦电机调整聚焦镜头,使成像点落在感光平面上,使摄像机画面清晰成像,这个过程就是聚焦过程。Focusing, the imaging principle of the camera is to use the lens to focus the light for imaging. In this process, the focus of the light focusing does not necessarily fall on the photosensitive plane. The focusing lens needs to be adjusted by the focusing motor so that the imaging point falls on the photosensitive plane, so that the camera picture is clear. Imaging, this process is the focusing process.
焦深,是焦点深度的简称。焦点与感光平面的范围在一定范围内,对于人眼都是清晰的,焦点的清晰范围称为焦深。Depth of focus is the abbreviation for depth of focus. The range of the focal point and the photosensitive plane is within a certain range, which is clear to the human eye, and the clear range of the focus is called the depth of focus.
景深,当某一物体聚焦清晰时,从该物体前面的某一段距离到其后面的某一段距离内的所有景物也都当清晰的。这段从前到后的距离就叫做景深。Depth of field, when an object is in focus, all the scenery from a certain distance in front of the object to a certain distance behind it should also be in focus. This distance from front to back is called the depth of field.
物距,物体到成像平面的距离。在本申请中,相对于物距而言,摄像机的镜头内部参数可以忽略不计,因此,近似认为物距为被拍摄物体到摄像机前端第一个镜头的距离。Object distance, the distance from the object to the imaging plane. In this application, relative to the object distance, the internal parameters of the camera lens can be ignored. Therefore, the object distance is approximately considered to be the distance from the object to be photographed to the first lens in front of the camera.
焦距,摄像机参数,是指摄像机中的镜片光学中心到底片、图像传感器等成像平面的距离。The focal length, the camera parameter, refers to the distance from the optical center of the lens in the camera to the imaging plane such as the film and the image sensor.
多物距场景,在同一个场景下,画面不同位置的物体距离摄像机的距离不同,这种场景称为多物距场景。In a multi-object-distance scene, in the same scene, objects at different positions on the screen have different distances from the camera. This kind of scene is called a multi-object-distance scene.
聚焦值(focus value,FV),也称为清晰度统计值,用于评价图像的清晰度。示意性地,参考图1,图1是本申请实施例提供的一种聚焦值与镜头位置的关系示意图,如图1所示,图1中的聚焦评价函数也即是聚焦值FV,通常在一个固定场景下,图像的FV随着镜头位置的移动而变化,呈现出像山坡一样的类高斯函数形状,山坡的峰值所对应的镜头位置对应于图像的清晰点。其中,镜头位置由聚焦电机控制。相关技术中,FV的计算方式有灰度梯度法以及高频分量法等。Focus value (FV), also known as sharpness statistic, is used to evaluate the sharpness of an image. Schematically, referring to FIG. 1, FIG. 1 is a schematic diagram of the relationship between a focus value and a lens position provided by an embodiment of the present application. As shown in FIG. 1, the focus evaluation function in FIG. 1 is also the focus value FV, which is usually in In a fixed scene, the FV of the image changes with the movement of the lens position, showing a Gaussian-like function shape like a hillside, and the lens position corresponding to the peak of the hillside corresponds to the clear point of the image. Among them, the lens position is controlled by the focus motor. In the related art, the calculation methods of FV include gray gradient method and high frequency component method.
爬坡算法,是在一定范围内搜索FV最大值的聚焦算法。爬坡算法一开始的时候会给出一个初始的电机移动方向,在电机移动后对比移动前和移动后的FV,如果FV变大则继续向该方向移动电机,如果FV变小则反方向移动电机。电机移动过程中不断监测FV变化,当FV不断变大的时候则说明焦点是向感光平面不断移动的,直到FV出现下降,说明已经到达清晰点,聚焦过程结束。The climbing algorithm is a focusing algorithm that searches for the maximum value of FV within a certain range. At the beginning of the climbing algorithm, an initial motor movement direction will be given. After the motor moves, the FV before and after the movement are compared. If the FV becomes larger, the motor will continue to move in this direction, and if the FV becomes smaller, it will move in the opposite direction. motor. During the movement of the motor, the change of FV is constantly monitored. When the FV continues to increase, it means that the focus is constantly moving towards the photosensitive plane. When the FV drops, it means that the clear point has been reached, and the focusing process is over.
图2是本申请实施例提供的一种自动聚焦方法的系统架构。如图2所示,本申请实施例提供的自动聚焦方法应用于摄像机200中。摄像机200包括但不限于:模拟摄像机、网络摄像机以及高清摄像机等。其中,摄像机200包括:镜头210、图像传感器220、图像信号处理单元230、聚焦电机240以及中央处理器250。FIG. 2 is a system architecture of an auto-focusing method provided by an embodiment of the present application. As shown in FIG. 2 , the automatic focusing method provided in this embodiment of the present application is applied to the camera 200 . The cameras 200 include, but are not limited to, analog cameras, network cameras, and high-definition cameras. The camera 200 includes a lens 210 , an image sensor 220 , an image signal processing unit 230 , a focus motor 240 and a central processing unit 250 .
镜头210主要用于对所拍摄区域进行光线采集。The lens 210 is mainly used to collect light on the photographed area.
图像传感器220用于将光学信号转换为图像模拟电信号,可选地,在本申请实施例中涉及的图像传感器220包括感光耦合器件(charge-coupled device,CCD)图像传感器。还包括基于互补金属氧化物半导体(complementary metal oxide semiconductor,CMOS)工艺得到的图像传感器,这种图像传感器也称为CMOS图像传感器(CMOS image sensor),是网络摄像机、数码相机和其他电子光学设备的核心部件。当然,在一些实施例中还可能包括其他类型的图像传感器,在此,本申请实施例对所涉及到的图像传感器220的类型不做限定。The image sensor 220 is used to convert the optical signal into an image analog electrical signal. Optionally, the image sensor 220 involved in the embodiment of the present application includes a charge-coupled device (CCD) image sensor. It also includes image sensors based on complementary metal oxide semiconductor (complementary metal oxide semiconductor, CMOS) processes, also known as CMOS image sensors (CMOS image sensors), which are used in network cameras, digital cameras and other electronic optical devices. Core components. Certainly, other types of image sensors may also be included in some embodiments, and the types of the involved image sensors 220 are not limited in this embodiment of the present application.
图像信号处理单元230(image signal process,ISP)主要用于对图像传感器220输出的信号进行处理,通过一系列数字图像处理算法对图像信号进行处理,获得图像的FV。The image signal processing unit 230 (image signal process, ISP) is mainly used for processing the signal output by the image sensor 220, and processing the image signal through a series of digital image processing algorithms to obtain the FV of the image.
聚焦电机240用于带动镜头210移动,以使成像点落在图像传感器220上,实现画面 清晰成像。The focusing motor 240 is used to drive the lens 210 to move, so that the imaging point falls on the image sensor 220, so as to realize clear image of the picture.
中央处理器250(central processing unit,CPU)用于根据FV控制聚焦电机240运动,以实现聚焦。A central processing unit (CPU) 250 is used to control the movement of the focusing motor 240 according to the FV, so as to realize focusing.
下面对本申请实施例提供的自动聚焦方法进行示例性的说明。图3是本申请实施例提供的一种自动聚焦方法的流程图,在本申请实施例中,该自动聚焦方法由如图2所示的摄像机200执行,例如,该自动聚焦方法可应用于摄像机200的中央处理器250中。示例性地,该自动聚焦方法包括以下几个步骤。The autofocus method provided by the embodiments of the present application is exemplarily described below. FIG. 3 is a flowchart of an auto-focusing method provided by an embodiment of the present application. In the embodiment of the present application, the auto-focusing method is performed by the camera 200 shown in FIG. 2 . For example, the auto-focusing method can be applied to a camera 200 in the central processing unit 250. Exemplarily, the auto-focusing method includes the following steps.
301、摄像机获取包括目标对象的至少两帧图像,至少两帧图像由摄像机对所拍摄区域进行图像采集得到。301. The camera acquires at least two frames of images including the target object, and the at least two frames of images are acquired by the camera through image acquisition of the captured area.
在本申请实施例中,拍摄区域是指需要进行图像采集的区域。目标对象是指符合自动聚焦条件的对象。可选地,目标对象为拍摄区域中的移动物体。例如,目标对象为机动车辆、非机动车辆或行人等,本申请对此不作限定。可选地,目标对象为预先设置的指定对象。例如,在涉及机动车监控的场景下,将需要进行实时跟踪的车辆设置为目标对象。In the embodiments of the present application, the shooting area refers to an area where image acquisition needs to be performed. The target object is the object that meets the autofocus conditions. Optionally, the target object is a moving object in the shooting area. For example, the target object is a motor vehicle, a non-motor vehicle, a pedestrian, etc., which is not limited in this application. Optionally, the target object is a preset designated object. For example, in a scenario involving motor vehicle monitoring, the vehicle that needs to be tracked in real time is set as the target object.
在一种可能的实现方式中,摄像机获取包括目标对象的至少两帧图像的方式,包括但不限于如下步骤311-314。In a possible implementation manner, the manner in which the camera acquires at least two frames of images including the target object includes but is not limited to the following steps 311-314.
311,摄像机检测到摄像机的拍摄区域中存在目标对象。311. The camera detects that a target object exists in the shooting area of the camera.
在一些实施例中,摄像机包括图像存储模块和检测模块,该图像存储模块用于将摄像机对所拍摄区域进行图像采集得到的每一帧图像进行存储,由检测模块对图像存储模块所存储的图像进行检测,以确定拍摄区域中是否存在目标对象。In some embodiments, the camera includes an image storage module and a detection module, the image storage module is used to store each frame of image obtained by the camera on the captured area, and the detection module stores the image in the image storage module. Detection is performed to determine if a target object is present in the shot area.
可选地,摄像机对所拍摄区域进行图像采集时,每秒采集N帧图像,并将每帧图像都存储至图像存储模块,由检测模块对图像存储模块中的图像每间隔M帧检测一次,以确定拍摄区域中是否存在目标对象;其中,N和M均为正整数,N大于M。例如,摄像机每秒采集25帧图像,将采集到的每帧图像实时存储至图像存储模块,检测模块对图像存储模块中的图像每间隔3帧检测一次。需要说明的是,通常在间隔3帧图像的时长内,近似认为处于移动状态下的目标对象在所拍摄区域中的位置不变,因此,在本申请实施例中,检测模块每间隔3帧检测一次。在实际应用中,开发人员能够根据需求设置检测模块对每一帧图像都进行检测,本申请对于检测模块的检测频率不作限定。Optionally, when the camera collects images of the captured area, N frames of images are collected every second, and each frame of images is stored in the image storage module, and the images in the image storage module are detected by the detection module every M frames. To determine whether there is a target object in the shooting area; wherein, N and M are both positive integers, and N is greater than M. For example, the camera collects 25 frames of images per second, and stores each frame of the collected images in the image storage module in real time, and the detection module detects the images in the image storage module every 3 frames. It should be noted that, usually within the time interval of 3 frames of images, it is approximately considered that the position of the target object in the moving state in the photographed area does not change. Therefore, in the embodiment of the present application, the detection module detects every 3 frames. once. In practical applications, the developer can set the detection module to detect each frame of images according to requirements, and the application does not limit the detection frequency of the detection module.
可选地,摄像机通过无线网络或有线网络与终端相连。终端上运行有指定应用程序,该指定应用程序用于对摄像机进行功能设置。例如,该指定应用程序提供智能检测模式的设置选项,用户能够在终端上进行操作以开启智能检测模式,终端响应于用户对智能检测模式的开启操作,向摄像机发送相应的开启指令,该开启指令用于触发检测模块对图像存储模块所存储的图像进行智能检测。Optionally, the camera is connected to the terminal through a wireless network or a wired network. A designated application program runs on the terminal, and the designated application program is used to set the functions of the camera. For example, the designated application program provides a setting option of the smart detection mode, the user can operate the terminal to turn on the smart detection mode, and the terminal sends a corresponding turn-on instruction to the camera in response to the user's operation of turning on the smart detection mode, and the turn-on instruction It is used to trigger the detection module to perform intelligent detection on the images stored in the image storage module.
可选地,摄像机通过检测模型来检测拍摄区域中是否存在目标对象,下面对这种可选地实现方式进行详细阐述,包括下述步骤3111和步骤3112:Optionally, the camera detects whether there is a target object in the shooting area by using the detection model. This optional implementation is described in detail below, including the following steps 3111 and 3112:
3111、摄像机将至少两帧图像输入到检测模型中,该至少两帧图像为摄像机对所拍摄区域进行图像采集得到。3111. The camera inputs at least two frames of images into the detection model, where the at least two frames of images are acquired by the camera through image acquisition of the captured area.
其中,检测模型用于根据输入的每一图像,输出每一图像的检测结果。该检测结果用于指示每一图像中是否存在目标对象。若图像中存在目标对象,则检测结果中包括目标对象在每一图像中的目标区域信息。可选地,该目标区域信息包括目标对象的标识、目标区 域的尺寸以及目标区域在每一图像中所处的位置。The detection model is used to output the detection result of each image according to each input image. The detection result is used to indicate whether the target object exists in each image. If there is a target object in the image, the detection result includes the target area information of the target object in each image. Optionally, the target area information includes the identification of the target object, the size of the target area, and the location of the target area in each image.
在一些实施例中,检测模型根据输入的一帧图像,对该图像进行图像语义分割,对该图像的各个像素进行分类,以获取各个像素的语义类别,得到图像分割结果,然后基于图像分割结果,输出该图像的检测结果。其中,若该图像中存在目标对象,则图像分割结果中包括目标对象的分割图像,该检测模型能够基于该分割图像,确定目标对象在图像中的目标区域信息,以输出检测结果。In some embodiments, the detection model performs image semantic segmentation on an input frame of image, and classifies each pixel of the image to obtain the semantic category of each pixel to obtain an image segmentation result, and then based on the image segmentation result , and output the detection result of the image. Wherein, if there is a target object in the image, the image segmentation result includes the segmented image of the target object, and the detection model can determine the target area information of the target object in the image based on the segmented image to output the detection result.
在另一些实施例中,检测模型根据输入的一帧图像,对图像中各个物体的边缘轮廓、纹理和灰度等信息构建模板,通过模板匹配的方法检测目标对象。若图像中有物体的模板与目标对象匹配,则检测模型基于该物体在图像中所处的目标区域,确定目标区域信息,以输出检测结果。In other embodiments, the detection model constructs a template for information such as edge contour, texture and gray level of each object in the image according to an input frame of image, and detects the target object by a template matching method. If the template of the object in the image matches the target object, the detection model determines the target area information based on the target area where the object is located in the image, so as to output the detection result.
需要说明的是,上述检测模型的运算过程仅为示意性地,本申请对于检测模型的检测目标对象的方式不作限定。It should be noted that the operation process of the above detection model is only illustrative, and the present application does not limit the method of detecting the target object of the detection model.
3112、摄像机响应于检测结果中包括目标对象在每一图像中的目标区域信息,获取该目标区域信息。3112. In response to the detection result including the target area information of the target object in each image, the camera acquires the target area information.
其中,若检测模型输出的检测结果中包括目标对象在每一图像中的目标区域信息,则说明摄像机所拍摄区域中当前存在目标对象,摄像机获取该目标区域信息,并执行下述步骤312。相反地,若检测模型输出的检测结果中不包括目标对象在每一图像中的目标区域信息,则说明摄像机所拍摄区域中当前不存在目标对象,则摄像机重复执行本步骤311,直到获取到目标区域信息。Wherein, if the detection result output by the detection model includes the target area information of the target object in each image, it means that the target object currently exists in the area captured by the camera, the camera obtains the target area information, and executes the following step 312 . On the contrary, if the detection result output by the detection model does not include the target area information of the target object in each image, it means that there is currently no target object in the area captured by the camera, and the camera repeats this step 311 until the target is acquired Regional information.
需要说明的是,在上述步骤3111和3112中,检测模型可以是基于指定场景的检测模型。可选地,该检测模型用于检测图像中具有一定特征的行人,以输出检测结果。例如,该检测模型用于检测图像中出现的男性。可选地,该检测模型用于检测图像中的特定车辆,以输出检测结果。例如,该检测模型用于检测图像中出现的公交车辆。在实际应用中,开发人员能够根据需求对检测模型进行训练,以得到相应的检测模型,本申请对此不作限定。It should be noted that, in the above steps 3111 and 3112, the detection model may be a detection model based on a specified scene. Optionally, the detection model is used to detect pedestrians with certain characteristics in the image to output detection results. For example, this detection model is used to detect males appearing in images. Optionally, the detection model is used to detect specific vehicles in the image to output detection results. For example, this detection model is used to detect public transit vehicles that appear in images. In practical applications, developers can train detection models according to requirements to obtain corresponding detection models, which are not limited in this application.
通过上述步骤311,摄像机根据摄像机采集到的图像,检测所拍摄区域中是否存在目标对象,能够有针对性的确定图像中的目标区域,以得到目标区域信息,不仅能够成为触发自动聚焦的先验信息,还能够在后续聚焦过程中保证目标对象的清晰成像。Through the above step 311, the camera detects whether there is a target object in the shooting area according to the image collected by the camera, and can determine the target area in the image in a targeted manner to obtain the target area information, which can not only become a priori for triggering automatic focusing information, and can also ensure clear imaging of the target object in the subsequent focusing process.
312、摄像机获取该摄像机中的聚焦电机的当前位置。312. The camera acquires the current position of the focus motor in the camera.
在本申请实施例中,本步骤312由摄像机中的聚焦模块来执行。其中,本步骤312包括以下任一种情况:In this embodiment of the present application, this step 312 is performed by the focusing module in the camera. Wherein, this step 312 includes any of the following situations:
情况一、摄像机响应于摄像机首次检测到目标对象,通过预测获取摄像机中的聚焦电机的当前位置。Case 1: In response to the camera detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera through prediction.
情况二、摄像机响应于该摄像机非首次检测到该目标对象,获取该摄像机中的聚焦电机当前所处的位置,将该当前所处的位置作为当前位置。Case 2: In response to the camera not detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera, and uses the current position as the current position.
需要说明的是,在本申请实施例中,无论摄像机是首次检测到目标对象还是非首次检测到目标对象,都能够获取到一个当前位置,便于后续通过该当前位置进行聚焦循环。也就是说,摄像机只要能够检测到目标对象,就会一直进行聚焦循环,在每一次聚焦过程中都会获取一个当前位置,如果是首次检测到目标对象,就通过预测获取一个当前位置,然后在该当前位置的基础上进行第一次聚焦,如果是第二次检测到目标对象,就获取聚焦电 机当前所处的位置,也即是聚焦电机在完成第一次聚焦时所处的位置,然后在该位置的基础上进行第二次聚焦,以此类推,一直循环下去,直到摄像机不再检测到目标对象。可选地,也可设置一个检测周期,在检测周期内如果检测到目标对象则继续循环,如果检测周期结束,则不再检测。It should be noted that, in this embodiment of the present application, regardless of whether the camera detects the target object for the first time or not for the first time, a current position can be obtained, which is convenient for subsequent focusing cycles through the current position. That is to say, as long as the camera can detect the target object, it will continue to focus on the cycle, and will obtain a current position during each focusing process. If the target object is detected for the first time, it will obtain a current position through prediction, and then in the The first focusing is performed on the basis of the current position. If the target object is detected for the second time, the current position of the focusing motor is obtained, that is, the position of the focusing motor when the first focusing is completed, and then the current position of the focusing motor is obtained. Based on this position, a second focus is performed, and so on, and the cycle continues until the camera no longer detects the target object. Optionally, a detection period may also be set, and if the target object is detected within the detection period, the cycle will continue, and if the detection period ends, no further detection will be performed.
313、摄像机基于该当前位置,获取至少一个参考位置,该至少一个参考位置与该当前位置之间的距离为调整步长。313. The camera acquires at least one reference position based on the current position, and the distance between the at least one reference position and the current position is an adjustment step.
在本申请实施例中,本步骤313由摄像机中的聚焦模块来执行。其中,调整步长是指摄像机的聚焦电机的移动步长。可选地,调整步长为半个焦深,本申请对此不作限定。可选地,摄像机基于该当前位置,在该当前位置两侧,各获取一个参考位置,其中,调整步长为半个焦深,该焦深基于该当前位置计算得到。In this embodiment of the present application, this step 313 is performed by the focusing module in the camera. The adjustment step length refers to the moving step length of the focus motor of the camera. Optionally, the adjustment step length is half the focal depth, which is not limited in this application. Optionally, based on the current position, the camera obtains a reference position on both sides of the current position, wherein the adjustment step is half a focal depth, and the focal depth is calculated based on the current position.
下面以摄像机基于该当前位置,获取两个参考位置为例,对本步骤进行详细说明:Taking the camera to obtain two reference positions based on the current position as an example, this step will be described in detail below:
可选地,参考图4,图4是本申请实施例提供的一种获取参考位置的示意图。如图4所示,摄像机获取到的当前位置为P1,在P1位置的两侧,间隔半个焦深的位置,分别为参考位置P2和P3。其中,焦深通过下述公式(1)计算得到:Optionally, referring to FIG. 4 , FIG. 4 is a schematic diagram of obtaining a reference position according to an embodiment of the present application. As shown in FIG. 4 , the current position acquired by the camera is P1, and the positions on both sides of the position P1, which are separated by half the focal depth, are the reference positions P2 and P3, respectively. Among them, the depth of focus is calculated by the following formula (1):
焦深=a×F×L×fDepth of focus = a×F×L×f
(1)式中,a为摄像机的固定参数,不同型号摄像机的a值不同;F为摄像机的光圈值;L为物距,具体可通过后续步骤3121中的公式(7)和公式(8)计算得到;f为焦距。In formula (1), a is a fixed parameter of the camera, and the value of a is different for different models of cameras; F is the aperture value of the camera; L is the object distance, which can be determined by formula (7) and formula (8) in the subsequent step 3121. Calculated; f is the focal length.
需要说明的是,在一些实施例中,摄像机能够基于该当前位置,获取W个参考位置,W为大于2的正整数,例如,在该当前位置两侧,每间隔半个焦深,获取一个参考电机位置,一共获取4个参考位置。本申请对此不作限定。It should be noted that, in some embodiments, the camera can obtain W reference positions based on the current position, where W is a positive integer greater than 2. For example, on both sides of the current position, at every half depth of focus, obtain one reference position. With reference to the motor position, a total of 4 reference positions are obtained. This application does not limit this.
314、摄像机控制摄像机中的聚焦电机分别移动至该当前位置和该至少一个参考位置上,在该摄像机中的聚焦电机位于该当前位置以及该至少一个参考位置上时,获取至少两帧图像。314. The camera controls the focus motor in the camera to move to the current position and the at least one reference position respectively, and acquires at least two frames of images when the focus motor in the camera is at the current position and the at least one reference position.
在本申请实施例中,本步骤314由摄像机中的聚焦模块来执行。其中,该至少两帧图像由摄像机对所拍摄区域进行图像采集得到。其中,摄像机中的聚焦电机每位于一个位置上时,摄像机获取相应位置的一帧图像。In this embodiment of the present application, this step 314 is performed by the focusing module in the camera. Wherein, the at least two frames of images are obtained by image capturing of the captured area by the camera. Wherein, each time the focus motor in the camera is located at a position, the camera acquires a frame of image of the corresponding position.
302、摄像机对于至少两帧图像中的每一图像,确定目标对象在每一图像中所位于的目标区域,获取每个目标区域所对应的FV。302. For each image in the at least two frames of images, the camera determines a target area where the target object is located in each image, and acquires the FV corresponding to each target area.
在本申请实施例中,本步骤302由摄像机中的聚焦模块来执行。其中,FV用于评价目标区域的图像清晰度。可选地,FV的计算方式可以采用灰度梯度法或高频分量法等,本申请对此不作限定。In this embodiment of the present application, this step 302 is performed by the focusing module in the camera. Among them, FV is used to evaluate the image sharpness of the target area. Optionally, the calculation method of FV may adopt a gray gradient method or a high frequency component method, etc., which is not limited in this application.
在一些实施例中,摄像机对于至少两帧图像中的每一图像,根据步骤301中获取到的目标区域信息,确定目标对象在每一图像中所位于的目标区域,从而获取每个区域所对应的FV。In some embodiments, for each image in the at least two frames of images, the camera determines the target area where the target object is located in each image according to the target area information obtained in step 301, so as to obtain the target area corresponding to each area. the FV.
在另一些实施例中,摄像机对于至少两帧图像中的每一图像,将每一图像输入到检测模型中,该检测模型用于根据输入的每一图像,输出每一图像的检测结果,该检测结果中包括目标对象在每一图像中的目标区域信息。然后摄像机根据检测结果中的目标区域信息,确定目标对象在每一图像中所位于的目标区域,从而获取每个目标区域所对应的FV。需要 说明的是,检测模型的实现方式已在上述步骤301中说明,故在此不再赘述。In other embodiments, for each image in the at least two frames of images, the camera inputs each image into a detection model, and the detection model is configured to output a detection result of each image according to each input image, the The detection result includes the target area information of the target object in each image. Then, according to the target area information in the detection result, the camera determines the target area where the target object is located in each image, so as to obtain the FV corresponding to each target area. It should be noted that, the implementation of the detection model has been described in the above step 301, so it will not be repeated here.
需要说明的第一点是,本申请实施例对于摄像机确定目标对象在每一图像中所位于的目标区域的方式不做限定。也即是,摄像机能够根据从步骤301获取到的目标区域信息进行确定,也能够将每一帧图像输入到一个检测模型中进行检测,以确定目标区域信息。The first point that needs to be explained is that the embodiments of the present application do not limit the manner in which the camera determines the target area where the target object is located in each image. That is, the camera can determine according to the target area information obtained from step 301, and can also input each frame of image into a detection model for detection, so as to determine the target area information.
需要说明的第二点是,上述步骤301和步骤302可同步执行,也即是,每当摄像机控制聚焦电机移动到一个电机位置时,随即获取到一帧图像,确定目标对象在该图像中所位于的目标区域,并计算得到一个目标区域所对应的FV。The second point that needs to be explained is that the above steps 301 and 302 can be executed synchronously, that is, whenever the camera controls the focus motor to move to a motor position, a frame of image is immediately acquired, and it is determined that the target object is located in the image. located in the target area, and calculate the FV corresponding to a target area.
可选地,下面以摄像机获取两个参考位置,调整步长为半个焦深为例,对上述步骤进行具体说明。例如,继续参考图4,上述步骤301和步骤302可以替换为下述步骤一至步骤三:Optionally, the above steps are specifically described below by taking the camera acquiring two reference positions and adjusting the step size as half the focal depth as an example. For example, with continued reference to FIG. 4 , the above steps 301 and 302 can be replaced with the following steps 1 to 3:
步骤一、摄像机控制聚焦电机移动到当前位置P1上,获取到第一帧图像,并基于目标区域信息,确定目标对象在该第一帧图像中所位于的目标区域,然后计算得到第一个目标区域所对应的FV。Step 1. The camera controls the focus motor to move to the current position P1, obtains the first frame of image, and determines the target area where the target object is located in the first frame of image based on the target area information, and then calculates the first target. The FV corresponding to the region.
步骤二、摄像机控制聚焦电机以P1为起点,以半个焦深为调整步长,正向移动到达参考位置P2,获取到第二帧图像,并基于目标区域信息,确定目标对象在该第二帧图像中所位于的目标区域,然后计算得到第二个目标区域所对应的FV。Step 2: The camera controls the focusing motor with P1 as the starting point and half the focal depth as the adjustment step, moves forward to reach the reference position P2, obtains the second frame of image, and determines that the target object is in the second frame based on the target area information. The target area located in the frame image, and then calculate the FV corresponding to the second target area.
步骤三、摄像机控制聚焦电机以P2为起点,以一个焦深为调整步长,反向移动到达参考位置P3,获取到第三帧图像,并基于目标区域信息,确定目标对象在该第三帧图像中所位于的目标区域,然后计算得到第三个目标区域所对应的FV。Step 3: The camera controls the focusing motor with P2 as the starting point and a focal depth as the adjustment step, moves in the reverse direction to reach the reference position P3, obtains the third frame of image, and determines the target object in the third frame based on the target area information The target area located in the image, and then calculate the FV corresponding to the third target area.
需要说明的是,图4所示仅为示意性地,在实际应用中,摄像机能够控制聚焦电机先反向移动到达P3,再正向移动到达P2,本申请对此不作限定。另外需要说明的是,上述步骤中的正向和反向是相对于聚焦电机的默认移动方向而言,该默认移动方向可以预先设置,本申请实施例对此不作限定。It should be noted that, what is shown in FIG. 4 is only schematic. In practical applications, the camera can control the focus motor to first move in the reverse direction to reach P3, and then move forward to reach P2, which is not limited in this application. In addition, it should be noted that the forward and reverse directions in the above steps are relative to the default moving direction of the focusing motor, and the default moving direction may be preset, which is not limited in this embodiment of the present application.
下面以摄像机基于一帧图像获取一个目标区域所对应的FV为例,进行举例说明:The following takes the camera to obtain the FV corresponding to a target area based on one frame of image as an example to illustrate:
例如,摄像机获取到一帧图像,同时获取到该图像的整个区域的FV,通常,将一帧图像划分为255个子区域,每个子区域均对应一个子FV,摄像机根据获取到的目标区域信息,确定目标对象在该图像中所位于的目标区域,然后将与目标区域对应的所有子区域的FV进行相加,得到目标区域所对应的FV。需要说明的是,在实际应用中,目标区域所对应的FV有多种计算方式,在一些实施例中,摄像机还能够通过求取与目标区域对应的所有子区域的FV的平均值,将该平均值作为目标区域所对应的FV。本申请实施例对于目标区域的FV的计算方式不做限定。For example, when the camera acquires a frame of image, it also acquires the FV of the entire area of the image. Usually, a frame of image is divided into 255 sub-areas, and each sub-area corresponds to a sub-FV. Determine the target area where the target object is located in the image, and then add the FVs of all sub-areas corresponding to the target area to obtain the FV corresponding to the target area. It should be noted that, in practical applications, the FV corresponding to the target area can be calculated in various ways. In some embodiments, the camera can also obtain the average value of the FV of all sub-areas corresponding to the target area to calculate The average value is taken as the FV corresponding to the target area. The embodiment of the present application does not limit the calculation method of the FV of the target area.
303、摄像机基于获得的至少两个FV,获取摄像机中的聚焦电机的目标位置,控制摄像机中的聚焦电机移动至该目标位置,以使通过聚焦镜头的光线焦点落在该摄像机的感光平面上,该目标位置所对应的FV符合目标聚焦条件。303. The camera acquires the target position of the focusing motor in the camera based on the obtained at least two FVs, and controls the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, The FV corresponding to the target position meets the target focus condition.
在本申请实施例中,本步骤303由摄像机中的聚焦模块来执行。其中,目标聚焦条件是指目标对象的成像符合清晰度要求。在本步骤中,摄像机将获得的至少两个FV作为纵坐标,将与FV对应的聚焦电机的位置作为横坐标,通过拟合得到目标位置。In this embodiment of the present application, this step 303 is performed by the focusing module in the camera. The target focusing condition means that the imaging of the target object meets the definition requirement. In this step, the camera takes the obtained at least two FVs as the ordinate and the position of the focusing motor corresponding to the FVs as the abscissa, and obtains the target position through fitting.
可选地,本步骤303中,摄像机基于获得的至少两个FV,获取摄像机中的聚焦电机的目标位置,包括以下步骤3031和步骤3032:Optionally, in this step 303, the camera obtains the target position of the focus motor in the camera based on the obtained at least two FVs, including the following steps 3031 and 3032:
3031、摄像机获取每个FV与摄像机中的聚焦电机的位置之间的关联关系。3031. The camera acquires an association relationship between each FV and the position of the focus motor in the camera.
3032、摄像机基于每个FV、当前位置以及至少一个参考位置,通过该关联关系,获取该摄像机中的聚焦电机的目标位置。3032. The camera obtains the target position of the focus motor in the camera based on each FV, the current position, and the at least one reference position and through the association relationship.
下面以参考位置为2个为例,对上述步骤3031和步骤3032进行详细阐述:The following steps 3031 and 3032 are described in detail by taking two reference positions as an example:
例如,继续参考图4,如图4所示,摄像机的聚焦电机的当前位置为P1,参考位置分别为P2和P3,这三个位置分别对应一个目标区域的FV。摄像机获取每个FV与摄像机中的聚焦电机的位置之间的关联关系,也即是下述公式(2)。进一步地,摄像机基于该公式(2)分别得到电机位置P1、P2、P3与各个电机位置所对应的FV之间的关系式,如公式(3)至公式(5)所示。For example, continuing to refer to FIG. 4 , as shown in FIG. 4 , the current position of the focus motor of the camera is P1, and the reference positions are P2 and P3 respectively, and these three positions correspond to the FV of a target area respectively. The camera obtains the relationship between each FV and the position of the focus motor in the camera, that is, the following formula (2). Further, based on the formula (2), the camera obtains the relational expressions between the motor positions P1, P2, P3 and the FV corresponding to each motor position, as shown in formulas (3) to (5).
Figure PCTCN2021113969-appb-000001
Figure PCTCN2021113969-appb-000001
Figure PCTCN2021113969-appb-000002
Figure PCTCN2021113969-appb-000002
Figure PCTCN2021113969-appb-000003
Figure PCTCN2021113969-appb-000003
Figure PCTCN2021113969-appb-000004
Figure PCTCN2021113969-appb-000004
公式(2)中,y表示FV,x表示电机位置,a和c为可变参数,b为目标位置;上述公式(3)至公式(5)中,x 1、x 2以及x 3分别表示当前位置P1和参考位置P2和P3,y 1、y 2以及y 3分别表示与P1、P2以及P3所对应的目标区域的FV。 In formula (2), y represents FV, x represents the motor position, a and c are variable parameters, and b is the target position; in the above formulas (3) to (5), x 1 , x 2 and x 3 respectively represent The current position P1 and the reference positions P2 and P3, y 1 , y 2 and y 3 respectively represent the FVs of the target areas corresponding to P1 , P2 and P3 .
通过对上述公式(3)至公式(5)进行拟合,能够得到下述公式(6):By fitting the above formula (3) to formula (5), the following formula (6) can be obtained:
Figure PCTCN2021113969-appb-000005
Figure PCTCN2021113969-appb-000005
根据上述公式(6),能够计算得到b的取值,b即为聚焦电机的目标位置。According to the above formula (6), the value of b can be calculated, and b is the target position of the focusing motor.
需要说明的第一点是,在上述步骤中,通过计算目标区域所对应的FV,能够避免多物距的影响,使得摄像机仅针对目标对象进行聚焦,大大增加了目标对象成像的清晰度,同时还能够减少图像处理的数据量。The first point that needs to be explained is that in the above steps, by calculating the FV corresponding to the target area, the influence of multiple object distances can be avoided, so that the camera can only focus on the target object, which greatly increases the imaging clarity of the target object. It is also possible to reduce the amount of data for image processing.
需要说明的第二点是,在一些实施例中,摄像机在当前位置的基础上,获取到两个参考位置,使得摄像机执行上述步骤301至步骤303所需的时长仅为4帧画面的时间,例如,仅有0.16秒,在此时间段内,能够近似认为目标对象处于静止状态,基于此,能够最大程度保证目标位置的准确性。同时,大大减少了聚焦时间,提高了聚焦效率。The second point that needs to be explained is that, in some embodiments, the camera obtains two reference positions on the basis of the current position, so that the time required for the camera to perform the above steps 301 to 303 is only 4 frames of time. For example, it is only 0.16 seconds. During this time period, the target object can be approximately considered to be in a stationary state. Based on this, the accuracy of the target position can be guaranteed to the greatest extent. At the same time, the focusing time is greatly reduced and the focusing efficiency is improved.
需要说明的第三点是,经过上述步骤301至步骤303,当摄像机检测到摄像机所拍摄区域中存在目标对象时,触发自动聚焦,此时摄像机中的聚焦模块由空闲状态切换至聚焦状态。The third point that needs to be explained is that, after the above steps 301 to 303, when the camera detects that there is a target object in the area captured by the camera, automatic focusing is triggered, and the focusing module in the camera is switched from the idle state to the focusing state.
下面对上述步骤312中的两种情况进行详细阐述:The two situations in the above step 312 are described in detail below:
以情况一为例,上述步骤312替换为:摄像机响应于摄像机首次检测到目标对象,通过预测获取摄像机中的聚焦电机的当前位置。Taking case 1 as an example, the above step 312 is replaced with: in response to the camera detecting the target object for the first time, the camera obtains the current position of the focus motor in the camera through prediction.
在本申请实施例中,摄像机还包括聚焦模块,能够用于执行本步骤312,其中,当聚焦模块处于空闲状态时,摄像机检测到目标对象,则确定摄像机首次检测到目标对象,聚焦模块处于空闲状态是指聚焦模块当前不在聚焦过程中。可选地,聚焦模块每一帧都会检测摄像机是否获取到目标区域信息,若聚焦模块处于空闲状态时摄像机获取到目标区域信息,则确定摄像机首次检测到目标对象。In the embodiment of the present application, the camera further includes a focusing module, which can be used to perform step 312, wherein, when the focusing module is in an idle state and the camera detects the target object, it is determined that the camera detects the target object for the first time, and the focusing module is idle Status means that the focus module is not currently in the focus process. Optionally, the focusing module detects whether the camera acquires the target area information every frame. If the camera acquires the target area information when the focusing module is in an idle state, it is determined that the camera detects the target object for the first time.
下面对摄像机通过预测获取摄像机中的聚焦电机的当前位置的具体实施方式进行说明,包括下述步骤3121和步骤3122:The following describes the specific implementation of the camera to obtain the current position of the focus motor in the camera through prediction, including the following steps 3121 and 3122:
3121、摄像机获取摄像机与目标对象之间的预测物距。3121. The camera acquires a predicted object distance between the camera and the target object.
其中,预测物距通过下述公式(7)和公式(8)计算得到:Among them, the predicted object distance is calculated by the following formulas (7) and (8):
物距=目标猜测长度/检测框占整个画面的比例/视场角的正切函数Object distance = target guess length / ratio of detection frame to the entire screen / tangent function of field of view
(7)(7)
视场角=acrtan(传感器尺寸/焦距)field of view = acrtan (sensor size/focal length)
(8)(8)
下面对公式(7)和公式(8)进行详细阐述,包括以下三点:The formula (7) and formula (8) are elaborated below, including the following three points:
第一,在公式(7)中,目标猜测长度是对目标对象长度的预测值。可选地,摄像机预先设置目标猜测长度的数值,例如,当目标区域信息中目标对象的标识表明目标对象为车辆时,目标猜测长度为2.2米(m),本申请对于目标猜测长度的具体数值不作限定。需要说明的是,上述公式(7)中目标猜测长度还可以为目标猜测高度。可选地,摄像机预先设置目标猜测高度的数值,例如,当目标区域信息中目标对象的标识表明目标对象为行人时,目标猜测高度为1.7m。在实际应用中,能够根据需求设置相应的目标猜测长度,本申请实施例对此不作限定。First, in Equation (7), the target guess length is the predicted value of the target object length. Optionally, the camera pre-sets the value of the target guess length. For example, when the mark of the target object in the target area information indicates that the target object is a vehicle, the target guess length is 2.2 meters (m). The specific value of the target guess length in this application is Not limited. It should be noted that the target guess length in the above formula (7) may also be the target guess height. Optionally, the camera pre-sets the value of the target guessing height. For example, when the target object identifier in the target area information indicates that the target object is a pedestrian, the target guessing height is 1.7m. In practical applications, a corresponding target guess length can be set according to requirements, which is not limited in this embodiment of the present application.
第二,在公式(7)中,检测框占整个画面的比例是指目标区域的尺寸占整个图像的比例。可选地,摄像机根据目标区域信息中目标区域的尺寸计算得到目标区域的面积,从而得到检测框占整个画面的比例。Second, in formula (7), the ratio of the detection frame to the entire image refers to the ratio of the size of the target area to the entire image. Optionally, the camera calculates the area of the target area according to the size of the target area in the target area information, so as to obtain the ratio of the detection frame to the entire screen.
第三,在公式(7)中,视场角通过公式(8)计算得到,其中,传感器尺寸是指图像传感器成像平面的尺寸。Third, in formula (7), the field of view is calculated by formula (8), where the sensor size refers to the size of the imaging plane of the image sensor.
3122、摄像机基于预测物距和摄像机的焦距,获取摄像机中的聚焦电机的当前位置。3122. The camera acquires the current position of the focus motor in the camera based on the predicted object distance and the focal length of the camera.
其中,摄像机的焦距是能够直接获取到的一种实时的摄像机参数。在一些实施例中,摄像机还包括参数存储模块,该参数存储模块用于存储摄像机的各项参数信息。其中,该参数存储模块中存储有用于查询聚焦电机位置的表格,摄像机根据计算得到的预测物距和摄像机当前的焦距,向参数存储模块发送查询请求,该查询请求用于根据预测物距和焦距查询对应的聚焦电机位置,参数存储模块基于该查询请求,将对应的聚焦电机位置发送给聚焦模块。The focal length of the camera is a real-time camera parameter that can be obtained directly. In some embodiments, the camera further includes a parameter storage module for storing various parameter information of the camera. Among them, the parameter storage module stores a table for querying the position of the focusing motor, and the camera sends a query request to the parameter storage module according to the calculated predicted object distance and the current focal length of the camera, and the query request is used to predict the object distance and focal length according to The corresponding focusing motor position is queried, and the parameter storage module sends the corresponding focusing motor position to the focusing module based on the query request.
通过上述步骤312,摄像机通过对摄像机与目标对象之间的物距进行预测,给出一个估算的物距,以便获取到一个聚焦电机的初始位置,且聚焦电机处于该初始位置上时,目标对象能够实现一定程度上的清晰成像。Through the above step 312, the camera gives an estimated object distance by predicting the object distance between the camera and the target object, so as to obtain an initial position of the focus motor, and when the focus motor is at the initial position, the target object A certain degree of clear imaging can be achieved.
需要说明的是,以情况一为例时,经过上述步骤301至步骤303,摄像机响应于摄像机 首次检测到目标对象,会根据目标对象所位于的目标区域计算得到目标对象的预测物距,基于此,通过预测得到聚焦电机的当前位置,并确定至少一个参考位置,最终获取到至少两个FV,并通过拟合得到目标位置。通过上述方法,当摄像机控制聚焦电机移动至该目标位置时,聚焦镜头的光线焦点能够落在该摄像机的感光平面上,此时摄像机对所拍摄区域进行图像采集所得到的目标图像中,目标对象能够实现清晰成像。It should be noted that, in case 1 as an example, after the above steps 301 to 303, the camera responds to the camera detecting the target object for the first time, and calculates the predicted object distance of the target object according to the target area where the target object is located. Based on this , obtain the current position of the focusing motor through prediction, and determine at least one reference position, finally obtain at least two FVs, and obtain the target position through fitting. Through the above method, when the camera controls the focusing motor to move to the target position, the light focus of the focusing lens can fall on the photosensitive plane of the camera. Clear imaging can be achieved.
以情况二为例,上述步骤312替换为:摄像机响应于该摄像机非首次检测到该目标对象,获取该摄像机中的聚焦电机当前所处的位置,将该当前所处的位置作为当前位置。Taking case 2 as an example, the above step 312 is replaced with: the camera, in response to the camera detecting the target object for the first time, obtains the current position of the focus motor in the camera, and uses the current position as the current position.
在本申请实施例中,本步骤312具体由摄像机中的聚焦模块来执行,其中,当聚焦模块在处于聚焦状态下,摄像机获取到目标区域信息,则确定摄像机非首次检测到该目标对象。可选地,该聚焦模块每一帧都会检测是否接收到目标区域信息,若聚焦模块在处于聚焦状态时继续获取到目标区域信息,则确定摄像机非首次检测到该目标对象。In the embodiment of the present application, this step 312 is specifically performed by the focusing module in the camera, wherein when the focusing module is in the focusing state and the camera obtains the target area information, it is determined that the camera has not detected the target object for the first time. Optionally, the focusing module detects whether the target area information is received every frame, and if the focusing module continues to obtain the target area information when it is in the focused state, it is determined that the camera has not detected the target object for the first time.
可选地,下面以摄像机第二次获取到目标区域信息为例进行说明:Optionally, the following takes the second acquisition of the target area information by the camera as an example for description:
在本步骤中,摄像机响应于该摄像机非首次检测到该目标对象,获取聚焦电机当前所处的位置,也即是以情况一为例时,上述步骤303中的目标位置,将该目标位置作为当前位置,然后执行上述步骤301中的步骤313和步骤314,接着执行步骤302和步骤303,最终得到目标位置。In this step, in response to the camera not detecting the target object for the first time, the camera obtains the current position of the focus motor, that is, in case 1, the target position in the above step 303 is taken as the target position. The current position, then step 313 and step 314 in the above-mentioned step 301 are executed, and then step 302 and step 303 are executed to finally obtain the target position.
在一些实施例中,本步骤312还能够替换为以下步骤312A至步骤312C:In some embodiments, this step 312 can also be replaced by the following steps 312A to 312C:
312A、摄像机控制摄像机中的聚焦电机移动至当前位置,获取到一帧图像,同时,聚焦模块获取上一次聚焦过程中,聚焦电机位于该当前位置上时摄像机所拍摄到的一帧图像。312A. The camera controls the focus motor in the camera to move to the current position, and acquires a frame of image. At the same time, the focus module acquires a frame of image captured by the camera when the focus motor was at the current position during the last focusing process.
312B、摄像机对于两帧图像中的每一图像,确定目标对象在每一图像中所位于的目标区域,获取每个目标区域所对应的FV。312B. For each image in the two frames of images, the camera determines a target area where the target object is located in each image, and obtains the FV corresponding to each target area.
312C、摄像机基于获得的两个FV,获取摄像机中的聚焦电机的目标位置,控制摄像机中的聚焦电机移动至该目标位置,以使通过聚焦镜头的光线焦点落在该摄像机的感光平面上,该目标位置所对应的FV符合目标聚焦条件。312C, the camera obtains the target position of the focusing motor in the camera based on the obtained two FVs, and controls the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the photosensitive plane of the camera, the The FV corresponding to the target position meets the target focus condition.
通过上述步骤312A至步骤312C,摄像机获取到两帧图像,一帧图像是聚焦电机在本次聚焦过程中位于当前位置时的图像,另一帧是聚焦电机在上一次聚焦过程中位于当前位置时的图像,基于此,摄像机获取到两个目标区域所对应的FV,通过对比两个FV的数值大小,以获取到目标位置。例如,若摄像机获取到的本次聚焦过程中的FV小于上一次聚焦过程中的FV,则摄像机控制聚焦电机正向移动半个焦深的调整步长,以得到目标位置;若摄像机获取到的本次聚焦过程中的FV大于上一次聚焦过程中的FV,则摄像机控制聚焦电机反向移动半个焦深的调整步长,以得到目标位置。需要说明的是,上述举例仅为示意性地,在实际应用中,开发人员能够根据需求设置不同的移动方向以及调整步长以得到目标位置,本申请实施例对此不作限定。Through the above steps 312A to 312C, the camera obtains two frames of images, one frame is the image when the focus motor is at the current position during the current focusing process, and the other frame is when the focus motor is at the current position during the last focusing process. Based on this, the camera obtains the FV corresponding to the two target areas, and obtains the target position by comparing the numerical values of the two FVs. For example, if the FV obtained by the camera during the current focusing process is smaller than the FV during the previous focusing process, the camera controls the focusing motor to move forward by half the focal depth adjustment step to obtain the target position; The FV in this focusing process is greater than the FV in the previous focusing process, and the camera controls the focusing motor to reversely move half the focal depth adjustment step to obtain the target position. It should be noted that the above examples are only illustrative, and in practical applications, developers can set different moving directions and adjust the step length to obtain the target position according to requirements, which is not limited in this embodiment of the present application.
另外,需要说明的是,在本申请实施例中,只要摄像机能够检测到目标对象,就会获取到目标区域信息,摄像机则会一直进行自动聚焦,每一次聚焦都会获取到目标位置,完成聚焦后再开始一次新的聚焦,从而快速调整聚焦电机的位置,实现了当目标对象在移动过程中时,摄像机拍摄到的图像中目标对象依然能够清晰成像。而当摄像机不再检测到目标对象时,也就无法获取到目标区域信息,此时摄像机中的聚焦模块由聚焦状态切换回空闲状态,直到摄像机再次获取到目标区域信息。In addition, it should be noted that, in this embodiment of the present application, as long as the camera can detect the target object, the target area information will be obtained, the camera will always perform automatic focusing, and the target position will be obtained each time the focusing is completed. A new focus is started again, so as to quickly adjust the position of the focus motor, so that when the target object is moving, the target object in the image captured by the camera can still be clearly imaged. When the camera no longer detects the target object, the target area information cannot be obtained. At this time, the focusing module in the camera switches from the focused state to the idle state until the camera obtains the target area information again.
在本申请实施例提供的自动聚焦方法中,当摄像机的拍摄区域中存在目标对象时,触发自动聚焦,此时摄像机获取包括目标对象的至少两帧图像,并分别确定目标对象在每一帧图像中所位于的目标区域,然后仅计算每一帧图像中目标区域的FV,得到以使目标对象清晰成像的目标位置,基于此,控制聚焦电机移动以实现聚焦。也就是说,该自动聚焦方法是以目标对象所在的目标区域的清晰度为基础,直接获取聚焦电机的目标位置,然后控制聚焦电机移动到该目标位置上,这样能够避免多物距的影响,使得摄像机时刻以目标对象的清晰成像为目标进行自动聚焦,实现目标对象的清晰成像,而且,这种方法能够大大缩短聚焦时间,提高聚焦效率。进一步地,只要摄像机还能够继续检测到目标对象,摄像机就会在上一次聚焦的基础上再次进行聚焦,以不断刷新聚焦电机的电机位置,实现对移动的目标对象的实时跟踪,从而保证动态场景中目标对象的清晰成像。In the automatic focusing method provided by the embodiment of the present application, when there is a target object in the shooting area of the camera, the automatic focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines that the target object is in each frame of the image. Then, only the FV of the target area in each frame of image is calculated to obtain the target position for clear imaging of the target object. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances. The camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the camera can continue to detect the target object, the camera will focus again on the basis of the previous focus, so as to continuously refresh the motor position of the focusing motor, and realize real-time tracking of the moving target object, thus ensuring dynamic scenes. clear imaging of the target object.
图5是本申请实施例提供的另一种自动聚焦方法的流程图。下面结合图5对本申请实施例提供的自动聚焦方法进行示意性地说明。如图5所示,该自动聚焦方法包括以下步骤501至步骤505。FIG. 5 is a flowchart of another automatic focusing method provided by an embodiment of the present application. The automatic focusing method provided by the embodiment of the present application will be schematically described below with reference to FIG. 5 . As shown in FIG. 5 , the automatic focusing method includes the following steps 501 to 505 .
501、摄像机一秒获取25帧图像,将每一帧图像都发送到摄像机平台中,其中,摄像机平台也即是摄像机中的CPU。在智能检测模式处于开启状态时,摄像机平台中的检测模块每间隔3帧在图像中检测目标对象。其中,检测模块会将图像作为输入导入一个已经训练好的检测模型中,最后会输出检测模型对于整幅图像中目标对象的检测结果,如果检测到目标对象,输出结果中会有检测到的目标区域信息,同时将检测到的目标区域信息传递给摄像机平台中的聚焦模块。501. The camera acquires 25 frames of images per second, and sends each frame of image to the camera platform, where the camera platform is also the CPU in the camera. When the intelligent detection mode is turned on, the detection module in the camera platform detects the target object in the image every 3 frames. Among them, the detection module will import the image as input into a trained detection model, and finally output the detection result of the detection model for the target object in the whole image. If the target object is detected, the detected target will be in the output result. area information, and transmit the detected target area information to the focusing module in the camera platform.
502、摄像机平台中的聚焦模块,每一帧都会检测有没有接收到检测模块的目标区域信息。如果聚焦模块处于空闲状态的时候接收到了检测模块的目标区域信息,则会触发自动聚焦;聚焦模块完成一次循环后,会继续检测是否还能接收到智能算法的先验信息,如果还能接收到,则继续循环,如果不能接收到,则退出循环,进入空闲状态。502. The focusing module in the camera platform detects whether the target area information of the detection module is received in each frame. If the focusing module receives the target area information of the detection module when it is in an idle state, it will trigger automatic focusing; after the focusing module completes one cycle, it will continue to detect whether it can still receive the prior information of the intelligent algorithm. , then continue the loop, if it cannot receive, then exit the loop and enter the idle state.
503、如果聚焦模块在处于空闲状态的时候接收到了目标区域信息,也就是首次检测到目标对象,首先会根据上述公式(7)来估算得到预测物距,然后,根据预测物距和当前的焦距查表获取对应的电机位置,将该电机位置作为当前位置。503. If the focusing module receives the target area information when it is in an idle state, that is, the target object is detected for the first time, the predicted object distance will be estimated first according to the above formula (7), and then, according to the predicted object distance and the current focal length. Look up the table to obtain the corresponding motor position, and use the motor position as the current position.
504、聚焦模块在该当前位置左右两侧,各获取一个参考位置。然后聚焦模块控制聚焦电机依次移动到这三个位置,同时获取与这三个位置对应的目标区域的FV,再依据上述公式(2)所示的关联关系,拟合得到最清晰点的目标位置,聚焦模块控制聚焦电机移动到该目标位置,完成一次聚焦循环。504. The focusing module obtains a reference position on the left and right sides of the current position, respectively. Then the focusing module controls the focusing motor to move to the three positions in turn, and obtains the FV of the target area corresponding to the three positions at the same time, and then fits the target position of the clearest point according to the correlation shown in the above formula (2). , the focusing module controls the focusing motor to move to the target position to complete a focusing cycle.
505、如果聚焦模块在一次循环后依然接收到目标区域信息,也就是说非首次检测到目标对象,则聚焦模块会获取上一次聚焦模块聚焦后决策的位置,将该位置再次作为新的当前位置,重复执行上述步骤504,获取目标区域的FV,拟合得到最清晰点的目标位置,再次控制聚焦电机移动到该目标位置,完成再一次聚焦循环。505. If the focusing module still receives the target area information after one cycle, that is to say, the target object is not detected for the first time, the focusing module will obtain the position decided by the focusing module after focusing last time, and use the position as the new current position again. , and repeat step 504 to obtain the FV of the target area, obtain the target position of the clearest point by fitting, and control the focusing motor to move to the target position again to complete the focusing cycle again.
在本申请实施例提供的自动聚焦方法中,当摄像机的拍摄区域中存在目标对象时,触发自动聚焦,此时摄像机获取包括目标对象的至少两帧图像,并分别确定目标对象在每一帧图像中所位于的目标区域,然后仅计算每一帧图像中目标区域的FV,得到以使目标对象清晰成像的目标位置,基于此,控制聚焦电机移动以实现聚焦。也就是说,该自动聚焦方法是以目标对象所在的目标区域的清晰度为基础,直接获取聚焦电机的目标位置,然后控 制聚焦电机移动到该目标位置上,这样能够避免多物距的影响,使得摄像机时刻以目标对象的清晰成像为目标进行自动聚焦,实现目标对象的清晰成像,而且,这种方法能够大大缩短聚焦时间,提高聚焦效率。进一步地,只要摄像机还能够继续检测到目标对象,摄像机就会在上一次聚焦的基础上再次进行聚焦,以不断刷新聚焦电机的电机位置,实现对移动的目标对象的实时跟踪,从而保证动态场景中目标对象的清晰成像。In the automatic focusing method provided by the embodiment of the present application, when there is a target object in the shooting area of the camera, the automatic focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines that the target object is in each frame of the image. Then, only the FV of the target area in each frame of image is calculated to obtain the target position for clear imaging of the target object. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing method is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances. The camera always takes the clear imaging of the target object as the goal to automatically focus, so as to realize the clear imaging of the target object, and this method can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the camera can continue to detect the target object, the camera will focus again on the basis of the previous focus, so as to continuously refresh the motor position of the focusing motor, and realize real-time tracking of the moving target object, thus ensuring dynamic scenes. clear imaging of the target object.
图6是本申请实施例提供的一种自动聚焦装置的结构示意图,该自动聚焦装置用于执行上述自动聚焦方法执行时的步骤,参见图6,该自动聚焦装置600包括:图像获取模块601、FV获取模块602以及控制模块603。FIG. 6 is a schematic structural diagram of an auto-focusing apparatus provided by an embodiment of the present application. The auto-focusing apparatus is used to execute the steps of the above-mentioned auto-focusing method. Referring to FIG. 6 , the auto-focusing apparatus 600 includes: an image acquisition module 601, FV acquisition module 602 and control module 603 .
图像获取模块601,用于获取包括目标对象的至少两帧图像,该至少两帧图像由该摄像机对所拍摄区域进行图像采集得到;An image acquisition module 601, configured to acquire at least two frames of images including the target object, the at least two frames of images are obtained by the camera on the captured area;
FV获取模块602,用于对于该至少两帧图像中的每一图像,确定该目标对象在该每一图像中所位于的目标区域,获取每个该目标区域所对应的FV;The FV acquisition module 602 is configured to, for each of the at least two frames of images, determine the target area where the target object is located in each of the images, and acquire the FV corresponding to each of the target areas;
控制模块603,用于基于获得的至少两个FV,获取该摄像机中的聚焦电机的目标位置,控制该摄像机中的聚焦电机移动至该目标位置,以使通过聚焦镜头的光线焦点落在该摄像机的感光平面上,该目标位置所对应的FV符合目标聚焦条件。The control module 603 is configured to obtain the target position of the focusing motor in the camera based on the obtained at least two FVs, and control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the camera On the photosensitive plane of , the FV corresponding to the target position meets the target focusing conditions.
在一种可选地实现方式中,该图像获取模块601包括:In an optional implementation manner, the image acquisition module 601 includes:
第一获取单元,用于获取该摄像机中的聚焦电机的当前位置,基于该当前位置,获取至少一个参考位置,该至少一个参考位置与该当前位置之间的距离为调整步长;a first obtaining unit, configured to obtain the current position of the focusing motor in the camera, and based on the current position, obtain at least one reference position, and the distance between the at least one reference position and the current position is the adjustment step;
第二获取单元,用于控制该摄像机中的聚焦电机分别移动至该初始位置和该至少一个参考位置上,在该摄像机中的聚焦电机位于该当前位置以及该至少一个参考位置上时,该摄像机获取该至少两帧图像。a second acquisition unit, configured to control the focus motor in the camera to move to the initial position and the at least one reference position respectively, when the focus motor in the camera is located at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
在一种可选地实现方式中,该第一获取单元,用于响应于该摄像机首次检测到该目标对象,通过预测获取该当前位置;响应于该摄像机非首次检测到该目标对象,获取该摄像机中的聚焦电机当前所处的位置,将该当前所处的位置作为该当前位置。In an optional implementation manner, the first acquisition unit is configured to acquire the current position by prediction in response to the camera detecting the target object for the first time; acquire the current position in response to the camera detecting the target object for the first time The current position of the focus motor in the camera is taken as the current position.
在一种可选地实现方式中,该第一获取单元,用于获取该摄像机与该目标对象之间的预测物距;基于该预测物距和该摄像机的焦距,获取该当前位置。In an optional implementation manner, the first obtaining unit is configured to obtain the predicted object distance between the camera and the target object; and obtain the current position based on the predicted object distance and the focal length of the camera.
在一种可选地实现方式中,该调整步长为半个焦深。In an optional implementation manner, the adjustment step is half the focal depth.
在一种可选地实现方式中,该第一获取单元用于基于该当前位置,在该当前位置两侧,各获取一个该参考位置。In an optional implementation manner, the first obtaining unit is configured to obtain the reference position on both sides of the current position based on the current position.
在一种可选地实现方式中,该控制模块603,用于获取每个FV与该摄像机中的聚焦电机的位置之间的关联关系;基于每个FV、该当前位置以及该至少一个参考位置,通过该关联关系,获取该摄像机中的聚焦电机的目标位置。In an optional implementation manner, the control module 603 is configured to acquire the association relationship between each FV and the position of the focus motor in the camera; based on each FV, the current position and the at least one reference position , and through the relationship, the target position of the focus motor in the camera is obtained.
在一种可选地实现方式中,该FV获取模块602,用于将该每一图像输入到检测模型中,该检测模型用于根据输入的该每一图像,输出该每一图像的检测结果,该检测结果中包括该目标对象在该每一图像中的目标区域信息;基于该检测结果确定该目标对象在该每一图像中所位于的目标区域。In an optional implementation manner, the FV acquisition module 602 is configured to input each image into a detection model, and the detection model is configured to output the detection result of each image according to the inputted each image , the detection result includes the target area information of the target object in each image; the target area where the target object is located in each image is determined based on the detection result.
在该自动聚焦装置中,当摄像机的拍摄区域中存在目标对象时,触发自动聚焦,此时摄像机获取包括目标对象的至少两帧图像,并分别确定目标对象在每一帧图像中所位于的目标区域,然后仅计算每一帧图像中目标区域的FV,得到以使目标对象清晰成像的目标位 置,基于此,控制聚焦电机移动以实现聚焦。也就是说,该自动聚焦装置是以目标对象所在的目标区域的清晰度为基础,直接获取聚焦电机的目标位置,然后控制聚焦电机移动到该目标位置上,这样能够避免多物距的影响,使得摄像机时刻以目标对象的清晰成像为目标进行自动聚焦,实现目标对象的清晰成像,而且,这样能够大大缩短聚焦时间,提高聚焦效率。进一步地,只要还能够继续检测到目标对象,自动聚焦装置就会在上一次聚焦的基础上再次进行聚焦,以不断刷新聚焦电机的电机位置,实现对移动的目标对象的实时跟踪,从而保证动态场景中目标对象的清晰成像。In the auto-focusing device, when there is a target object in the shooting area of the camera, auto-focusing is triggered. At this time, the camera acquires at least two frames of images including the target object, and respectively determines the target where the target object is located in each frame of image. Then only the FV of the target area in each frame of image is calculated to obtain the target position to make the target object clearly imaged. Based on this, the focus motor is controlled to move to achieve focusing. That is to say, the automatic focusing device is based on the clarity of the target area where the target object is located, directly obtains the target position of the focusing motor, and then controls the focusing motor to move to the target position, which can avoid the influence of multiple object distances. The camera is made to automatically focus on the clear imaging of the target object at all times, so as to realize the clear imaging of the target object, which can greatly shorten the focusing time and improve the focusing efficiency. Further, as long as the target object can continue to be detected, the automatic focusing device will focus again on the basis of the previous focusing, so as to continuously refresh the motor position of the focusing motor, and realize the real-time tracking of the moving target object, so as to ensure dynamic Clear imaging of target objects in the scene.
图7是本申请实施例提供的一种自动聚焦设备的结构示意图,该自动聚焦设备700可因配置或性能不同而产生差异,包括一个或一个以上的处理器701和一个或一个以上的存储器702,其中,该存储器702中存储有至少一条程序代码,该至少一条程序代码由该处理器701加载并执行以实现上述方法实施例中的步骤。当然,该自动聚焦设备700还能够具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该自动聚焦设备700还包括其他用于实现设备功能的部件,在此不做赘述。FIG. 7 is a schematic structural diagram of an auto-focusing device provided by an embodiment of the present application. The auto-focusing device 700 may vary due to different configurations or performances, and includes one or more processors 701 and one or more memories 702 , wherein at least one piece of program code is stored in the memory 702, and the at least one piece of program code is loaded and executed by the processor 701 to implement the steps in the above method embodiments. Of course, the auto-focusing device 700 can also have components such as a wired or wireless network interface, a keyboard, and an input-output interface for input and output. The auto-focusing device 700 also includes other components for realizing device functions, which will not be repeated here. .
在示例性实施例中,还提供了一种计算机可读存储介质,例如包括程序代码的存储器,上述程序代码可由终端中的处理器执行,以使计算机完成上述实施例中的自动聚焦方法。例如,该计算机可读存储介质是只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、只读光盘(compact disc read-only memory,CD-ROM)、磁带、软盘和光数据存储设备等。In an exemplary embodiment, a computer-readable storage medium, such as a memory including program codes, is also provided, and the program codes can be executed by a processor in the terminal, so that the computer can perform the auto-focusing method in the above-mentioned embodiments. For example, the computer-readable storage medium is read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), magnetic tape , floppy disks and optical data storage devices.
在示例性实施例中,还提供了一种自动聚焦摄像机,例如包括图像传感器和处理器,其中,该图像传感器用于获取上述实施例中的至少两帧图像,该处理器用于执行上述实施例中的自动聚焦方法。In an exemplary embodiment, an auto-focusing camera is also provided, for example comprising an image sensor and a processor, wherein the image sensor is used to acquire at least two frames of images in the above-mentioned embodiments, and the processor is used to execute the above-mentioned embodiments Autofocus method in .
本申请中术语“第一”“第二”等字样用于对作用和功能基本相同的相同项或相似项进行区分,应理解,“第一”、“第二”、“第n”之间不具有逻辑或时序上的依赖关系,也不对数量和执行顺序进行限定。还应理解,尽管以下描述使用术语第一、第二等来描述各种元素,但这些元素不应受术语的限制。这些术语只是用于将一元素与另一元素区别分开。例如,在不脱离各种所述示例的范围的情况下,第一图像可以被称为第二图像,并且类似地,第二图像可以被称为第一图像。第一图像和第二图像都可以是图像,并且在某些情况下,可以是单独且不同的图像。In this application, the terms "first", "second" and other words are used to distinguish the same or similar items with basically the same function and function, and it should be understood that between "first", "second" and "nth" There are no logical or timing dependencies, and no restrictions on the number and execution order. It will also be understood that, although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, a first image may be referred to as a second image, and, similarly, a second image may be referred to as a first image, without departing from the scope of various described examples. Both the first image and the second image may be images, and in some cases, may be separate and distinct images.
本申请中术语“至少一个”的含义是指一个或多个,本申请中术语“多个”的含义是指两个或两个以上,例如,多个第二图像是指两个或两个以上的第二图像。本文中术语“系统”和“网络”经常可互换使用。The term "at least one" in this application means one or more, and the term "plurality" in this application means two or more, for example, a plurality of second images means two or more Second image above. The terms "system" and "network" are often used interchangeably herein.
还应理解,术语“如果”可被解释为意指“当...时”(“when”或“upon”)或“响应于确定”或“响应于检测到”。类似地,根据上下文,短语“如果确定...”或“如果检测到[所陈述的条件或事件]”可被解释为意指“在确定...时”或“响应于确定...”或“在检测到[所陈述的条件或事件]时”或“响应于检测到[所陈述的条件或事件]”。It should also be understood that the term "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, depending on the context, the phrases "if it is determined..." or "if a [statement or event] is detected" can be interpreted to mean "when determining..." or "in response to determining... ” or “on detection of [recited condition or event]” or “in response to detection of [recited condition or event]”.
以上描述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above descriptions are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications within the technical scope disclosed in the present application. or replacement, these modifications or replacements should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机程序指令。在计算机上加载和执行该计算机程序指令时,全部或部分地产生按照本申请实施例中的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer program instructions. When the computer program instructions are loaded and executed on a computer, the procedures or functions according to the embodiments of the present application are generated in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,该计算机程序指令可以从一个网站站点、计算机、服务器或数据中心通过有线或无线方式向另一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质(例如软盘、硬盘、磁带)、光介质(例如,数字视频光盘(digital video disc,DVD)、或者半导体介质(例如固态硬盘)等。The computer instructions may be stored in or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer program instructions may be transmitted from a website site, computer, server or data center via Wired or wireless transmission to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media integrated. The available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, digital video discs (DVDs), or semiconductor media (eg, solid state drives), and the like.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,该程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium can be read-only memory, magnetic disk or optical disk, etc.
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand: The technical solutions described in the embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims (17)

  1. 一种自动聚焦方法,其特征在于,应用于摄像机,所述方法包括:An automatic focusing method, characterized in that, applied to a camera, the method comprising:
    获取包括目标对象的至少两帧图像,所述至少两帧图像由所述摄像机对所拍摄区域进行图像采集得到;Acquiring at least two frames of images including the target object, the at least two frames of images are obtained by image capturing of the captured area by the camera;
    对于所述至少两帧图像中的每一图像,确定所述目标对象在所述每一图像中所位于的目标区域,获取每个所述目标区域所对应的聚焦值FV;for each of the at least two frames of images, determining a target area where the target object is located in each of the images, and obtaining a focus value FV corresponding to each of the target areas;
    基于获得的至少两个FV,获取所述摄像机中的聚焦电机的目标位置,控制所述摄像机中的聚焦电机移动至所述目标位置,以使通过聚焦镜头的光线焦点落在所述摄像机的感光平面上,所述目标位置所对应的FV符合目标聚焦条件。Based on the obtained at least two FVs, the target position of the focusing motor in the camera is acquired, and the focusing motor in the camera is controlled to move to the target position, so that the focus of the light passing through the focusing lens falls on the light-sensing of the camera On the plane, the FV corresponding to the target position meets the target focusing condition.
  2. 根据权利要求1所述的方法,其特征在于,所述获取包括目标对象的至少两帧图像,包括:The method according to claim 1, wherein the acquiring at least two frames of images including the target object comprises:
    获取所述摄像机中的聚焦电机的当前位置,基于所述当前位置,获取至少一个参考位置,所述至少一个参考位置与所述当前位置之间的距离为调整步长;Acquire the current position of the focus motor in the camera, obtain at least one reference position based on the current position, and the distance between the at least one reference position and the current position is the adjustment step;
    控制所述摄像机中的聚焦电机分别移动至所述初始位置和所述至少一个参考位置上,在所述摄像机中的聚焦电机位于所述当前位置以及所述至少一个参考位置上时,所述摄像机获取所述至少两帧图像。controlling the focus motor in the camera to move to the initial position and the at least one reference position, respectively, when the focus motor in the camera is at the current position and the at least one reference position, the camera The at least two frames of images are acquired.
  3. 根据权利要求2所述的方法,其特征在于,所述获取所述摄像机中的聚焦电机的当前位置,包括下述一种:The method according to claim 2, wherein the acquiring the current position of the focus motor in the camera comprises one of the following:
    响应于所述摄像机首次检测到所述目标对象,通过预测获取所述当前位置;obtaining the current position by prediction in response to the camera detecting the target object for the first time;
    响应于所述摄像机非首次检测到所述目标对象,获取所述摄像机中的聚焦电机当前所处的位置,将所述当前所处的位置作为所述当前位置。In response to the camera not detecting the target object for the first time, the current position of the focus motor in the camera is acquired, and the current position is used as the current position.
  4. 根据权利要求3所述的方法,其特征在于,所述通过预测获取所述当前位置,包括:The method according to claim 3, wherein the obtaining the current position by prediction comprises:
    获取所述摄像机与所述目标对象之间的预测物距;obtaining the predicted object distance between the camera and the target object;
    基于所述预测物距和所述摄像机的焦距,获取所述当前位置。The current position is acquired based on the predicted object distance and the focal length of the camera.
  5. 根据权利要求2-4任一所述的方法,其特征在于,所述调整步长为半个焦深。The method according to any one of claims 2-4, wherein the adjustment step is half a focal depth.
  6. 根据权利要求2-5任一所述的方法,其特征在于,所述基于所述当前位置,获取至少一个参考位置,包括:The method according to any one of claims 2-5, wherein the acquiring at least one reference position based on the current position comprises:
    基于所述当前位置,在所述当前位置两侧,各获取一个所述参考位置。Based on the current position, one of the reference positions is acquired on both sides of the current position.
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述基于获得的至少两个FV,获取所述摄像机中的聚焦电机的目标位置,包括:The method according to any one of claims 1-6, wherein the obtaining the target position of the focus motor in the camera based on the obtained at least two FVs comprises:
    获取每个FV与所述摄像机中的聚焦电机的位置之间的关联关系;obtaining the relationship between each FV and the position of the focus motor in the camera;
    基于每个FV、所述当前位置以及所述至少一个参考位置,通过所述关联关系,获 取所述摄像机中的聚焦电机的目标位置。Based on each FV, the current position, and the at least one reference position, the target position of the focus motor in the camera is acquired through the association relationship.
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述确定所述目标对象在所述每一图像中所位于的目标区域,包括:The method according to any one of claims 1-7, wherein the determining a target area where the target object is located in each image comprises:
    将所述每一图像输入到检测模型中,所述检测模型用于根据输入的所述每一图像,输出所述每一图像的检测结果,所述检测结果中包括所述目标对象在所述每一图像中的目标区域信息;The each image is input into the detection model, and the detection model is used for outputting the detection result of each image according to the inputted each image, and the detection result includes the target object in the target area information in each image;
    基于所述检测结果确定所述目标对象在所述每一图像中所位于的目标区域。A target area where the target object is located in each of the images is determined based on the detection result.
  9. 一种自动聚焦装置,其特征在于,所述装置包括:An automatic focusing device, characterized in that the device comprises:
    图像获取模块,用于获取包括目标对象的至少两帧图像,所述至少两帧图像由所述摄像机对所拍摄区域进行图像采集得到;an image acquisition module, configured to acquire at least two frames of images including the target object, the at least two frames of images are acquired by the camera on the captured area;
    FV获取模块,用于对于所述至少两帧图像中的每一图像,确定所述目标对象在所述每一图像中所位于的目标区域,获取每个所述目标区域所对应的聚焦值FV;The FV acquisition module is configured to, for each of the at least two frames of images, determine a target area where the target object is located in each of the images, and acquire a focus value FV corresponding to each of the target areas ;
    控制模块,用于基于获得的至少两个FV,获取所述摄像机中的聚焦电机的目标位置,控制所述摄像机中的聚焦电机移动至所述目标位置,以使通过聚焦镜头的光线焦点落在所述摄像机的感光平面上,所述目标位置所对应的FV符合目标聚焦条件。The control module is configured to obtain the target position of the focusing motor in the camera based on the obtained at least two FVs, and control the focusing motor in the camera to move to the target position, so that the focus of the light passing through the focusing lens falls on the target position On the photosensitive plane of the camera, the FV corresponding to the target position meets the target focusing condition.
  10. 根据权利要求9所述的装置,其特征在于,所述图像获取模块,包括:The device according to claim 9, wherein the image acquisition module comprises:
    第一获取单元,用于获取所述摄像机中的聚焦电机的当前位置,基于所述当前位置,获取至少一个参考位置,所述至少一个参考位置与所述当前位置之间的距离为调整步长;a first obtaining unit, configured to obtain the current position of the focus motor in the camera, and based on the current position, obtain at least one reference position, and the distance between the at least one reference position and the current position is the adjustment step size ;
    第二获取单元,用于控制所述摄像机中的聚焦电机分别移动至所述初始位置和所述至少一个参考位置上,在所述摄像机中的聚焦电机位于所述当前位置以及所述至少一个参考位置上时,所述摄像机获取所述至少两帧图像。a second acquiring unit, configured to control the focus motor in the camera to move to the initial position and the at least one reference position, respectively, and the focus motor in the camera is located at the current position and the at least one reference position When in position, the camera acquires the at least two frames of images.
  11. 根据权利要求10所述的装置,其特征在于,所述第一获取单元,用于响应于所述摄像机首次检测到所述目标对象,通过预测获取所述当前位置;响应于所述摄像机非首次检测到所述目标对象,获取所述摄像机中的聚焦电机当前所处的位置,将所述当前所处的位置作为所述当前位置。The device according to claim 10, wherein the first acquiring unit is configured to acquire the current position by prediction in response to the camera detecting the target object for the first time; in response to the camera not detecting the target object for the first time; The target object is detected, the current position of the focus motor in the camera is acquired, and the current position is used as the current position.
  12. 根据权利要求11所述的装置,其特征在于,所述第一获取单元,用于获取所述摄像机与所述目标对象之间的预测物距;基于所述预测物距和所述摄像机的焦距,获取所述当前位置。The device according to claim 11, wherein the first obtaining unit is configured to obtain a predicted object distance between the camera and the target object; based on the predicted object distance and the focal length of the camera , to obtain the current position.
  13. 根据权利要求10-12任一项所述的装置,其特征在于,所述调整步长为半个焦深。The device according to any one of claims 10-12, wherein the adjustment step is half a focal depth.
  14. 根据权利要求10-13任一项所述的装置,其特征在于,所述第一获取单元用于 基于所述当前位置,在所述当前位置两侧,各获取一个所述参考位置。The apparatus according to any one of claims 10-13, wherein the first obtaining unit is configured to obtain one of the reference positions on both sides of the current position based on the current position.
  15. 根据权利要求9-14任一项所述的装置,其特征在于,所述控制模块用于获取每个FV与所述摄像机中的聚焦电机的位置之间的关联关系;基于每个FV、所述当前位置以及所述至少一个参考位置,通过所述关联关系,获取所述摄像机中的聚焦电机的目标位置。The device according to any one of claims 9-14, wherein the control module is configured to obtain the association relationship between each FV and the position of the focus motor in the camera; The current position and the at least one reference position are obtained, and the target position of the focus motor in the camera is acquired through the association relationship.
  16. 根据权利要求9-15任一项所述的装置,其特征在于,所述FV获取模块用于将所述每一图像输入到检测模型中,所述检测模型用于根据输入的所述每一图像,输出所述每一图像的检测结果,所述检测结果中包括所述目标对象在所述每一图像中的目标区域信息;基于所述检测结果确定所述目标对象在所述每一图像中所位于的目标区域。The device according to any one of claims 9-15, wherein the FV acquisition module is configured to input the each image into a detection model, and the detection model is configured to input each image according to the input image, output the detection result of each image, the detection result includes target area information of the target object in each image; determine the target object in each image based on the detection result in the target area.
  17. 一种自动聚焦摄像机,其特征在于,所述自动聚焦摄像机包括图像传感器和处理器,所述图像传感器用于采集如权利要求1至8任一项所述的至少两帧图像,所述处理器用于执行如权利要求1至8任一项所述的自动聚焦方法。An auto-focusing camera, characterized in that the auto-focusing camera comprises an image sensor and a processor, the image sensor is used to collect at least two frames of images according to any one of claims 1 to 8, and the processor uses for performing the autofocusing method as claimed in any one of claims 1 to 8 .
PCT/CN2021/113969 2020-09-30 2021-08-23 Automatic focusing method and device, and camera WO2022068466A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202011055721 2020-09-30
CN202011055721.4 2020-09-30
CN202110135129.3A CN114363504A (en) 2020-09-30 2021-01-30 Automatic focusing method and device and camera
CN202110135129.3 2021-01-30

Publications (1)

Publication Number Publication Date
WO2022068466A1 true WO2022068466A1 (en) 2022-04-07

Family

ID=80949585

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/113969 WO2022068466A1 (en) 2020-09-30 2021-08-23 Automatic focusing method and device, and camera

Country Status (1)

Country Link
WO (1) WO2022068466A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012063994A1 (en) * 2010-11-11 2012-05-18 고려대학교 산학협력단 Training-based auto-focus device and method
CN102780847A (en) * 2012-08-14 2012-11-14 北京汉邦高科数字技术股份有限公司 Camera automatic focusing control method focused on moving target
CN104459940A (en) * 2013-09-25 2015-03-25 北京环境特性研究所 Quick self-adaptation automatic focusing method
CN110278383A (en) * 2019-07-25 2019-09-24 浙江大华技术股份有限公司 Focus method, device and electronic equipment, storage medium
CN111178281A (en) * 2019-12-31 2020-05-19 杭州晨安科技股份有限公司 Automatic focusing method for face area under large-magnification shallow depth of field state

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012063994A1 (en) * 2010-11-11 2012-05-18 고려대학교 산학협력단 Training-based auto-focus device and method
CN102780847A (en) * 2012-08-14 2012-11-14 北京汉邦高科数字技术股份有限公司 Camera automatic focusing control method focused on moving target
CN104459940A (en) * 2013-09-25 2015-03-25 北京环境特性研究所 Quick self-adaptation automatic focusing method
CN110278383A (en) * 2019-07-25 2019-09-24 浙江大华技术股份有限公司 Focus method, device and electronic equipment, storage medium
CN111178281A (en) * 2019-12-31 2020-05-19 杭州晨安科技股份有限公司 Automatic focusing method for face area under large-magnification shallow depth of field state

Similar Documents

Publication Publication Date Title
CN109104561B (en) System and method for tracking moving objects in a scene
CN109922251B (en) Method, device and system for quick snapshot
WO2021052487A1 (en) Method and apparatus for obtaining extended depth of field image, and electronic device
KR101826897B1 (en) Method and camera for determining an image adjustment parameter
JP6604019B2 (en) Image processing apparatus, image processing method, and image processing system
JP6887960B2 (en) Systems and methods for autofocus triggers
US9615019B2 (en) Image capturing apparatus and control method for image capturing apparatus with particle filter for main object detection and selecting focus detection area based on priority
WO2019061079A1 (en) Focusing processing method and device
JP6184189B2 (en) SUBJECT DETECTING DEVICE AND ITS CONTROL METHOD, IMAGING DEVICE, SUBJECT DETECTING DEVICE CONTROL PROGRAM, AND STORAGE MEDIUM
US10701281B2 (en) Image processing apparatus, solid-state imaging device, and electronic apparatus
CN107111764B (en) Events triggered by the depth of an object in the field of view of an imaging device
US20140036104A1 (en) Photographing apparatus, and method for photographing moving object with the same
CN110941076B (en) Control apparatus, image pickup apparatus, control method, and storage medium
US20090034953A1 (en) Object-oriented photographing control method, medium, and apparatus
JP5271227B2 (en) Crowd monitoring device, method and program
KR102196086B1 (en) Method for autonomous balancing PTZ of camera and system for providing traffic information therewith
KR101038650B1 (en) Adaptive modeling method for background image, detecting method and system for illegal-stopping and parking vehicle using it
JP2000188713A (en) Automatic focus controller and method for determining its focusing
WO2017166076A1 (en) Method, device and apparatus for determining focus window
EP3218756B1 (en) Direction aware autofocus
JP6602081B2 (en) Imaging apparatus and control method thereof
WO2022068466A1 (en) Automatic focusing method and device, and camera
CN111491105B (en) Focusing method of mobile terminal, mobile terminal and computer storage medium
JP5127692B2 (en) Imaging apparatus and tracking method thereof
JP2002277727A (en) Method and device for generating focusing sound

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21874127

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21874127

Country of ref document: EP

Kind code of ref document: A1