Automatic focusing method, device, image acquisition device and storage medium

By acquiring the image to be focused and its zoom information, and moving the focus mirror group within the preset focus range to determine the target coordinates, the problem of low focus efficiency in the prior art in non-fixed positions and object scenes is solved, and efficient automatic focusing in various scenarios is achieved.

CN119071631BActive Publication Date: 2025-03-04HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411398475.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-03-04
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

The existing automatic focus technology can only focus quickly in fixed positions and object scenes, and cannot be applied to other shooting scenes.

Method used

By acquiring the image to be focused and its zoom information, the corresponding focus range in the preset calibration information is determined, and the focus mirror group is controlled to move within this range to determine the target coordinates, thereby achieving efficient automatic focusing of the image to be focused.

Benefits of technology

It improves the efficiency of automatically focusing on focused images, shortens the focus time, and is suitable for a variety of shooting scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071631B_ABST
    Figure CN119071631B_ABST
Patent Text Reader

Abstract

The embodiments of the present application are applicable to the field of automatic focusing technology, and provide an automatic focusing method, device, image acquisition equipment and storage medium, the method comprising: obtaining an image to be focused and its corresponding magnification information; determining a focusing range corresponding to the magnification information in preset calibration information; controlling a preset focusing lens group to move within the focusing range to determine a target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group; controlling the focusing lens group to be located at the target coordinate to generate a target image; wherein the focusing range comprises a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity. The embodiments of the present application can accelerate the time for completing automatic focusing of the image to be focused.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application belong to the field of automatic focusing technology, and in particular, relate to an automatic focusing method, device, image acquisition equipment and storage medium. Background Art

[0002] Autofocus means that the lens automatically adjusts the focus on the object when shooting to obtain the clearest image. This technology is widely used in electronic products such as video cameras, digital cameras, and mobile phones.

[0003] Focusing includes adjusting the position of the focusing lens in the lens. In order to improve the automatic focusing speed in the related art, the position of the focusing lens is pre-set in combination with the fixed position of the lens and the known objects that it may shoot. When it is necessary to shoot a known object, the focusing lens is adjusted to the preset position for the known object to complete the automatic focusing.

[0004] The above-mentioned related technologies can only achieve fast focusing for fixed-position cameras and fixed shooting objects, and are not applicable to other shooting scenarios. Summary of the invention

[0005] In view of this, embodiments of the present application provide an automatic focusing method, apparatus, image acquisition device, and storage medium to improve the efficiency of automatic focusing on a captured image to be focused.

[0006] A first aspect of an embodiment of the present application provides an automatic focusing method, comprising:

[0007] Obtaining the image to be focused and its corresponding magnification information;

[0008] Determining a focus range corresponding to the zoom information in preset calibration information;

[0009] Controlling a preset focusing lens group to move within the focusing range to determine a target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group;

[0010] Controlling the focusing lens group to be located at the target coordinates to generate a target image;

[0011] Among them, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity.

[0012] A second aspect of an embodiment of the present application provides an automatic focusing device, comprising:

[0013] An initial acquisition module is used to acquire the image to be focused and its corresponding zoom information;

[0014] A focusing range determination module, used to determine a focusing range corresponding to the zoom information in preset calibration information;

[0015] A target coordinate determination module, used to control a preset focusing lens group to move within the focusing range to determine the target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group;

[0016] A target image generation module, used for controlling the focusing lens group to be located at the target coordinates to generate a target image;

[0017] Among them, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity.

[0018] A third aspect of an embodiment of the present application provides an image acquisition device, comprising a focusing lens group, a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the automatic focusing method as described in the first aspect above is implemented.

[0019] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the automatic focusing method as described in the first aspect above is implemented.

[0020] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the automatic focusing method described in the first aspect.

[0021] Compared with the related art, the embodiments of the present application have the following beneficial effects:

[0022] In the embodiment of the present application, after acquiring the image to be focused and its corresponding magnification information, the focusing range corresponding to the magnification information in the preset calibration information is determined, and then the preset focusing lens group is controlled to move within the focusing range to determine the target coordinates; the target coordinates are the positions corresponding to the target clarity peak values ​​determined during the movement of the focusing lens group. After determining the target coordinates, the focusing lens group is controlled to be located at the target coordinates to generate the target image; wherein the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when the farthest focusable position is focused and the clarity is the highest, and the second boundary coordinate is the position of the focusing lens group when the nearest focusable position is focused and the clarity is the highest, so that after determining the magnification information of the image to be focused, the focusing lens group is controlled to determine the target coordinates within the focusing range corresponding to the magnification information, and the focusing range eliminates the invalid area corresponding to the magnification information within the entire movable range of the focusing lens group, thereby improving the efficiency of determining the target coordinates and accelerating the time to complete automatic focusing of the image to be focused, that is, improving the efficiency of automatic focusing on the captured image to be focused. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 is a schematic diagram of an automatic focusing method provided in an embodiment of the present application;

[0025] Figure 2 is a schematic diagram of a process for determining a target starting position and a target direction of the focusing lens assembly provided by an embodiment of the present application;

[0026] Figure 3 This is a schematic diagram of a flow chart for generating trial data provided by an embodiment of the present application;

[0027] Figure 4 This is a schematic diagram of a process for determining a target area of ​​an image to be focused provided by an embodiment of the present application;

[0028] Figure 5 It is a schematic diagram of a process of searching target coordinates along a target direction by a focusing lens assembly provided in an embodiment of the present application;

[0029] Figure 6 This is a schematic diagram of a mapping relationship determination process provided by an embodiment of the present application;

[0030] Figure 7is a schematic diagram of calibration information provided in an embodiment of the present application;

[0031] Figure 8 is a schematic diagram of a first boundary curve generating method provided in an embodiment of the present application;

[0032] Fig. 9 is a schematic diagram of an automatic focusing device provided in an embodiment of the present application;

[0033] Fig.10 It is a schematic diagram of an image acquisition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0035] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0036] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0037] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0038] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0039] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0040] The embodiments of the present application may be applicable to image acquisition devices (e.g., cameras, video cameras, etc.) that can magnify and automatically focus the acquired images. The image acquisition device is provided with an image sensor and an optical system. The optical system may be provided with a magnification lens group and a focusing lens group. The magnification of the image acquired by the image sensor is changed by adjusting the magnification lens group (including but not limited to adjusting its position relative to the image sensor), and the image acquired by the image sensor is focused by adjusting the focusing lens group (including but not limited to adjusting its position relative to the image sensor). The magnification lens group and the focusing lens group may be provided with one or more lenses.

[0041] The technical solution of the present application is described below through specific embodiments.

[0042] Reference Figure 1 , shows a schematic diagram of an automatic focusing method provided in an embodiment of the present application, which may specifically include the following steps:

[0043] Step 101, obtaining an image to be focused and its corresponding zoom information;

[0044] Determine that the currently acquired image that needs to be automatically focused is the image to be focused, and determine the zoom information corresponding to the image to be focused. In a specific implementation, the currently acquired image can be determined as the image to be focused when a specified operation event is detected. The specified operation event may include but is not limited to an operation event for an autofocus button (a user clicks the autofocus button), an operation event for adjusting the image acquisition direction (a user adjusts the horizontal or vertical orientation of the image acquisition device), and an operation event for a zoom button (a user clicks the autofocus button).

[0045] As an example, the image acquisition device is a rotatable portable ball camera, which can be placed arbitrarily by the user, and the user can also move the portable ball camera in working state. The portable ball camera includes a platform and an image acquisition unit movably connected to the platform. The user can rotate the image acquisition unit by clicking the horizontal rotation button or the vertical rotation button set on the portable ball camera, and change the real scene for image acquisition. At this time, the image acquired by the image acquisition unit is an image that needs to be automatically focused, that is, an image to be focused.

[0046] Different positions of the zoom lens group correspond to different zoom information, so the zoom information can be determined by the current position of the zoom lens group.

[0047] In a specific implementation, the zoom lens group may be controlled by a zoom motor, and the position of the zoom lens group may be determined according to the rotation distance of the zoom motor.

[0048] Step 102, determining a focus range corresponding to the zoom information in the preset calibration information;

[0049] Among them, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity.

[0050] The calibration information is provided with different zoom information and the focusing range corresponding to the different zoom information. For each zoom information, the corresponding first boundary coordinate and second boundary coordinate are provided. The first boundary coordinate is the position of the focusing lens group when the image acquisition device focuses on the farthest focusable point and the clarity is the highest when the image is acquired according to the zoom information. The second boundary coordinate is the position of the focusing lens group when the image acquisition device focuses on the nearest focusable point and the clarity is the highest when the image is acquired according to the zoom information. Therefore, the positions outside the focusing range are all invalid areas. When the focusing lens group is located in the invalid area, a clearly focused image cannot be obtained.

[0051] Each magnification information corresponds to a first boundary coordinate and a second boundary coordinate. After the magnification information is determined, the first boundary coordinate and the second boundary coordinate corresponding to the magnification information can be determined in the calibration information, and the first boundary coordinate and the second boundary coordinate are used as the two boundaries of the focusing range to determine the focusing range.

[0052] Step 103, controlling a preset focusing lens group to move within the focusing range to determine a target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group;

[0053] In a specific implementation, the focusing lens group can be controlled by a variable magnification motor, and the position of the focusing lens group can be determined according to the rotation distance of the focusing motor.

[0054] Since the first boundary coordinate is the position of the focusing lens group when the image acquisition device focuses on the farthest focusable point and has the highest clarity when capturing images according to certain zoom information, and the second boundary coordinate is the position of the focusing lens group when the image acquisition device focuses on the nearest focusable point and has the highest clarity when capturing images according to certain zoom information, the focusing range is smaller than the movable range of the focusing lens group. At the same time, under certain zoom information, when the image with the highest clarity is obtained by adjusting the focusing lens group, the position of the focusing lens group must be within the focusing range corresponding to the zoom information.

[0055] The target coordinates are the target clarity peak positions determined during the movement of the focusing lens group, that is, when the focusing lens group is located at the target coordinates, a clear image corresponding to the image to be focused can be generated.

[0056] In the related automatic focusing technology, for the to-be-focused images with different zoom information, the focus lens group is controlled to traverse the entire movable range of the focus lens group to determine the position with the highest clarity of the to-be-focused image. However, the embodiment of the present application determines the focus range corresponding to the zoom information, controls the focus lens group to move within the focus range to determine the clarity peak position, and completes the focusing. The focus ranges corresponding to different zoom information are all smaller than the movable range of the focus lens group, so the embodiment of the present application can improve the efficiency of automatic focusing on the to-be-focused image.

[0057] Step 104, controlling the focusing lens group to be located at the target coordinates to generate a target image;

[0058] After determining the target coordinates, the focusing lens group is controlled to be located at the target coordinates to complete automatic focusing. The image acquisition device automatically focuses on the image to be focused, thereby generating a focused target image.

[0059] In an embodiment of the present application, after acquiring the image to be focused and its corresponding magnification information, the focusing range corresponding to the magnification information in the preset calibration information is determined, and then the preset focusing lens group is controlled to move within the focusing range to determine the target coordinates; the target coordinates are the positions corresponding to the target clarity peak values ​​determined during the movement of the focusing lens group. After determining the target coordinates, the focusing lens group is controlled to be located at the target coordinates to generate the target image; wherein the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when the farthest focusable position is focused and the clarity is the highest, and the second boundary coordinate is the position of the focusing lens group when the nearest focusable position is focused and the clarity is the highest, so that after determining the magnification information of the image to be focused, the focusing lens group is controlled to determine the target coordinates within the focusing range corresponding to the magnification information, and the focusing range eliminates the invalid area corresponding to the magnification information within the entire movable range of the focusing lens group, thereby improving the efficiency of determining the target coordinates and accelerating the time to complete automatic focusing of the image to be focused, that is, improving the efficiency of automatic focusing of the captured image to be focused.

[0060] In some embodiments of the present application, step 103 includes: determining a target starting position and a target direction of the focusing lens group; determining a target area of ​​the image to be focused; controlling the focusing lens group to move along the target direction starting from the target starting position to generate peak search data corresponding to the target area; and determining target coordinates based on the peak search data.

[0061] The focusing range includes multiple coordinates. In order to search for the target coordinates in the focusing range, it is necessary to first determine the moving direction of the focusing lens group in the focusing range (i.e., the direction of searching for the target coordinates) as the target direction. Before executing step 103, the position of the focusing lens group may be outside the focusing range or any point within the focusing range. Therefore, the position of the focusing lens group before moving along the target direction is required to be the target starting position.

[0062] The image to be focused may have a certain depth of field and contain multiple objects. Different target images can be obtained by automatically focusing on different objects. The target area can be the focus point of the image to be focused. Automatically focusing on the target area can obtain an image with a clearer target area than other areas. The target area can be determined by user selection or by a preset method.

[0063] As an example, the image to be focused can be divided into a middle area and a plurality of peripheral areas adjacent to the middle area. The user can specify the middle area or one of the peripheral areas as the target area, or determine the middle area or one of the peripheral areas as the target area by a preset method.

[0064] In the process of controlling the focusing lens group to move along the target direction, peak search data corresponding to the target area is generated, and the target coordinates are determined based on the peak search data.

[0065] As an example, the target starting position of the focusing lens group may be determined first, and then the target moving direction may be determined in combination with the first boundary coordinate and the second boundary coordinate of the target starting position.

[0066] Reference Figure 2 , shows a schematic diagram of a process for determining a target starting position and a target direction of the focusing lens assembly provided in an embodiment of the present application; in some embodiments of the present application, determining the target starting position and the target direction of the focusing lens assembly includes:

[0067] Step 201, determining the current position of the focusing lens assembly;

[0068] The current position of the focusing lens group is determined by the rotation distance of the focusing motor used to control the focusing lens group. In a specific implementation, the focusing lens group is provided with an initial focus position, and when the position of the focusing lens group is initialized, the focusing lens group is located at the initial focus position. The relative position of the focusing lens group relative to the initial focus position can be determined by the rotation distance of the focusing motor relative to the initial focus position, and the rotation direction, and the current position of the focusing lens group can be determined based on the relative position.

[0069] Furthermore, a focusing coordinate axis can be constructed based on the initial focusing position, and the focusing range and the position of the focusing lens group can be identified by the coordinates of the coordinate axis.

[0070] Step 202, determining a probe starting position and a probe direction of the focusing lens assembly based on the current position, the first boundary coordinates and the second boundary coordinates;

[0071] After the current position is determined, the probing start position and the probing direction may be determined based on the positional relationship between the current position and the first boundary coordinates and the second boundary coordinates.

[0072] The positional relationship may include one of the following: the current position coincides with the first boundary coordinate, the current position coincides with the second boundary coordinate, the current position is between the first boundary coordinate and the second boundary coordinate, and the first boundary coordinate and the second boundary coordinate are located on the same side of the current position. For the case where the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, the positional relationship also includes the first boundary coordinate being closer to the current position than the second boundary coordinate, or the second boundary coordinate being closer to the current position than the first boundary coordinate.

[0073] A trial distance can be preset, and the process of the focusing lens group moving from the trial starting position to the trial ending position is the trial stage. The target direction and the target starting position are determined by the trial data generated in the trial stage with a limited trial distance, thereby improving the efficiency of searching the target coordinates.

[0074] Step 203, controlling the focusing lens group to move along the probing direction starting from the probing starting position to generate probing data;

[0075] Wherein, the trial data includes a first clarity and a first confidence;

[0076] After determining the tentative starting position and the tentative direction, the focusing lens group is controlled to move along the tentative direction with the tentative starting position as the starting point. During the movement along the tentative direction, tentative data including a first clarity and a first confidence level are generated for the image to be focused. The first clarity level is used to indicate the clarity level of the image to be focused, and the first confidence level is used to indicate the reliability level of the first clarity level.

[0077] The embodiment of the present application does not limit the method for calculating the clarity of the focused image.

[0078] Step 204, when the trial data meets the preset forward condition, determining the trial direction as the target direction, and determining the current position of the focusing lens group as the target starting position;

[0079] Step 205, when the trial data does not satisfy the preset forward condition, determining the opposite direction of the trial direction as the target direction, and determining the trial starting position as the target starting position;

[0080] The preset forward condition is that the first confidence is greater than a first confidence threshold, and the first clarity is positively correlated with a distance that the focusing lens group moves along the probing direction.

[0081] If, during the movement of the focusing lens group along the probing direction, the first confidence is greater than the first confidence threshold and the first clarity increases with the increase of the moving distance, it means that the probability of determining the target coordinates by taking the probing direction as the target direction is high, or the target coordinates obtained by continuing to search along the probing direction can have a higher clarity of the image to be focused than the target coordinates obtained by searching along the reverse direction of the probing direction. Therefore, if the probing data meets the preset forward condition, the probing direction is taken as the target direction.

[0082] If, during the movement of the focusing lens group along the probing direction, the first confidence is not greater than the first confidence threshold or the first clarity does not increase with the increase of the moving distance, the opposite direction of the probing direction is used as the target direction, and the focusing lens group is controlled to move to the position before the start of the probing phase, that is, the probing starting position is used as the target position.

[0083] In some embodiments of the present application, step 202 may include: when the current position, the first boundary coordinates, and the second boundary coordinates satisfy a preset position adjustment condition, determining the one of the first boundary coordinates and the second boundary coordinates that is closer to the current position as a tentative starting position; determining a tentative direction with the tentative starting position as a starting point, and an end point of the tentative direction is the one of the first boundary coordinates and the second boundary coordinates that is farther from the current position; when the current position, the first boundary coordinates, and the second boundary coordinates do not satisfy a preset position adjustment condition, determining the current position as a tentative starting position; and taking a direction from the tentative starting position to the first boundary coordinates as a tentative direction;

[0084] The position adjustment condition is that the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, or the distance between one of the first boundary coordinate and the second boundary coordinate and the current position is less than a preset first distance.

[0085] If the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, or the distance between the first boundary coordinate and the second boundary coordinate and the current position is less than the preset first distance, the position of the focusing lens group needs to be adjusted to determine the starting position and the direction of the probe.

[0086] Specifically, if the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, it means that the focusing lens group is located outside the focusing range, by determining the one of the first boundary coordinate and the second boundary coordinate that is closer to the current position, and taking the closer boundary coordinate as the tentative starting distance, the direction from the tentative starting position to the one of the first boundary coordinate and the second boundary coordinate that is farther from the current position is taken as the tentative direction. For example: if the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, and the distance between the first boundary coordinate and the current position is smaller than the distance between the second boundary coordinate and the current position, the first boundary coordinate is taken as the tentative starting position, and the direction from the first boundary coordinate to the second boundary coordinate is taken as the tentative direction. Similarly, if the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, and the distance between the second boundary coordinate and the current position is smaller than the distance between the first boundary coordinate and the current position, the second boundary coordinate is taken as the tentative starting position, and the direction from the second boundary coordinate to the first boundary coordinate is taken as the tentative direction.

[0087] If the distance between one of the first boundary coordinate and the second boundary coordinate and the current position is less than the preset first distance, the focusing lens group cannot complete the trial in one direction. For example: if the distance between the first boundary coordinate and the current position is less than the preset first distance, and the preset first distance is not greater than the above trial distance, the focusing lens group cannot complete the trial in the direction of the first boundary coordinate, and can only perform the trial in the direction of the second boundary coordinate. If the position corresponding to the target clarity peak is between the current position and the first boundary coordinate, it will greatly affect the focusing efficiency, so it is necessary to determine the first boundary coordinate as the starting position for the trial.

[0088] If the current position is between the first boundary coordinate and the second boundary coordinate, and the distance between the current position and the first boundary coordinate and the second boundary coordinate is greater than the preset threshold, the current position is used as the tentative starting position, and the direction of the first boundary coordinate is used as the tentative direction. Since the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, the first boundary coordinate is used as the tentative direction, which can improve the success rate and efficiency of determining the target coordinates.

[0089] As an example, since the focusing ranges corresponding to different magnification information are not necessarily equal, the focusing ranges corresponding to some magnification information may be larger, and the focusing ranges corresponding to some magnification information may be smaller, so corresponding trial distances can be set for different magnification information. According to the magnification information of the image to be identified, the corresponding trial distance is determined.

[0090] Reference Figure 3 , shows a schematic diagram of a flow chart of generating trial data provided by an embodiment of the present application; in some embodiments of the present application, step 203 may include:

[0091] Step 2031, controlling the focusing lens group to move along the probing direction starting from the probing starting position;

[0092] Step 2032, determining a first clarity, a first clarity change rate, and a first confidence level of the image to be focused when the focusing lens assembly moves along the probing direction;

[0093] Step 2033: if the moving distance of the focusing lens group does not reach the preset trial distance, and the first definition change rate is not less than the preset first change rate threshold, and the first confidence is greater than the first confidence threshold, then stop controlling the focusing lens group to move along the trial direction, and generate trial data according to the first definition and the first confidence;

[0094] Step 2034: if the moving distance of the focusing lens group reaches a preset test distance, generate test data according to the first clarity and the first confidence.

[0095] The first definition and the first confidence generated for the image to be focused when the focusing lens assembly moves along the probing direction are determined, and then the first definition change rate during the movement in the probing phase is determined according to the first emotion level.

[0096] Before the moving distance of the focusing lens group in the trial phase reaches the preset trial distance, if the first clarity change rate is not less than the preset first change rate threshold and the first confidence is greater than the preset first confidence threshold, the trial phase is ended in advance, the focusing lens group is stopped from being controlled to continue to move along the trial direction, and the trial data is generated according to the first clarity and the first confidence generated during the movement of the focusing lens group along the trial direction, thereby saving the time consumed in the trial phase and reducing the repeated changes of the image to be focused.

[0097] When the moving distance of the focusing lens group in the trial phase reaches the preset trial distance, the trial phase is determined to be ended, the control of the focusing lens group to continue to move along the trial direction is stopped, and the trial data is generated according to the first clarity and the first confidence generated during the movement of the focusing lens group along the trial direction.

[0098] Reference Figure 4 , shows a schematic diagram of a process for determining a target area of ​​an image to be focused provided by an embodiment of the present application; in some embodiments of the present application, determining the target area of ​​the image to be focused includes:

[0099] Step 401, dividing the image to be focused into a preset area and at least one candidate area according to a preset rule;

[0100] The image to be focused can be divided into a plurality of regions of equal perimeter and equal area, including a preset region and candidate regions. As an example, the image to be focused can be divided into 9 regions of 3*3, with the middle region being the preset region and the other 8 regions being candidate regions.

[0101] Step 402, determining, based on the trial data, a definition difference between the candidate area and the preset area during the movement of the focusing lens group along the trial direction;

[0102] For each candidate area and preset area, the definition difference of each area is calculated according to the maximum definition value and the minimum definition value of each area.

[0103] Step 403: Determine one of the candidate area and the preset area as the target area according to the definition difference.

[0104] According to the clarity difference of each area and the preset method, one of the candidate areas or the preset area is determined as the target area. For example, when there is any candidate area whose clarity difference is greater than the preset multiple of the clarity difference of the preset area, the candidate area with the highest clarity difference is determined as the target area; if there is no candidate area whose clarity difference is greater than the preset multiple of the clarity difference of the preset area, the preset area is determined as the target area.

[0105] The target area is the focus center of the automatic focusing process. The target area can be automatically selected through the clarity difference. The larger the clarity difference of the area, the less texture it contains. By determining the target area as described above, the focusing process pays more attention to the area with rich texture.

[0106] In some embodiments of the present application, controlling the focusing lens group to move along the target direction starting from the target starting position to generate peak search data corresponding to the target area includes: controlling the focusing lens group to be located at the target starting position; determining a moving step; controlling the focusing lens group to move along the target direction according to the moving step and a preset number of moving steps to generate a second clarity and a second confidence of the image to be focused; if there is trial data, generating peak search data based on the trial data, the second clarity and the second confidence; if there is no trial data, generating peak search data based on the second clarity and the second confidence.

[0107] After determining the target starting position, the focusing lens group is controlled to be located at the target starting position. For example, when the current position is outside the focusing range and after determining the first boundary coordinate as the target starting position, the focusing lens group is controlled to move to the first boundary coordinate.

[0108] Different moving step lengths may be pre-set for different magnification information, and the moving step length may be determined according to the magnification information corresponding to the image to be focused.

[0109] If the target direction is consistent with the trial direction, that is, the movement of the target direction continues in the same direction after the trial stage ends, and the trial data corresponding to the trial stage is saved at this time, then the peak search data is generated based on the trial data including the first clarity and the first confidence, and the second clarity and the second confidence generated during the movement of the focusing lens group along the target direction.

[0110] If the target direction is opposite to the trial direction, the trial data corresponding to the trial stage is not retained. Then, peak search data is generated based on the second clarity and second confidence generated during the movement of the focusing lens group along the target direction. The peak search data does not include the first clarity and the first confidence.

[0111] In some embodiments of the present application, determining the target coordinates based on the peak search data includes: when it is determined according to the peak search data that there is a target clarity peak that meets the preset search conditions, determining the position corresponding to the target clarity peak as the target coordinates; the preset search conditions are that it is located before the corresponding position of the second clarity that descends in sequence, and the number of the second clarity that descends in sequence reaches a preset number of times; when it is determined according to the peak search data that there is no target clarity peak that meets the preset search conditions, if the focusing lens group has currently reached one of the first boundary coordinates and the second boundary coordinates, updating the target direction in the opposite direction, and returning to the step of controlling the focusing lens group to be located at the target starting position; when it is determined according to the peak search data that there is no target clarity peak that meets the preset search conditions, if the focusing lens group has not currently reached one of the first boundary coordinates and the second boundary coordinates, returning to the step of determining the moving step.

[0112] As an example, the number of moving steps is 3 times, that is, the focusing lens group determines whether the target coordinates are found after each 3 moves. After the 3 moves, if the target clarity peak value that meets the search condition is determined, the movement is stopped; if the target clarity peak value that meets the search condition cannot be determined, the step of determining the step length is returned to achieve a single search process with 3 moves, and the target clarity peak value is determined through multiple cycles of the search process.

[0113] The preset number of times may be the number of times the focusing lens group moves according to the moving step length, and the search condition is that during the movement of the focusing lens group along the target direction, the second clarity continuously decreases, and the number of consecutive decreases reaches a preset number (for example: the number of moving steps is 3 times, and the second clarity decreases 3 times in sequence), and there is a clarity peak before the second clarity continuously decreases, then the clarity peak is determined as the target clarity peak, and the position of the target clarity peak is determined as the target coordinates.

[0114] If the focusing lens group is away from the target starting position and reaches the first boundary coordinate or the second boundary coordinate, but still cannot determine the target clarity peak that meets the search conditions, that is, the target cannot be determined, then the search for the target coordinates is re-enacted. Specifically, the opposite direction of the target direction is used as the new target direction, and the focusing lens group is controlled to return to the target starting position, so that the focusing lens group moves in the opposite direction within the focusing range to search for the target coordinates.

[0115] If the target coordinates cannot be determined at present, but the focusing lens group has not reached the first boundary coordinates or the second boundary coordinates, the step of determining the step length is returned to control the focusing lens group to continue to move along the target direction. In this way, the movement of the focusing lens group in the target direction is divided into multiple movements, each movement is performed according to a preset number of movement steps, thereby improving the efficiency of searching the target coordinates.

[0116] In a specific implementation, if the target coordinates cannot be determined at present, the focusing lens group has not reached the first boundary coordinates or the second boundary coordinates, but at this time the focusing lens group has moved along the target direction to reach a preset second distance (or the number of times it has moved along the target direction reaches a preset number threshold), and the current second clarity is lower than the second clarity corresponding to the target starting position, and the current second confidence is lower than the second confidence corresponding to the target starting position, indicating that the probability of continuing to search for the target coordinates is low, the target direction is updated in the opposite direction, and the step of controlling the focusing lens group to be located at the target starting position is returned to improve the efficiency of searching for the target coordinates by turning to search for the target coordinates in time before reaching the first boundary coordinates or the second boundary coordinates.

[0117] In some embodiments of the present application, after returning to step 502, before controlling the focusing lens group to move along the target direction according to the moving step and the preset number of moving steps to generate the second clarity and the second confidence of the image to be focused, it also includes: determining a step coefficient; and updating the moving step according to the step coefficient.

[0118] By determining the step length coefficient, the moving step length of the focusing lens group is adjusted in different situations, thereby improving the efficiency of searching the target coordinates.

[0119] As an example, if the second confidence is less than the confidence threshold, and the remaining distance in the target direction is greater than the preset first distance threshold, the step length coefficient is determined to be the first coefficient; if the second confidence is less than the confidence threshold, or the second clarity is greater than the clarity threshold and the second clarity change rate is less than the second change rate threshold, the step length coefficient is determined to be the second coefficient; otherwise, the step length coefficient is determined to be the third coefficient. The first coefficient is greater than the second coefficient, and the second coefficient is greater than the third coefficient. For example: the first coefficient is 3, the second coefficient is 2, and the third coefficient is 1.

[0120] In the embodiment of the present application, step 104 may include: controlling the focusing lens group to move to the target coordinates with a minimum step; and determining that the image to be focused when the focusing lens group is located at the target coordinates is the target image.

[0121] By controlling the focusing lens group to move to the target coordinates with the smallest step, the image changes more slowly.

[0122] The following is an example to further illustrate the process of the focusing lens group searching for the target coordinates along the target direction in the embodiment of the present application. Figure 5 , shows a schematic diagram of a process of searching target coordinates along a target direction by a focusing lens assembly provided in an embodiment of the present application; including:

[0123] Step 501, controlling the focusing lens assembly to be located at the target starting position.

[0124] Step 502, determine the moving step length.

[0125] Step 503, determine the step length coefficient.

[0126] Step 504: Update the moving step size according to the step size coefficient.

[0127] Step 505: Control the focusing lens group to move along the target direction according to the moving step length and the preset moving step number, and generate a second clarity and a second confidence of the image to be focused.

[0128] Step 506: If there is trial data, generate peak search data according to the trial data, the second clarity and the second confidence.

[0129] Step 507: if there is no trial data, generate peak search data according to the second clarity and the second confidence.

[0130] Step 508: When it is determined according to the peak search data that there is a target clarity peak that meets the preset search condition, a position corresponding to the target clarity peak is determined as the target coordinate.

[0131] The preset search condition is that the position is located before the corresponding position of the second definition that is sequentially decreased, and the number of times the second definition that is sequentially decreased reaches a preset number.

[0132] Step 509, when it is determined based on the peak search data that there is no target clarity peak that meets the preset search condition, if the focusing lens group has currently reached one of the first boundary coordinate and the second boundary coordinate, update the target direction in the opposite direction and return to step 501.

[0133] Step 510, when it is determined based on the peak search data that there is no target clarity peak that meets the preset search conditions, if the sum of the number of movement steps of the focusing lens group along the target direction reaches a preset number threshold, and the current second clarity is lower than the second clarity corresponding to the target starting position, and the current second confidence is lower than the second confidence corresponding to the target starting position, then return to step 501.

[0134] Step 511 , when it is determined according to the peak search data that there is no target clarity peak that meets the preset search condition, if the focusing lens group has not currently reached one of the first boundary coordinate and the second boundary coordinate, return to step 502 .

[0135] Reference Figure 6 , shows a schematic diagram of a mapping relationship determination process provided in an embodiment of the present application; the mapping relationship between the clarity statistical information and the confidence can be determined by the following method:

[0136] Step 601, obtaining preset images of different scenes, and dividing the preset images into 8*8 square areas;

[0137] Step 602, calculating brightness statistics of each square area;

[0138] Step 603, determine whether there is an overexposed area or an overly dark area; if so, execute steps 604-607; if not, execute steps 605-607.

[0139] Determine an overexposed area and / or an overdark area in the block area according to the brightness statistical information;

[0140] Step 604, reducing the weight values ​​corresponding to the overexposed area and the overly dark area;

[0141] By reducing the weight values ​​corresponding to the overexposed area and the too dark area, the possibility of focusing on bright spots by mistake and the possibility of focusing on dark noise by mistake are reduced.

[0142] Step 605: Calculate clarity statistics based on a preset gradient algorithm and weight values ​​of each block area.

[0143] Step 606: Adjust the clarity statistics of the block areas that meet the preset texture condition in the block areas.

[0144] The feature value calculated by the convolution window in the gradient algorithm can be used to determine whether the square area is a texture-free area. When the feature value is less than the preset texture threshold, the square area can be considered to be a texture-free area, and the filter threshold set in the gradient algorithm is adjusted to make the clarity statistics of the texture-free area in the square area approach 0.

[0145] Step 607: Obtain a mapping relationship between definition statistics and confidence levels based on preset images of multiple scenes.

[0146] By processing preset images of a large number of scenes, a mapping relationship with high reliability is obtained, and the mapping relationship records the corresponding clarity statistical information and confidence.

[0147] In some embodiments of the present application, the confidence of the image to be focused is determined based on clarity statistical information and a preset mapping relationship; the clarity statistical information is determined based on weight values ​​corresponding to multiple brightness statistical areas divided in the image to be focused, the third clarity and the brightness statistical information;

[0148] Among them, the weight value of the brightness statistical area where the brightness statistical information is within the preset brightness range is a first value, and the weight value of the brightness statistical area where the brightness statistical information is outside the preset brightness range is a second value, and the second value is smaller than the first value.

[0149] The image to be focused can be divided into multiple brightness statistical areas, the third clarity and brightness statistical information corresponding to each brightness statistical area are calculated, and whether the corresponding brightness statistical area is an over-exposure area or an over-dark area is determined based on the brightness statistical information. The preset weight value of each brightness statistical area is a first value. When the brightness statistical information of a brightness statistical area is outside the preset brightness range, the brightness statistical area is determined to be an over-exposure area or an over-dark area, and the weight value of the brightness statistical area is reduced, and according to the weight value corresponding to each brightness area and the corresponding third clarity, the clarity statistical information is obtained, and the confidence of the image to be focused (including but not limited to the first confidence and the second confidence) is determined based on the clarity statistical information and the above-obtained mapping relationship.

[0150] By pre-generating a mapping relationship and introducing the first confidence level and the second confidence level in the automatic focusing process, the possibility of focusing errors such as focusing on bright spots and dark spots can be reduced.

[0151] In some embodiments of the present application, the calibration information is generated by the following method: determining a zoom sampling point and a target object distance; the target object distance includes one of a farthest focusable point and a closest focusable point; obtaining a calibration image acquired from a preset calibration object according to the zoom sampling point, and the clarity of the calibration image; calculating a search range corresponding to the target object distance based on the zoom sampling point and preset lens group parameters; controlling the focusing lens group to move within the search range to determine boundary coordinates; the target boundary coordinates are the position of the focusing lens group when the clarity of the calibration image is the highest during the movement of the focusing lens group within the search range; interpolating the boundary coordinates of different zoom sampling points to generate a boundary curve; and generating calibration information based on the boundary curves corresponding to different object distances.

[0152] The calibration object may be an object containing several calibration elements (e.g., paper, photo, plate, etc.). The image acquisition device acquires an image of the calibration object to obtain a calibration image, and calculates the clarity of the calibration image based on the calibration elements. The lens group parameters are parameters related to the zoom lens group and / or the focusing lens group, and the search range corresponding to the target object distance can be calculated based on the lens group parameters. As an example, the lens group parameters can also be set with a focus standard distance corresponding to the target object distance, and the corresponding search range is obtained by expanding based on the focus standard distance. By determining the clarity of the calibration image during the movement of the focusing lens group, the position of the focusing lens group when the clarity of the calibration image is the highest at the current zoom sampling point and the target object distance (the farthest focusable point or the closest focusable point) is determined as the boundary coordinate. The zoom sampling point is a discrete value, and the boundary coordinates corresponding to the zoom sampling point are also discrete values. Therefore, the boundary coordinates of different zoom sampling points at the same target object distance are interpolated to generate a boundary curve.

[0153] Since the calibration information is determined based on the characteristics of the preset calibration object and the image acquisition device (for example, the size of the target object distance, the range of variation of the zoom sampling point, and the parameters of the lens group), and does not depend on the actual position of the image acquisition device and the actual environment in which it is located, the embodiments of the present application can be applicable to general scenarios rather than being limited to fixed scenarios (for example, fixed positions, fixed real environments).

[0154] Reference Figure 7 , shows a schematic diagram of calibration information provided in an embodiment of the present application, wherein the calibration information includes a first boundary curve and a second boundary curve, the horizontal axis (X axis) is the position of the zoom lens group, the position of the zoom lens group corresponds to the zoom information, and the vertical axis (Y axis) is the position of the focusing lens group. The first boundary curve corresponds to the farthest focusable position, and the second boundary curve corresponds to the closest focusable position.

[0155] The following is a further explanation of the method for generating the first boundary curve using an example. Figure 8 , shows a first boundary curve generating method provided by an embodiment of the present application, comprising:

[0156] Step 801, obtaining a calibration image and initializing the lens assembly.

[0157] The image acquisition device acquires the calibration image by acquiring the image of the calibration object. The zoom lens group is provided with an initial zoom position. When the position of the zoom lens group is initialized, the zoom lens group is located at the initial zoom position. The relative position of the zoom lens group relative to the initial zoom position can be determined by the rotation distance and rotation direction of the zoom motor relative to the initial position, and the current position of the zoom lens group can be determined based on the relative position. The lens group initialization includes controlling the zoom lens group to be located at the initial zoom position and controlling the focusing lens group to be located at the initial focusing position, so as to reset the position errors of the zoom lens group and the focusing lens group to zero.

[0158] Step 802, plan the movement of the zoom lens group from point 0 to the W end position, and move to the W end position of the zoom lens group (zoom[0] coordinate) with a certain step length.

[0159] The W end is the short-focus extreme position end.

[0160] Step 803, planning the movement plan between the focusing lens group 0 point and the FAR end coordinate point, and moving to the FAR end position with the maximum step length.

[0161] The FAR end position is the focus_inf[0] coordinate. As an example, for different optical systems, the focus_inf[0] coordinate can be preset. The FAR end is the farthest limit end of the focus.

[0162] Step 804, determine the search range corresponding to the zoom sampling point to be calibrated. Determine the zoom sampling point zoom[i] to be calibrated, plan the movement plan of the zoom lens group, and calculate the search range corresponding to the sampled zoom sampling point. The search range is obtained by expanding the focus_inf calculated based on the current zoom sampling point by a certain tolerance distance. By setting a certain tolerance distance, the search range corresponding to the same zoom sampling point can cover different individuals of the same specification optical system, thereby improving the applicability of the calibration information generation method.

[0163] Step 805, search for the position of the focusing lens group when the calibration image has the highest clarity. Plan a search plan for the focusing lens group at each zoom sampling point, and search for the position of the focusing lens group when the calibration image has the highest clarity, max focus[i], within the search range ([focus[i]min, focus[i]max]) corresponding to zoom[i].

[0164] Step 806, traverse all zoom sampling points, and obtain the position of the focusing lens group corresponding to each zoom sampling point when focusing on the farthest focusable point and calibrating the image with the highest clarity as the first boundary coordinate.

[0165] Step 807: perform linear interpolation on each first boundary coordinate to obtain a first boundary curve.

[0166] The second boundary curve is obtained by a process similar to steps 801-807, which will not be described in detail here.

[0167] In one example, a calibration image corresponding to the target object distance may be obtained by setting a teleconverter between the image acquisition device and the calibration object.

[0168] As an example, when it is determined that the user adjusts the magnification information during the operation of the image acquisition device, the focusing lens group can be controlled to move along the first boundary curve so that the acquired image is close to the clearest position and has a higher clarity. At the same time, when autofocus is required, less time is consumed to complete the autofocus.

[0169] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0170] Reference Fig. 9 , shows a schematic diagram of an automatic focusing device provided in an embodiment of the present application, which may specifically include an initial acquisition module 901, a focus range determination module 902, a target coordinate determination module 903, and a target image generation module 904, wherein:

[0171] An initial acquisition module 901 is used to acquire an image to be focused and its corresponding zoom information;

[0172] A focusing range determination module 902, used to determine a focusing range corresponding to the zoom information in preset calibration information;

[0173] A target coordinate determination module 903 is used to control a preset focusing lens group to move within the focusing range to determine the target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group;

[0174] A target image generating module 904, used to control the focusing lens group to be located at the target coordinates to generate a target image;

[0175] Among them, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity.

[0176] In some embodiments of the present application, the target coordinate determination module 903 includes:

[0177] A target search determination submodule is used to determine the target starting position and target direction of the focusing lens assembly;

[0178] A target area determination submodule, used to determine the target area of ​​the image to be focused;

[0179] A target control submodule, used for controlling the focusing lens group to move along the target direction starting from the target starting position, and generating peak search data corresponding to the target area;

[0180] The target coordinate determination submodule is used to determine the target coordinates according to the peak search data.

[0181] In some embodiments of the present application, the target search determination submodule is used to include:

[0182] A current position determination unit, used to determine the current position of the focusing lens assembly;

[0183] A tentative determination unit, configured to determine a tentative starting position and a tentative direction of the focusing lens assembly based on the current position, the first boundary coordinates, and the second boundary coordinates;

[0184] A trial data generating unit, used for controlling the focusing lens group to move along the trial direction starting from the trial starting position to generate trial data; the trial data includes a first clarity and a first confidence level;

[0185] A trial forward unit, configured to determine the trial direction as a target direction and determine the current position of the focusing lens group as a target starting position when the trial data meets a preset forward condition;

[0186] A probe reversing unit, configured to determine the opposite direction of the probe direction as the target direction and determine the probe starting position as the target starting position when the probe data does not satisfy the preset forward condition;

[0187] The preset forward condition is that the first confidence is greater than a first confidence threshold, and the first clarity is positively correlated with a distance that the focusing lens group moves along the probing direction.

[0188] In some embodiments of the present application, the probe data generating unit includes:

[0189] A probe movement control subunit, used for controlling the focusing lens group to move along the probe direction starting from the probe starting position;

[0190] A clarity information determination subunit, used to determine a first clarity, a first clarity change rate, and a first confidence level of the image to be focused during the movement of the focusing lens group along the probing direction;

[0191] a first trial data generating subunit, configured to stop controlling the focusing lens group to move along the trial direction if the moving distance of the focusing lens group does not reach a preset trial distance, and the first definition change rate is not less than a preset first change rate threshold, and the first confidence is greater than the first confidence threshold, and generate trial data according to the first definition and the first confidence;

[0192] The second probing data generating subunit is configured to generate probing data according to the first clarity and the first confidence if the moving distance of the focusing lens group reaches a preset probing distance.

[0193] In some embodiments of the present application, the tentative determination unit includes:

[0194] A first determining subunit is configured to determine, when the current position, the first boundary coordinates, and the second boundary coordinates satisfy a preset position adjustment condition, which of the first boundary coordinates and the second boundary coordinates is closer to the current position as a tentative starting position; determine a tentative direction with the tentative starting position as a starting point, and an end point of the tentative direction is which of the first boundary coordinates and the second boundary coordinates is farther from the current position;

[0195] a second determining subunit, configured to determine, when the current position, the first boundary coordinates, and the second boundary coordinates do not satisfy a preset position adjustment condition, that the current position is a tentative starting position; and to take a direction from the tentative starting position to the first boundary coordinates as a tentative direction;

[0196] The position adjustment condition is that the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, or the distance between one of the first boundary coordinate and the second boundary coordinate and the current position is less than a preset first distance.

[0197] In some embodiments of the present application, the target area determination submodule includes:

[0198] A to-be-focused division unit, used for dividing the to-be-focused image into a preset area and at least one candidate area according to a preset rule;

[0199] A clarity difference determination unit, configured to determine, based on the trial data, a clarity difference between the candidate area and the preset area during the movement of the focusing lens group along the trial direction;

[0200] The target area determination unit is used to determine one of the candidate area and the preset area as the target area according to the definition difference.

[0201] In some embodiments of the present application, the target control submodule includes:

[0202] A target starting position control unit, used for controlling the focusing lens group to be located at the target starting position;

[0203] A moving step length determining unit, used to determine the moving step length;

[0204] a clarity information determining unit, configured to control the focusing lens group to move along the target direction according to the moving step length and a preset number of moving steps, and generate a second clarity and a second confidence of the image to be focused;

[0205] a second peak search data generating unit, configured to generate peak search data according to the trial data, the second clarity and the second confidence if trial data exists;

[0206] The first peak search data generating unit is configured to generate peak search data according to the second clarity and the second confidence if no trial data exists.

[0207] In some embodiments of the present application, the target control submodule further includes:

[0208] A step coefficient determination unit, used for determining a step coefficient;

[0209] A moving step length updating unit is used to update the moving step length according to the step length coefficient.

[0210] In some embodiments of the present application, the target coordinate determination submodule includes:

[0211] a target coordinate determination unit, for determining, when it is determined according to the peak search data that there is a target clarity peak that satisfies a preset search condition, a position corresponding to the target clarity peak as the target coordinate; the preset search condition is that it is located before a position corresponding to a second clarity that is successively descending, and the number of times the second clarity that is successively descending reaches a preset number;

[0212] a target direction updating unit, configured to update the target direction in an opposite direction and call a target starting position control unit if it is determined according to the peak search data that there is no target clarity peak satisfying the preset search condition and if the focusing lens group has currently reached one of the first boundary coordinate and the second boundary coordinate;

[0213] The moving step length returning unit is used to call the moving step length determining unit if it is determined according to the peak search data that there is no target clarity peak that meets the preset search condition and if the focusing lens group currently does not reach one of the first boundary coordinate and the second boundary coordinate.

[0214] In some embodiments of the present application, the target coordinate determination submodule determining the target coordinates according to the peak search data further includes:

[0215] The target starting position returning unit is used to call the target starting position control unit if it is determined according to the peak search data that there is no target clarity peak that meets the preset search conditions, if the sum of the moving steps of the focusing lens group along the target direction reaches a preset number threshold, and the current second clarity is lower than the second clarity corresponding to the target starting position, and the current second confidence is lower than the second confidence corresponding to the target starting position.

[0216] In some embodiments of the present application, the confidence of the image to be focused is determined based on clarity statistical information and a preset mapping relationship; the clarity statistical information is determined based on weight values ​​corresponding to multiple brightness statistical areas divided in the image to be focused, the third clarity and the brightness statistical information;

[0217] Among them, the weight value of the brightness statistical area where the brightness statistical information is within the preset brightness range is a first value, and the weight value of the brightness statistical area where the brightness statistical information is outside the preset brightness range is a second value, and the second value is smaller than the first value.

[0218] In some embodiments of the present application, the calibration information is generated by the following modules:

[0219] A variable magnification sampling point and target object distance determination module is used to determine the variable magnification sampling point and the target object distance; the target object distance includes one of the farthest focusable point and the closest focusable point;

[0220] A calibration image acquisition module, used to acquire a calibration image acquired by collecting a preset calibration object according to the variable magnification sampling points, and the clarity of the calibration image;

[0221] A search range calculation module, used to calculate the search range corresponding to the target object distance according to the variable magnification sampling points and preset lens group parameters;

[0222] A boundary coordinate determination module is used to control the focusing lens group to move within the search range to determine the boundary coordinates; the target boundary coordinates are the position of the focusing lens group when the clarity of the calibration image is the highest during the movement of the focusing lens group within the search range;

[0223] A boundary curve generation module is used to perform interpolation processing on the boundary coordinates of different zoom sampling points to generate a boundary curve;

[0224] The calibration information generation module is used to generate calibration information according to boundary curves corresponding to different object distances.

[0225] An embodiment of the present application provides an automatic focusing device, and by using the device, each step in the aforementioned method embodiments can be implemented.

[0226] In some embodiments of the present application, the target image generation module 904 includes:

[0227] A minimum step control submodule, used for controlling the focusing lens group to move to the target coordinates with a minimum step;

[0228] The target image determination submodule is used to determine that the image to be focused when the focusing lens group is located at the target coordinates is the target image.

[0229] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.

[0230] Reference Fig.10 , shows a schematic diagram of an image acquisition device provided by an embodiment of the present application. Fig.10 As shown, the image acquisition device 1000 in the embodiment of the present application includes: a processor 1010, a memory 1020, and a computer program 1021 stored in the memory 1020 and executable on the processor 1010. When the processor 1010 executes the computer program 1021, the steps in each embodiment of the above-mentioned automatic focusing method are implemented, for example Figure 1 Alternatively, when the processor 1010 executes the computer program 1021, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Fig. 9 Functions of modules 901 to 904 are shown.

[0231] Exemplarily, the computer program 1021 may be divided into one or more modules / units, which are stored in the memory 1020 and executed by the processor 1010 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which may be used to describe the execution process of the computer program 1021 in the image acquisition device 1000. For example, the computer program 1021 may be divided into an initial acquisition module, a focus range determination module, a target coordinate determination module, and a target image generation module, and the specific functions of each module are as follows:

[0232] An initial acquisition module, used to acquire the image to be focused and its corresponding zoom information;

[0233] A focusing range determination module, used to determine a focusing range corresponding to the zoom information in preset calibration information;

[0234] A target coordinate determination module, used to control a preset focusing lens group to move within the focusing range to determine the target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group;

[0235] A target image generation module, used for controlling the focusing lens group to be located at the target coordinates to generate a target image;

[0236] Among them, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable point with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable point with the highest clarity.

[0237] The image acquisition device 1000 may include, but is not limited to, a processor 1010 and a memory 1020. Those skilled in the art will appreciate that Fig.10 It is only an example of the image acquisition device 1000 and does not constitute a limitation of the image acquisition device 1000. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the image acquisition device 1000 may also include input and output devices, network access devices, buses, etc.

[0238] The processor 1010 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0239] The memory 1020 may be an internal storage unit of the image acquisition device 1000, such as a hard disk or memory of the image acquisition device 1000. The memory 1020 may also be an external storage device of the image acquisition device 1000, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the image acquisition device 1000. Further, the memory 1020 may also include both an internal storage unit of the image acquisition device 1000 and an external storage device. The memory 1020 is used to store the computer program 1021 and other programs and data required by the image acquisition device 1000. The memory 1020 may also be used to temporarily store data that has been output or is to be output.

[0240] An embodiment of the present application also discloses an image acquisition device, including a focusing lens group, a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the automatic focusing method described in the aforementioned embodiments is implemented.

[0241] In some embodiments of the present application, the image acquisition device also includes a zoom lens group.

[0242] The embodiments of the present application further disclose a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the automatic focusing method as described in the above embodiments is implemented.

[0243] The embodiment of the present application further discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the automatic focusing method described in the above-mentioned embodiments.

[0244] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0245] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0246] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic, for example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0247] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0248] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An automatic focusing method, characterized in that: include: Obtaining the image to be focused and its corresponding magnification information; Determining a focus range corresponding to the zoom information in preset calibration information; Controlling a preset focusing lens group to move within the focusing range to determine a target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group; Controlling the focusing lens group to be located at the target coordinates to generate a target image; Wherein, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable position with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable position with the highest clarity; the target coordinate is determined by peak search data generated when the focusing lens group moves along the target direction with the target starting position as the starting point; the target starting position and the target direction are determined by trial data generated when the focusing lens group moves along the trial direction; the trial data includes a first clarity and a first confidence of the image to be focused; The trial data is generated by the following steps: Controlling the focusing lens group to move along the probing direction starting from the probing starting position; Determining a first clarity, a first clarity change rate, and a first confidence level of the image to be focused during the movement of the focusing lens group along the probing direction; If the moving distance of the focusing lens group does not reach the preset trial distance, and the first definition change rate is not less than the preset first change rate threshold, and the first confidence is greater than the first confidence threshold, then stop controlling the focusing lens group to move along the trial direction, and generate trial data according to the first definition and the first confidence; If the moving distance of the focusing lens group reaches the preset trial distance, generating trial data according to the first clarity and the first confidence; The tentative starting position and the tentative direction are determined by the current position of the focusing lens group, the first boundary coordinates and the second boundary coordinates.

2. The method according to claim 1, characterized in that The controlling the preset focusing lens group to move within the focusing range to determine the target coordinates comprises: Determining a target starting position and a target direction of the focusing lens assembly; Determining a target area of ​​the image to be focused; Controlling the focusing lens group to move along the target direction starting from the target starting position to generate peak search data corresponding to the target area; The target coordinates are determined based on the peak search data.

3. The method according to claim 2, characterized in that Determining the target starting position and target direction of the focusing lens assembly comprises: Determining a current position of the focusing lens assembly; Determine a probe starting position and a probe direction of the focusing lens assembly based on the current position, the first boundary coordinates, and the second boundary coordinates; Controlling the focusing lens group to move along the probing direction starting from the probing starting position to generate probing data; the probing data includes a first clarity and a first confidence level; In the case where the trial data meets the preset forward condition, determining the trial direction as the target direction, and determining the current position of the focusing lens group as the target starting position; In the case where the trial data does not satisfy the preset forward condition, determining the opposite direction of the trial direction as the target direction, and determining the trial starting position as the target starting position; The preset forward condition is that the first confidence is greater than a first confidence threshold, and the first clarity is positively correlated with a distance that the focusing lens group moves along the probing direction.

4. The method according to claim 3, characterized in that The determining the probing starting position and probing direction of the focusing lens assembly based on the current position, the first boundary coordinates, and the second boundary coordinates comprises: In the case where the current position, the first boundary coordinates, and the second boundary coordinates satisfy a preset position adjustment condition, determining one of the first boundary coordinates and the second boundary coordinates that is closer to the current position as a tentative starting position; determining a tentative direction with the tentative starting position as a starting point, and an end point of the tentative direction being one of the first boundary coordinates and the second boundary coordinates that is farther from the current position; In the case that the current position, the first boundary coordinates and the second boundary coordinates do not satisfy a preset position adjustment condition, determining the current position as a tentative starting position; and taking a direction from the tentative starting position to the first boundary coordinates as a tentative direction; The position adjustment condition is that the first boundary coordinate and the second boundary coordinate are located on the same side of the current position, or the distance between one of the first boundary coordinate and the second boundary coordinate and the current position is less than a preset first distance.

5. The method according to claim 3, characterized in that: Determining the target area of ​​the image to be focused comprises: Dividing the image to be focused into a preset area and at least one candidate area according to a preset rule; Determine, based on the trial data, a definition difference between the candidate area and the preset area during the movement of the focusing lens group along the trial direction; One of the candidate area and the preset area is determined as the target area according to the definition difference.

6. The method according to any one of claims 3 to 5, characterized in that: The step of controlling the focusing lens group to move along the target direction starting from the target starting position to generate peak search data corresponding to the target area comprises: Controlling the focusing lens group to be located at the target starting position; Determine the moving step length; According to the moving step length and the preset moving step number, the focusing lens group is controlled to move along the target direction to generate a second clarity and a second confidence of the image to be focused; If there is trial data, generating peak search data according to the trial data, the second clarity and the second confidence; If no trial data exists, peak search data is generated according to the second clarity and the second confidence.

7. The method according to claim 6, characterized in that Determining the target coordinates according to the peak search data includes: In the case where it is determined according to the peak search data that there is a target definition peak that meets a preset search condition, determining the position corresponding to the target definition peak as the target coordinate; the preset search condition is that it is located before the corresponding position of the second definition that is successively descending, and the number of the second definition that is successively descending reaches a preset number of times; In the case where it is determined according to the peak search data that there is no target clarity peak that meets the preset search condition, if the focusing lens group has currently reached one of the first boundary coordinate and the second boundary coordinate, updating the target direction in the opposite direction, and returning to the step of controlling the focusing lens group to be located at the target starting position; When it is determined according to the peak search data that there is no target clarity peak that meets the preset search condition, if the focusing lens group has not currently reached one of the first boundary coordinate and the second boundary coordinate, the step of determining the moving step is returned.

8. The method according to claim 6, characterized in that The confidence of the image to be focused is determined according to the clarity statistical information and a preset mapping relationship; the clarity statistical information is determined according to the weight values ​​corresponding to the multiple brightness statistical areas divided in the image to be focused, the third clarity and the brightness statistical information; Among them, the weight value of the brightness statistical area where the brightness statistical information is within the preset brightness range is a first value, and the weight value of the brightness statistical area where the brightness statistical information is outside the preset brightness range is a second value, and the second value is smaller than the first value.

9. The method according to any one of claims 1 to 5, characterized in that: The calibration information is generated by the following method: Determine the zoom sampling point and the target object distance; the target object distance includes one of the farthest focusable point and the closest focusable point; Acquire a calibration image acquired by collecting a preset calibration object according to the variable magnification sampling points, and the clarity of the calibration image; Calculating the search range corresponding to the target object distance according to the variable magnification sampling points and the preset lens group parameters; Controlling the focusing lens group to move within the search range to determine boundary coordinates; the boundary coordinates are the position of the focusing lens group when the clarity of the calibration image is the highest during the movement of the focusing lens group within the search range; Interpolate the boundary coordinates of different zoom sampling points to generate boundary curves; Calibration information is generated based on boundary curves corresponding to different object distances.

10. An automatic focusing device, characterized in that: include: An initial acquisition module is used to acquire the image to be focused and its corresponding zoom information; A focusing range determination module, used to determine a focusing range corresponding to the zoom information in preset calibration information; A target coordinate determination module, used to control a preset focusing lens group to move within the focusing range to determine the target coordinate; the target coordinate is a position corresponding to a target clarity peak value determined during the movement of the focusing lens group; A target image generation module, used for controlling the focusing lens group to be located at the target coordinates to generate a target image; Wherein, the focusing range includes a first boundary coordinate and a second boundary coordinate; the first boundary coordinate is the position of the focusing lens group when focusing on the farthest focusable position with the highest clarity, and the second boundary coordinate is the position of the focusing lens group when focusing on the nearest focusable position with the highest clarity; the target coordinate is determined by peak search data generated when the focusing lens group moves along the target direction with the target starting position as the starting point; the target starting position and the target direction are determined by trial data generated when the focusing lens group moves along the trial direction; the trial data includes a first clarity and a first confidence of the image to be focused; The test data is generated by the following subunits: A probe movement control subunit, used for controlling the focusing lens group to move along the probe direction starting from the probe starting position; A clarity information determination subunit, used to determine a first clarity, a first clarity change rate, and a first confidence level of the image to be focused during the movement of the focusing lens group along the probing direction; a first trial data generating subunit, configured to stop controlling the focusing lens group to move along the trial direction if the moving distance of the focusing lens group does not reach a preset trial distance, and the first definition change rate is not less than a preset first change rate threshold, and the first confidence is greater than the first confidence threshold, and generate trial data according to the first definition and the first confidence; a second trial data generating subunit, configured to generate trial data according to the first clarity and the first confidence if the moving distance of the focusing lens group reaches a preset trial distance; The tentative starting position and the tentative direction are determined by the current position of the focusing lens group, the first boundary coordinates and the second boundary coordinates.

11. An image acquisition device, comprising a focusing lens group, a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the automatic focusing method according to any one of claims 1 to 9 is implemented.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the automatic focusing method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Focusing method and device, computer readable storage medium and electronic equipment

    CN110381261A