CN113905173B - Focusing method, focusing apparatus, and computer-readable storage medium - Google Patents

Focusing method, focusing apparatus, and computer-readable storage medium Download PDF

Info

Publication number
CN113905173B
CN113905173B CN202111006320.4A CN202111006320A CN113905173B CN 113905173 B CN113905173 B CN 113905173B CN 202111006320 A CN202111006320 A CN 202111006320A CN 113905173 B CN113905173 B CN 113905173B
Authority
CN
China
Prior art keywords
focusing
motor
focus
determining
camera
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202111006320.4A
Other languages
Chinese (zh)
Other versions
CN113905173A (en
Inventor
陈天钧
况璐
潘润发
赵军
李准
卢二利
邵一轶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
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
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202111006320.4A priority Critical patent/CN113905173B/en
Publication of CN113905173A publication Critical patent/CN113905173A/en
Application granted granted Critical
Publication of CN113905173B publication Critical patent/CN113905173B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • H04N23/67Focus control based on electronic image sensor signals
    • 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
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/675Focus control based on electronic image sensor signals comprising setting of focusing regions

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

The application discloses a focusing method, a focusing device and a computer readable storage medium, wherein the focusing method comprises the following steps: acquiring motion information of a focusing target; determining the motion direction of the focusing target according to the motion information; determining a focusing area in the current frame image according to the movement direction of the focusing target; and driving a focusing motor in the camera to move so as to focus the focusing area. The focusing method can improve the accuracy of focusing and avoid focusing blurring.

Description

Focusing method, focusing apparatus, and computer-readable storage medium
Technical Field
The present disclosure relates to the field of focusing technologies, and in particular, to a focusing method, a focusing apparatus, and a computer-readable storage medium.
Background
The intelligent tracking service is along with the construction and the application of intelligent traffic and intelligent cities, but the intelligent tracking effect of the current camera is not satisfactory, and the main problems are that the target is easy to lose focus and fuzzy, and the tracked target is easy to lose when the target is tracked in a centralized manner.
In view of the above existing problems, a new focusing method is needed.
Disclosure of Invention
The application provides a focusing method, a focusing device and a computer readable storage medium, which can improve the accuracy of focusing and avoid focusing blurring.
A first aspect of embodiments of the present application provides a focusing method, where the focusing method includes: acquiring motion information of a focusing target; determining the motion direction of the focusing target according to the motion information; determining a focusing area in the current frame image according to the motion direction of the focusing target; and driving a focusing motor in the camera to move so as to focus the focusing area.
A second aspect of the embodiments of the present application provides a focusing apparatus, which includes a processor, a memory, and a communication circuit, where the processor is respectively coupled to the memory and the communication circuit, the memory stores program data, and the processor implements the steps of the method by executing the program data in the memory.
A third aspect of embodiments of the present application provides a computer-readable storage medium storing a computer program, which is executable by a processor to implement the steps in the above-mentioned method.
The beneficial effects are that: according to the method and the device, the focusing area is determined according to the movement direction of the focusing target in the focusing process, and then the focusing motor is driven to move so as to focus the focusing area. Because the following movement position of the focusing target can be pre-judged according to the movement direction of the focusing target, the focusing area is determined according to the movement direction of the focusing target, the focusing accuracy can be ensured, and the occurrence of blurring during focusing can be avoided.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the description below are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts. Wherein:
FIG. 1 is a schematic flow chart diagram of an embodiment of a focusing method of the present application;
FIG. 2 is a schematic view of the direction of movement of a focus target in an application scenario;
FIG. 3 is a schematic illustration of the direction of motion of a focus target in another application scenario;
FIG. 4 is a diagram of a current frame image in an application scenario;
FIG. 5 is a schematic diagram of a current frame image in another application scenario;
FIG. 6 is a schematic diagram of a current frame image in yet another application scenario;
FIG. 7 is a schematic flowchart of step S140 in an application scenario in FIG. 1;
FIG. 8 is a schematic flowchart of step S140 in FIG. 1 in another application scenario;
FIG. 9 is a schematic illustration of a standard object distance curve;
FIG. 10 is a schematic flow chart diagram of another embodiment of a focusing method of the present application;
FIG. 11 is a schematic structural diagram of an embodiment of a focusing device according to the present application;
FIG. 12 is a schematic structural diagram of another embodiment of a focusing assembly of the present application;
FIG. 13 is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic flow chart diagram of an embodiment of the focusing method of the present application, the method including:
s110: motion information of the focus target is acquired.
Specifically, when the intelligent side triggers a focusing task, the intelligent side sends the motion information of a focusing target to the focusing side, and then the focusing side performs focusing processing. The motion information sent by the intelligent side is vector information so as to determine the motion direction of the focusing target in the following.
Besides the motion information, the intelligent side can also send other information such as the position and the size of the focusing target to the focusing side.
S120: and determining the motion direction of the focusing target according to the motion information.
The camera tracks the focus target along with the movement of the focus target, that is, the movement of the focus target can be reflected by the rotation of the camera, so the movement information of the embodiment is specifically the movement information of the camera, and includes a first rotation angle and a first rotation direction of the camera in a first direction, and a second rotation angle and a second rotation direction of the camera in a second direction. Since the rotation direction of the camera is generally divided into a horizontal rotation direction and a vertical rotation direction, the present embodiment sets the first direction to be the horizontal direction and the second direction to be the vertical direction. It will be appreciated that the camera is typically rotated by the pan/tilt head, since the motion information of the camera, and in particular the motion information of the pan/tilt head, is also known.
Wherein the first rotation direction is right or left and the second rotation direction is up or down.
In the present embodiment, the moving direction of the focus target is divided into an up-down direction (also vertical direction), a left-right direction (also horizontal direction), a left-up-right-down motion, and a left-down-right-up motion.
In this embodiment, step S120 specifically includes: if the first rotation angle exceeds a first angle threshold value and the second rotation angle does not exceed a second angle threshold value, determining the movement direction of the focusing target according to the first direction; if the first rotation angle does not exceed the first angle threshold and the second rotation angle exceeds the second angle threshold, determining the motion direction of the focusing target according to the second direction; and if the first rotation angle exceeds a first angle threshold value and the second rotation angle exceeds a second angle threshold value, determining the movement direction of the focusing target according to the first rotation direction and the second rotation direction.
The first angle threshold and the second angle threshold may be equal or different. For convenience of description, the first angle threshold and the second angle threshold are equal and are both 1 °.
Specifically, if the first rotation angle of the camera in the horizontal direction exceeds 1 ° and the second rotation angle in the vertical direction does not exceed 1 °, it is determined that the movement direction of the focus target is the left-right direction (i.e., the horizontal direction); if the first rotation angle of the camera in the horizontal direction does not exceed 1 DEG and the second rotation angle in the vertical direction exceeds 1 DEG, determining the motion direction of the focusing target to be the up-down direction (namely the vertical direction); if both the first rotation angle of the camera in the horizontal direction and the second rotation angle in the vertical direction exceed 1 °, the first rotation direction and the second rotation direction are combined to determine the movement direction of the focusing target, for example, in the application scenario of fig. 2, when the first rotation direction is rightward and the second rotation direction is upward, the movement direction of the focusing target is determined to be a lower left and upper right direction, or, in the application scenario of fig. 3, when the first rotation direction is leftward and the second rotation direction is upward, the movement direction of the focusing target is determined to be an upper left and lower right direction.
In other embodiments, the moving direction of the focus target may be further set to include: determining the first rotating direction as the moving direction of the focusing target if the first rotating angle exceeds a first angle threshold value and the second rotating angle does not exceed a second angle threshold value; if the first rotation angle does not exceed the first angle threshold value and the second rotation angle exceeds the second angle threshold value, determining the second rotation direction as the movement direction of the focusing target; and if the first rotation angle exceeds a first angle threshold value and the second rotation angle exceeds a second angle threshold value, determining the movement direction of the focusing target according to the first rotation direction and the second rotation direction.
S130: and determining a focus area in the current frame image according to the motion direction of the focus target.
Specifically, since the following movement position of the focus target can be pre-determined according to the movement direction of the focus target, the focus area is determined according to the movement direction of the focus target, the accuracy of subsequent focusing can be ensured, and the focusing picture blur caused by the movement of the focus target can be avoided.
Since the zoom processing has been performed before focusing is performed, the position of the focus target in the current frame image is roughly determined, and considering that the focus target is generally located at the center position of the current frame image, the present embodiment determines a region extending in the motion direction in the current frame image, passing through the center point of the current frame image, and extending from one side to the other side of the current frame image, as a focus region.
Referring to fig. 4, when the moving direction of the focus target is the left-right direction, the focus area is area 1 in the current frame image, referring to fig. 5, when the moving direction of the focus target is the up-down direction, the focus area is area 2 in the current frame image, referring to fig. 6, when the moving direction of the focus target is the up-down and right-down directions, the focus area is area 3 in the current frame image.
Compared with the prior art that the focus area is only the area where the focus target is located, the embodiment can avoid shaking during focusing.
The focus area may be a regularly-shaped area, for example, in the application scenarios of fig. 4 and 5, both rectangular areas, and the focus area may also be an irregularly-shaped area, for example, in the application scenario of fig. 6.
In other embodiments, a region extending along the moving direction and passing through the position of the focusing target in the current frame image may be determined as the focusing region, and it is understood that, in this case, in addition to determining the moving direction of the focusing target, the position of the focusing target in the current frame image also needs to be determined.
S140: and driving a focusing motor in the camera to move so as to focus the focusing area.
After the focus area is determined, a focus motor (focus motor) can be driven to move, so that the focus area is focused.
In the present embodiment, referring to fig. 7, step S140 includes:
s141: and acquiring a definition evaluation value of the focusing area after driving the focusing motor to move.
Specifically, the definition evaluation value of the focus area represents the focusing effect of the picture after the focus motor moves, so that the definition evaluation value of the focus area is obtained after the focus motor is driven to move, and the current focusing effect is evaluated according to the definition evaluation value of the focus area.
In the focusing process, when the focusing motor is driven to move for the first time, the focusing motor may be driven to move towards a randomly determined direction, and then whether to change the moving direction of the focusing motor may be determined according to the sharpness evaluation value of the focusing area.
In an application scenario, step S141 specifically includes: distributing weights for all image blocks in the current frame image, wherein the weight of the image block where the focusing area is located is greater than the weights of other image blocks; and determining the definition evaluation value of the focusing area according to the weight of each image block.
Specifically, the current frame image is divided into a plurality of image blocks in advance, for example, in the application scenarios of fig. 4 to 6, the current frame image is divided into 15 × 17 image blocks. After the focusing area is determined, weights are configured for each image block in the current frame image, and the weight of the image block where the focusing area is located is specifically set to be larger than the weights of other image blocks.
After the weights of the image blocks are determined, the measured statistical values (specifically, values representing the image block definition) of the image blocks are multiplied by the corresponding weights, so that the definition evaluation values of the image blocks are obtained, and the definition evaluation value of the focus area is also determined.
In the application scenarios in fig. 4 to 6, the weight of the image block in which the focus area is located is set to be not 0 (e.g., 9), and the weights of the other image blocks are set to be 0, so that only the focus effect of the focus area can be focused on during the focusing process, and the influence of the other areas on the evaluation of the focus effect is avoided.
S142: and determining whether to drive the focusing motor to move again according to the definition evaluation value of the focusing area.
Specifically, after the focusing motor is driven to move, how the current focusing effect is determined according to the definition evaluation value of the focusing area, and whether to continue driving the focusing motor for focusing or to end the focusing processing process is determined according to the effect.
After the focusing motor is driven to move, the definition evaluation value of the focusing area is increased but does not reach a preset threshold value, the focusing motor is continuously determined to move towards the original position until the definition evaluation value of the focusing area meets the preset threshold value.
Meanwhile, in the present embodiment, in the process of driving the focus motor to perform the focus process, if it is detected that the current position of the focus motor reaches the limit position in the first direction when the focus motor is driven to move in the first direction, it indicates that the focus motor cannot continue to move in the first direction, and at this time, the focus motor is driven to move in a second direction opposite to the first direction, or after the focus motor is driven to move in the first direction, it is detected that the sharpness evaluation value of the focus area decreases, that is, after the focus is performed, the focus effect becomes worse instead, and it indicates that an error occurs in the movement direction of the focus motor, and the focus motor is driven to move in the second direction opposite to the first direction.
Meanwhile, the embodiment further sets an ending condition of the focusing process, specifically, in the process of driving the focusing motor to move, if at least one of the conditions that the sharpness evaluation value of the focusing area rises first and then falls, the moving direction of the focusing motor changes twice, and the number of times of movement of the focusing motor reaches a threshold number is detected, the driving of the focusing motor is stopped, so as to end the focusing process.
Specifically, when the sharpness evaluation value of the focus area first rises and then falls, it indicates that the focus motor has changed direction after moving in the first direction to reach the extreme position, but when the focus motor moves in the second direction opposite to the first direction after changing direction, the sharpness evaluation value of the focus area falls, and at this time, it indicates that the focus motor cannot continue moving in both the first direction and the second direction, and then the process of focusing is ended.
Or, when the moving direction of the focus motor is changed twice, it indicates that the focus motor cannot move in two opposite directions to achieve the ideal focusing effect of the focus area, and then the process of the focusing process is ended.
Or, when the number of times of movement of the focus motor reaches the threshold value, it indicates that the focus effect of the focus area cannot reach the ideal effect even if the focus motor moves many times, and then the process of focus processing is ended.
In this embodiment, referring to fig. 8, the step of driving the focus motor to move in step S140 includes:
s143: a current first position of a focus motor and a current second position of a zoom motor in the camera are obtained.
It is understood that the position of the zoom motor (zoom motor) is not changed while the focusing process is performed, and only the position of the focus motor is changed again.
When performing the focusing process, first, the current positions of the focus motor and the zoom motor are respectively obtained and recorded as a first position and a second position.
S144: and determining the current object distance of the camera according to the first position and the second position.
According to the parameters of the camera, after the positions of the zoom motor and the focus motor are determined, the current object distance of the camera can be determined.
S145: and determining the minimum standard object distance which is larger than the current object distance and the maximum standard object distance which is smaller than the current object distance.
Specifically, referring to fig. 9 (the abscissa represents the position of the zoom motor, and the ordinate represents the position of the focus motor), the standard object distance curve, also called zoom following curve, is a curve with a certain radian, and a lens manufacturer will provide the curve at different standard object distances (usually 8, and the corresponding standard object distances are INF, 10M, 5M, 3M, 2M, 1M, 50CM, and 10CM, respectively) when shipping, where the standard object distance corresponding to the curve 1 in fig. 9 is INF, the standard object distance corresponding to the curve 2 is 10M, the standard object distance corresponding to the curve 3 is 5M, and the standard object distance corresponding to the curve 4 is 3M), and the physical meaning of the curve is that, when the zoom motor and the focus motor travel along the corresponding curves at the standard object distances, the acquired images are both clear images.
That is, for a camera, its standard object distance and the corresponding standard object distance curve are known and determined by the manufacturer. For convenience of description, the standard object distances corresponding to the cameras include INF, 10M, 5M, 3M, 2M, 1M, 50CM, and 10CM, and the corresponding standard object distance curves are shown in fig. 9.
Thus, after the current object distance of the camera is obtained, the minimum standard object distance larger than the current object distance and the maximum standard object distance smaller than the current object distance can be determined in the standard object distances provided by the manufacturers. For example, assuming that the current object distance of the camera is 4M in step S144, step S145 determines that the maximum standard object distance less than 4M is 3M and the minimum standard object distance greater than 4M is 5M.
S146: and respectively determining a first standard position and a second standard position of the focusing motor under the second position on a first standard object distance curve corresponding to the minimum standard object distance and a second standard object distance curve corresponding to the maximum standard object distance.
Specifically, after the maximum standard object distance and the minimum standard object distance are determined, a first standard object distance curve and a second standard object distance curve can be determined, and then in the first standard object distance curve and the second standard object distance curve, a first standard position and a second standard position of the focusing motor at the second position are determined.
To better understand the step S146, as illustrated in fig. 9, assuming that the abscissa of the point 101 represents the current second position of the zoom motor and the ordinate represents the current first position of the focus motor, the first standard object distance curve and the second standard object distance curve are determined as the curve 4 and the curve 3, respectively, according to the above steps, and then the point 102 and the point 103 having the same abscissa as the abscissa of the point 101 are determined, and the ordinate of the final point 102 and the point 103 represents the first standard position and the second standard position of the focus motor, respectively, in the curve 4 and the curve 3.
S147: and determining an adjusting step length according to the first standard position and the second standard position.
In this embodiment, step S147 specifically includes: if the current object distance is larger than the critical object distance, obtaining an adjusting step length according to a first product of a distance value between the first standard position and the second standard position and the first parameter; otherwise, obtaining an adjusting step length according to a second product of the distance value between the first standard position and the second parameter, wherein the first parameter is smaller than the second parameter.
The critical object distance may be a standard object distance, such as 5M, 3M, etc., or may be a user-defined object distance, such as 4M. In the present embodiment, the critical object distance is set to be 5M.
Specifically, when the current object distance is larger than the critical object distance, calculating a first product of a distance value between the first standard position and the second standard position and a first parameter to obtain an adjustment step length; otherwise, calculating a second product of the distance value between the first standard position and the second parameter to obtain the adjusting step length.
As can be seen from fig. 9, the standard object distance curve with an object distance of 5M is used as a boundary, and the interval between two adjacent standard object distance curves with an object distance greater than 5M is smaller than the interval between two adjacent standard object distance curves with an object distance less than 5M, so in view of this relationship, the first parameter is set to be smaller than the second parameter, for example, the first parameter is set to be one twentieth, and the second parameter is set to be one tenth.
In another embodiment, the step S146 may also determine the distance difference between the first standard position and the second standard position as the adjustment step directly, which is not limited herein.
S148: and driving the focusing motor to move according to the adjusting step length.
And after the adjusting step length is determined, driving the focusing motor to move according to the adjusting step length.
As can be seen from the foregoing related matters, the focusing motor may be driven to move for multiple times during the same focusing process, and the focusing motor may be driven to move according to the same adjustment step each time.
In another embodiment of the present application, a re-trigger condition is further set, and after the focusing process on the focused region is finished, when the re-trigger condition is satisfied, the focusing process is triggered again, specifically, in conjunction with fig. 10, at this time, the focusing method includes:
s210: motion information of the focus target is acquired.
S220: and determining the motion direction of the focusing target according to the motion information.
S230: and determining a focus area in the current frame image according to the motion direction of the focus target.
S240: and driving a focusing motor in the camera to move so as to focus the focusing area.
Steps S210 to S240 are the same as steps S110 to S140, and reference may be made to the above embodiments for details, which are not described herein again.
S250: after the focusing processing is carried out on the focusing area, when the camera is detected to rotate, the angle difference between the current angle of the camera and the angle when the previous focusing processing is finished is obtained.
After the focusing process is finished, as long as the camera rotates, an angle difference value between the current angle of the camera and the angle of the camera at the end of the previous focusing process, namely the angle deviation of the current angle of the camera relative to the angle at the end of the previous focusing process is obtained.
In an application scenario, the angle difference includes a horizontal angle difference and a vertical angle difference, the horizontal angle difference represents an angle deviation of the camera in a horizontal direction when the previous focusing process is finished, and the vertical angle difference represents an angle deviation of the camera in a vertical direction when the previous focusing process is finished.
S260: a current first position of a focus motor and a current second position of a zoom motor in the camera are determined.
S270: and determining the current object distance of the camera according to the first position and the second position, and determining the size relation between the current object distance and the critical object distance.
As in the above embodiments, the current object distance of the camera may be determined after the positions of the zoom motor and the focus motor are determined according to the parameters of the camera. And the critical object distance may be a standard object distance, such as 5M, 3M, etc., or a user-defined object distance, such as 4M. In the present embodiment, the critical object distance is set to be 5M.
S280: and determining an angle threshold according to the second position and the size relation.
In an application scenario, the corresponding relationship between the second position and size relationship and the angle threshold is calibrated and stored in advance, for example, the corresponding relationship between the second position and size relationship and the angle threshold is stored by using the following table 1:
TABLE 1 correspondence of second position, magnitude relationship and angle threshold
Figure GDA0004041890240000101
Figure GDA0004041890240000111
Wherein ZooPos represents a current second position of the zoom motor, P is a horizontal angle difference threshold, T is a vertical angle difference threshold, distance is less than or equal to 5M represents that a current object Distance is less than or equal to a critical object Distance (specifically, 5M), and Distance > 5M represents that the current object Distance is greater than the critical object Distance (specifically, 5M).
Specifically, when the horizontal angle difference value is not 0 and the vertical angle difference value is 0 among the angle difference values obtained in step S250, a corresponding P change threshold is determined according to the second position and the magnitude relationship obtained in step S270, and then step S290 directly determines whether the horizontal angle difference value exceeds the P change threshold; when the horizontal angle difference value is 0 and the vertical angle difference value is not 0 among the angle difference values obtained in step S250, determining a corresponding T change threshold according to the second position and the magnitude relationship obtained in step S270, and then directly determining whether the vertical angle difference value exceeds the T change threshold in step S290; when the horizontal angle difference value and the vertical angle difference value in the angle difference values obtained in step S250 are not 0, first, a P variation threshold value and a T variation threshold value are respectively determined according to the second position and the magnitude relation obtained in step S270, and the P variation threshold value and the T variation threshold value are substituted into a matched calculation formula to determine a comprehensive angle difference value threshold value, and step S290 is to first obtain a comprehensive angle difference value according to the horizontal angle difference value and the vertical angle difference value, and then, determine whether the comprehensive angle difference value exceeds the comprehensive angle difference value threshold value.
It should be noted that, in the actual shooting process, there are many possibilities that the second position of the zoom motor is unpredictable, but only a limited number of second positions can be calibrated when setting the table, so that when the second position is a predetermined position in the preset table (i.e. the second position exists in the preset table), the table lookup can be directly performed to determine the threshold, and when the second position does not exist in the preset table, the threshold can be determined according to a linear difference method, specifically, at this time, a minimum position larger than the second position and a maximum position smaller than the second position are first determined in the table, then a first threshold corresponding to both the minimum position and the magnitude relation is searched in the table, and a second threshold corresponding to both the maximum position and the magnitude relation is searched, and finally, an angle threshold is determined according to the first threshold and the second threshold.
The process of determining the angle threshold according to the first threshold and the second threshold may specifically include: the method comprises the steps of firstly determining the distance value of the minimum position and the maximum position, then determining the first ratio of the second position to the distance value, and then calculating the product of the difference value of the first threshold value and the second threshold value and the first ratio to obtain the angle threshold value.
S290: and judging whether the angle difference value exceeds an angle threshold value.
If yes, the process returns to step S210, otherwise, the process ends.
Specifically, if the angle difference obtained in step S250 exceeds the angle threshold, it is determined that the retriggering condition is satisfied, and the focusing process is performed again, otherwise, the focusing process is not performed.
In other embodiments, the angle threshold may be determined in other manners, for example, by using a formula matching the second position and size relationship.
As can be seen from the above, after each focusing process, as long as the re-trigger condition is satisfied, the re-focusing process is triggered.
In the embodiment, after each focusing process is finished, if it is detected that a variation value of the sharpness evaluation value of the focusing area corresponding to the previous focusing process exceeds a variation threshold, the position of the focusing motor is adjusted to the position after the previous focusing process, and an alarm event is generated.
Specifically, after each focusing process, if it is found that a change value of a sharpness evaluation value of a focusing area corresponding to a previous focusing process exceeds a change threshold (i.e., a sudden change occurs), it is determined that the tracking and focusing have failed, and at this time, a focusing target is lost or switched, the position of a focusing motor is adjusted to a position after the previous focusing process, i.e., the position at which the previous tracking and focusing is finished is recovered, and an alarm event is generated and reported to prompt a user.
Referring to fig. 11, fig. 11 is a schematic structural diagram of a focusing device according to an embodiment of the present disclosure. The focusing apparatus 200 includes a processor 210, a memory 220, and a communication circuit 230, wherein the processor 210 is coupled to the memory 220 and the communication circuit 230, respectively, the memory 220 stores program data, and the processor 210 implements the steps of the method according to any of the above embodiments by executing the program data in the memory 220, wherein detailed steps can refer to the above embodiments and are not repeated herein.
The focusing device 200 may be integrated with the camera or may be independent of the camera. When the focusing device 200 is independent of the camera, it may be any device with video processing capability, such as a computer, a mobile phone, etc., and is not limited herein.
Referring to fig. 12, fig. 12 is a schematic structural diagram of an embodiment of a focusing device according to the present application. The focusing apparatus 300 includes an information acquisition module 310, a direction determination module 320, a region determination module 330, and a motor driving module 340.
The information acquiring module 310 is used for acquiring the motion information of the focus target.
The direction determining module 320 is connected to the information obtaining module 310, and is configured to determine a moving direction of the focusing object according to the movement information.
The region determining module 330 is connected to the direction determining module 320, and configured to determine a focusing region in the current frame image according to a moving direction of the focusing target;
the motor driving module 340 is connected to the region determining module 330, and is configured to drive the focus motor in the camera to move, so as to perform a focusing process on the focus region.
The focusing apparatus 300 in this embodiment performs the steps in the focusing method in any one of the above embodiments when operating, and the detailed steps can be referred to the above embodiments, which are not described herein again.
The focusing device 300 may be integrated with the camera or may be independent of the camera. When the focusing device 300 is independent of the camera, it may be any device with video processing capability, such as a computer, a mobile phone, etc., and is not limited herein.
Referring to fig. 13, fig. 13 is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application. The computer-readable storage medium 400 stores a computer program 410, the computer program 410 being executable by a processor to implement the steps of any of the methods described above.
The computer-readable storage medium 400 may be a device that can store the computer program 410, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, or may be a server that stores the computer program 410, and the server can send the stored computer program 410 to another device for operation, or can self-operate the stored computer program 410.
The above embodiments are merely examples and are not intended to limit the scope of the present disclosure, and all modifications, equivalents, and flow charts using the contents of the specification and drawings of the present disclosure or those directly or indirectly applied to other related technical fields are intended to be included in the scope of the present disclosure.

Claims (13)

1. A focusing method, characterized in that the method comprises:
acquiring motion information of a focusing target;
determining the motion direction of the focusing target according to the motion information;
determining a focusing area in the current frame image according to the motion direction of the focusing target;
driving a focusing motor in a camera to move so as to focus the focusing area;
wherein the step of driving the focus motor in the camera to move comprises:
acquiring a current first position of the focusing motor and a current second position of a zooming motor in the camera;
determining the current object distance of the camera according to the first position and the second position;
determining a minimum standard object distance which is larger than the current object distance and a maximum standard object distance which is smaller than the current object distance;
respectively determining a first standard position and a second standard position of the focusing motor at the second position on a first standard object distance curve corresponding to the minimum standard object distance and a second standard object distance curve corresponding to the maximum standard object distance;
determining an adjusting step length according to the first standard position and the second standard position;
and driving the focusing motor to move according to the adjusting step length.
2. The focusing method according to claim 1, wherein the step of determining a focusing area in a current frame image according to the moving direction of the focusing target comprises:
and determining a region extending along the motion direction, passing through the center point of the current frame image and extending from one side of the current frame image to the other side of the current frame image as the focusing region.
3. The method of claim 1, wherein the motion information comprises a first rotation angle of the camera in a first direction, a first rotation direction, and a second rotation angle of the camera in a second direction, a second rotation direction;
the step of determining the motion direction of the focusing target according to the motion information includes:
if the first rotation angle exceeds a first angle threshold value and the second rotation angle does not exceed a second angle threshold value, determining the movement direction of the focusing target according to the first direction;
if the first rotation angle does not exceed the first angle threshold and the second rotation angle exceeds the second angle threshold, determining the movement direction of the focusing target according to the second direction;
and if the first rotation angle exceeds the first angle threshold value and the second rotation angle exceeds the second angle threshold value, determining the movement direction of the focusing target according to the first rotation direction and the second rotation direction.
4. The method of claim 1, wherein the step of driving a focus motor in a camera to move to focus the focus region comprises:
after the focusing motor is driven to move, acquiring a definition evaluation value of the focusing area;
and determining whether to drive the focusing motor to move again according to the definition evaluation value of the focusing area.
5. The method according to claim 4, wherein the step of obtaining the sharpness evaluation value of the focus area comprises:
distributing weights to all image blocks in the current frame image, wherein the weight of the image block where the focus area is located is greater than the weights of other image blocks;
and determining the definition evaluation value of the focusing area according to the weight of each image block.
6. The method of claim 4, wherein the step of driving a focus motor in a camera to move to focus the focus region further comprises:
when the focusing motor is driven to move towards a first direction, if the current position of the focusing motor reaches an extreme position in the first direction, the focusing motor is driven to move towards a second direction opposite to the first direction; and/or the presence of a gas in the gas,
and after the focusing motor is driven to move towards a first direction, if the decrease of the definition evaluation value of the focusing area is detected, the focusing motor is driven to move towards a second direction opposite to the first direction.
7. The method of claim 6, wherein the step of driving a focus motor in a camera to move to focus the focus area further comprises:
in the process of driving the focusing motor to move, if at least one of the conditions that the definition evaluation value of the focusing area is increased and then decreased, the moving direction of the focusing motor is changed twice, and the moving frequency of the focusing motor reaches a frequency threshold value is detected, the driving of the focusing motor is stopped, so that the focusing processing is finished.
8. The method of claim 1, wherein the step of determining an adjustment step size based on the first standard position and the second standard position comprises:
if the current object distance is larger than the critical object distance, obtaining the adjusting step length according to a first product of a distance value between the first standard position and the second standard position and a first parameter;
otherwise, obtaining the adjusting step length according to a second product of the distance value between the first standard position and the second standard position and a second parameter, wherein the first parameter is smaller than the second parameter.
9. The method of claim 1, further comprising:
after the focusing processing is carried out on the focusing area, when the camera is detected to rotate, acquiring an angle difference value between the current angle of the camera and the angle when the previous focusing processing is finished;
and if the angle difference exceeds an angle threshold, returning to the step of acquiring the motion information of the focusing target.
10. The method according to claim 9, wherein if the angle difference exceeds an angle threshold, before returning to the step of obtaining the motion information of the focus target, the method further comprises:
determining a current first position of the focus motor and a current second position of a zoom motor in the camera;
determining the current object distance of the camera according to the first position and the second position;
determining the size relation between the current object distance and the critical object distance;
and determining the angle threshold according to the second position and the size relation.
11. The method of claim 1, further comprising, after performing the focusing process:
when the re-triggering condition is met, returning to execute the step of acquiring the motion information of the focusing target;
after each focusing process is finished, if a change value of a definition evaluation value of the focusing area corresponding to the previous focusing process is detected to exceed a change threshold value, adjusting the position of the focusing motor to the position after the previous focusing process, and generating a tracking focusing failure alarm event;
after the focusing processing is carried out on the focusing area, when the camera is detected to rotate, the angle difference between the current angle of the camera and the angle when the previous focusing processing is finished is obtained, and the re-triggering condition is determined to be met in response to the fact that the angle difference exceeds an angle threshold.
12. A focusing device, comprising a processor, a memory and a communication circuit, wherein the processor is coupled to the memory and the communication circuit, respectively, and the memory stores program data therein, and the processor executes the program data in the memory to implement the steps of the method according to any one of claims 1-11.
13. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executable by a processor to implement the steps in the method according to any of claims 1-11.
CN202111006320.4A 2021-08-30 2021-08-30 Focusing method, focusing apparatus, and computer-readable storage medium Active CN113905173B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111006320.4A CN113905173B (en) 2021-08-30 2021-08-30 Focusing method, focusing apparatus, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111006320.4A CN113905173B (en) 2021-08-30 2021-08-30 Focusing method, focusing apparatus, and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN113905173A CN113905173A (en) 2022-01-07
CN113905173B true CN113905173B (en) 2023-04-07

Family

ID=79188357

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111006320.4A Active CN113905173B (en) 2021-08-30 2021-08-30 Focusing method, focusing apparatus, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN113905173B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6879343B2 (en) * 1993-05-28 2005-04-12 Canon Kabushiki Kaisha Automatic focus adjusting device
CN103747179A (en) * 2014-01-02 2014-04-23 深圳英飞拓科技股份有限公司 Zooming tracking method and system based on focusing evaluation value feedback regulation
CN106961552A (en) * 2017-03-27 2017-07-18 联想(北京)有限公司 One kind focusing control method and electronic equipment
CN110278383A (en) * 2019-07-25 2019-09-24 浙江大华技术股份有限公司 Focus method, device and electronic equipment, storage medium
CN110572577A (en) * 2019-09-24 2019-12-13 浙江大华技术股份有限公司 Method, device, equipment and medium for tracking and focusing
CN113315903A (en) * 2020-02-26 2021-08-27 北京小米移动软件有限公司 Image acquisition method and device, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105262954B (en) * 2015-11-17 2019-07-19 腾讯科技(深圳)有限公司 The method and apparatus that triggering camera focuses automatically
CN111243030B (en) * 2020-01-06 2023-08-11 浙江大华技术股份有限公司 Target focusing dynamic compensation method and device and storage device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6879343B2 (en) * 1993-05-28 2005-04-12 Canon Kabushiki Kaisha Automatic focus adjusting device
CN103747179A (en) * 2014-01-02 2014-04-23 深圳英飞拓科技股份有限公司 Zooming tracking method and system based on focusing evaluation value feedback regulation
CN106961552A (en) * 2017-03-27 2017-07-18 联想(北京)有限公司 One kind focusing control method and electronic equipment
CN110278383A (en) * 2019-07-25 2019-09-24 浙江大华技术股份有限公司 Focus method, device and electronic equipment, storage medium
CN110572577A (en) * 2019-09-24 2019-12-13 浙江大华技术股份有限公司 Method, device, equipment and medium for tracking and focusing
CN113315903A (en) * 2020-02-26 2021-08-27 北京小米移动软件有限公司 Image acquisition method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN113905173A (en) 2022-01-07

Similar Documents

Publication Publication Date Title
US10455152B2 (en) Panoramic video processing method and device and non-transitory computer-readable medium
US9799118B2 (en) Image processing apparatus, imaging apparatus and distance correction method
US10769798B2 (en) Moving object detection apparatus, moving object detection method and program
JP5075757B2 (en) Image processing apparatus, image processing program, image processing method, and electronic apparatus
TWI471677B (en) Auto focus method and auto focus apparatus
KR20160020498A (en) Tracker assisted image capture
CN107888819A (en) A kind of auto focusing method and device
CN113572958B (en) Method and equipment for automatically triggering camera to focus
EP2733923A2 (en) Multiresolution depth from defocus based autofocus
JP5968379B2 (en) Image processing apparatus and control method thereof
CN113905173B (en) Focusing method, focusing apparatus, and computer-readable storage medium
CN111491105B (en) Focusing method of mobile terminal, mobile terminal and computer storage medium
CN111405193B (en) Focusing method and device and camera equipment
KR101576426B1 (en) Apparatus and Method for surveillance using fish eyes lens
JP5179784B2 (en) Three-dimensional coordinate measuring apparatus and program executed in three-dimensional coordinate measuring apparatus
CN112740649A (en) Photographing method, photographing apparatus, and computer-readable storage medium
JP5910252B2 (en) Imaging setting control system and imaging setting control method
CN110290315B (en) Tracking focusing method, apparatus, camera and medium for pan-tilt camera
US20240015391A1 (en) Information processing apparatus, information processing method, and storage medium
JP7154796B2 (en) Image processing device, image processing method, and program
EP4198918A1 (en) Object detection method and object detection system for video
US20230196584A1 (en) Object detection method and object detection system for video
JP2012118923A (en) Area division device and area division method
CN117808861A (en) Operation method of binocular vision system
JP2018124678A (en) Obstacle detection device, obstacle detection method, and obstacle detection program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant