Focusing method and device, camera and storage medium

By evaluating the value of the multi-frame image block clarity of the surveillance camera, the difficulty of focusing in the surveillance camera in scenes with fast rotation speed or low lighting is solved, and more accurate focus position determination and clearer image shooting are achieved.

CN119071630APending Publication Date: 2024-12-03TP-LINK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411035156.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In scenarios where the surveillance camera rotates at a fast speed or low light, it is difficult to accurately determine the focus position of the focus motor, resulting in poor imaging quality.

Method used

By acquiring multiple frames of images, each frame of images is divided into multiple image blocks, the definition evaluation value of each image block is calculated, the first and second thresholds are determined, the number of image blocks with strong texture and weak texture is counted, and the calculation is more accurate. the value of the clarity evaluation to determine the focus position.

Benefits of technology

It improves the focus accuracy of surveillance cameras in scenes with poor imaging quality, reduces image texture interference, achieves clearer image shooting, simplifies algorithms and reduces device performance requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071630A_ABST
    Figure CN119071630A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of photography and video recording, and provides a focusing method, a focusing device, a camera and a storage medium. A first block number represents the number of image blocks with relatively high textuality in a plurality of image blocks in a frame of image; the second block number represents the number of the remaining image blocks excluding the image blocks with relatively weak texture in the plurality of image blocks in one frame of image, and the target definition evaluation value determined according to the first block number and the second block number can reduce the interference of relatively weak image texture in the judgment of the image definition. Therefore, the definition evaluation value determined according to the first block number and the second block number can reflect the definition of the image more accurately, the target focusing position can be determined more accurately, and the focusing effect of the camera is good.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of photography and video technology, and in particular relates to a focusing method, device, camera and storage medium. Background Art

[0002] The surveillance camera includes a rotating motor and a focusing motor. As the rotating motor of the surveillance camera rotates, the focusing motor also needs to move to a focusing position, so that the images captured by the surveillance camera remain clear.

[0003] At present, in order to determine the focus position of the focus motor, the overlapping area of ​​adjacent frame images is usually matched, and the clarity evaluation values ​​corresponding to the overlapping area of ​​adjacent frame images are calculated and compared, so as to determine the focus position of the focus motor. However, when the surveillance camera is shooting at a fast rotation speed or the shooting scene is low in light, the image quality is poor. Therefore, the matching effect of the overlapping area of ​​adjacent frame images is poor, and the focus position of the focus motor cannot be accurately determined, resulting in poor focusing effect. Summary of the invention

[0004] The embodiments of the present application provide a focusing method, device, camera and storage medium, which can solve the problem of how to accurately determine the focusing position of a focusing motor when a surveillance camera is shooting in a scene with poor imaging quality.

[0005] In a first aspect, an embodiment of the present application provides a focusing method, comprising:

[0006] Acquire an i-th group of images including N frames of images, where i is a positive integer, N is a positive integer greater than or equal to 3, different frames of images correspond to different focus motor positions, each frame of image includes a plurality of image blocks, and each image block corresponds to a first clarity evaluation value;

[0007] Determine the first number of blocks and the second number of blocks respectively corresponding to each frame of image, the first number of blocks being the number of image blocks with first clarity evaluation values ​​greater than a first threshold respectively corresponding to a plurality of image blocks in each frame of image, and the second number of blocks being the number of image blocks with first clarity evaluation values ​​greater than a second threshold respectively corresponding to a plurality of image blocks in each frame of image;

[0008] Determine a second definition evaluation value corresponding to each frame of image according to the first block number and the second block number corresponding to each frame of image, wherein each frame of image corresponds to a second definition evaluation value;

[0009] The target focus position is determined according to the second clarity evaluation value corresponding to each frame of image.

[0010] The present application provides a focusing method, wherein a first block number represents the number of image blocks with stronger textures among multiple image blocks in a frame of image, and a second block number represents the number of image blocks remaining after excluding image blocks with weaker textures from multiple image blocks in a frame of image. A target clarity evaluation value determined according to the first block number and the second block number can reduce the interference of weaker image texture in judging image clarity, so that the clarity evaluation value determined according to the first block number and the second block number can more accurately reflect the clarity of the image, thereby being able to more accurately determine the target focus position, resulting in a good focusing effect of the camera.

[0011] In a second aspect, an embodiment of the present application provides a focusing device, comprising:

[0012] an acquisition unit, configured to acquire an i-th group of images including N frames of images, where i is a positive integer, and N is a positive integer greater than or equal to 3, where different frames of images correspond to different focus motor positions, and each frame of image includes a plurality of image blocks, and each image block corresponds to a first clarity evaluation value;

[0013] a determining unit, configured to determine a first number of blocks and a second number of blocks respectively corresponding to each frame of image, wherein the first number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a first threshold value respectively corresponding to a plurality of image blocks in each frame of image, and the second number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a second threshold value respectively corresponding to a plurality of image blocks in each frame of image;

[0014] The determination unit is further used to determine the second definition evaluation value corresponding to each frame of the image according to the first block number and the second block number corresponding to each frame of the image, and each frame of the image corresponds to a second definition evaluation value;

[0015] The determination unit is further used to determine the target focus position according to the second clarity evaluation value corresponding to each frame of image.

[0016] In a third aspect, an embodiment of the present application provides a camera, comprising: 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 focusing method as described in any one of the first aspects above is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the focusing method as described in any one of the first aspects above.

[0018] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a camera, the terminal device executes the focusing method of any one of the above-mentioned first aspects.

[0019] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0021] Figure 1 is a schematic diagram of focusing movement during the rotation movement of a camera provided in an embodiment of the present application;

[0022] Figure 2A is a schematic diagram of a relatively clear image captured during the rotational movement of a camera provided in an embodiment of the present application;

[0023] Figure 2B is a schematic diagram of a relatively blurred image captured during the rotational movement of a camera provided in an embodiment of the present application;

[0024] Figure 3 is a flowchart of a focusing method provided in an embodiment of the present application;

[0025] Figure 4 is a distribution diagram of first clarity evaluation values ​​respectively corresponding to image blocks in a frame of image provided by an embodiment of the present application, arranged in ascending order;

[0026] Figure 5A is a schematic diagram of determining a candidate focus position for the first time provided by an embodiment of the present application;

[0027] Figure 5B is a schematic diagram of determining a candidate focus position for the second time provided by an embodiment of the present application;

[0028] Figure 5C is a schematic diagram of determining a candidate focus position for the third time provided by an embodiment of the present application;

[0029] Figure 6 is a schematic structural diagram of a focusing device provided in an embodiment of the present application;

[0030] Figure 7 It is a schematic diagram of the structure of a camera provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] 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.

[0032] 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.

[0033] 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.

[0034] 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.

[0035] 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.

[0036] 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.

[0037] High-speed intelligent ball cameras (referred to as high-speed ball cameras) in surveillance cameras generally include a rotary motor, which can realize rotational movement in the left and right (Pan), pitch (Tilt) and tilt (Pan+Tilt) directions. The focus movement schematic diagram of the camera rotation movement process provided in the embodiment of the present application is as follows: Figure 1 As shown, the user can control the rotating motor to rotate the high-speed ball camera to move to the scene that the user is interested in. In the process of controlling the movement of the rotating motor (that is, the rotation angle of the rotating motor changes), the user needs to move the focusing motor to a suitable position (the focusing motor position, that is, the focusing position), so that the picture taken by the high-speed ball camera can remain relatively clear, that is, there is motion blur in the picture, but no out-of-focus blur.

[0038] In the related art, a contrast focusing method is used to determine the focus position of the focus motor, and the focus position of the focus motor is determined by image comparison. The principle is: under a fixed object distance, the positions of the rotating motor and the zoom motor in the surveillance camera remain unchanged, that is, the surveillance camera is in a fixed focus state, and the entire picture remains almost unchanged. At this time, the image is collected by moving the focus motor, and the clarity of the image is calculated and compared to determine the best focus position. However, during the rotation of the surveillance camera, the scene and object distance are constantly changing, and there will be differences in the content of adjacent frame images. Directly calculating and comparing the clarity evaluation values ​​corresponding to the images cannot locate the focus position of the focus motor when the image is clear. The focus position of the focus motor determined by this focusing method is unreliable.

[0039] At present, the industry has also provided a method for determining the focus position of the focus motor. During the movement of the surveillance camera, the focus motor is moved and two adjacent frames of images are collected. The overlapping area of ​​the two adjacent frames of images is determined using the image feature matching method, and then the clarity evaluation value of the overlapping area is calculated and compared. A clarity evaluation system is established, and the focus motor position corresponding to the image with a higher clarity evaluation value is determined as the focus position of the focus motor. Figure 2A and Figure 2B For example, in judging Figure 2A and Figure 2B When comparing the clarity of two images, it is necessary to first match the two images to determine the overlapping area. This process will take a lot of time to obtain the overlapping area of ​​the two images (such as Figure 2A and Figure 2B After that, the clarity evaluation values ​​of the overlapping areas of the two images are calculated. Figure 2B The corresponding clarity is higher than Figure 2A , you can collect Figure 2B The corresponding focus motor position is determined as the focus position of the focus motor.

[0040] However, when the above solution is adopted, the texture of the image obtained in scenes such as the surveillance camera rotating at a fast speed or the shooting scene with low lighting is poor, and the matching effect of the overlapping area of ​​adjacent frame images is poor, and thus the focus position of the focus motor cannot be determined, resulting in poor focusing effect. In addition, in order to pursue the focusing effect of the focus motor in different scenes, different scenes correspond to different image matching templates, which makes the solution highly complex and computationally intensive, and places high demands on the equipment performance of the surveillance camera. In order to make the focus position of the focus motor more accurate, some technologies may also use special hardware (such as a time delay integration (TDI) camera) to eliminate motion blur of the image, which increases the equipment cost of the surveillance camera.

[0041] In view of this, the present application proposes a focusing method, wherein a first block number represents the number of image blocks with stronger texture among multiple image blocks in a frame of image, and a second block number represents the number of image blocks remaining after excluding image blocks with weaker texture among multiple image blocks in a frame of image. The target clarity evaluation value determined according to the first block number and the second block number can reduce the interference of weaker image texture in judging image clarity, so that the clarity evaluation value determined according to the first block number and the second block number can more accurately reflect the clarity of the image, thereby being able to more accurately determine the target focus position, thereby achieving a good focusing effect of the camera.

[0042] A focusing method provided in an embodiment of the present application will be described in detail below.

[0043] The focusing method provided in the embodiment of the present application is applied to a camera, which includes: a rotating motor, a focusing motor and a zoom motor. In the embodiment of the present application, the camera is in a rotating motion state by controlling the operation of the rotating motor, and the focusing motor is controlled to move so that the camera is in a focusing state. In the embodiment of the present application, the position of the zoom motor is fixed, that is, the position of the zoom motor is not moved. In some embodiments, the camera may also include more components or different components such as a processor and a lens, which are not limited in the embodiment of the present application.

[0044] The following will take a camera as an example to illustrate the focusing method provided in the embodiment of the present application. Figure 3 FIG. 1 is a schematic flow chart of a focusing method provided in an embodiment of the present application. Figure 3 As shown, the method includes S301 to S306.

[0045] S301, the camera acquires the i-th group of images.

[0046] Among them, i is a positive integer, the i-th group of images includes N frames of images, N is a positive integer greater than or equal to 3, different frames of images correspond to different focus motor positions, each frame of image includes multiple image blocks, and each image block corresponds to a first clarity evaluation value.

[0047] In the embodiment of the present application, the camera is in a rotational motion. During the rotational motion, the focus motor in the camera starts from the current position of the focus motor and moves according to the preset sampling step length and the preset sampling step number to determine different focus motor positions, so that the camera can obtain images corresponding to each focus motor position at different focus motor positions to obtain N frames of images, that is, to obtain the i-th group of images. The embodiment of the present application does not limit the specific values ​​of the preset sampling step length and the preset sampling step number.

[0048] In some embodiments, during the rotational motion of the camera, the focus motor in the camera moves at a preset sampling step size, and each time the preset step size is moved, the camera acquires an image corresponding to the position of the focus motor until a preset number (N) of images are acquired, thus obtaining the i-th group of images.

[0049] It should be noted that the preset number can be set according to actual needs, and the embodiment of the present application does not limit the specific value of the preset number.

[0050] In other embodiments, when the camera is in a state of just being turned on, obtaining the i-th group of images is equivalent to obtaining the first group of images. The current position of the focus motor in the camera, that is, the initial position of the focus motor in the camera, can be obtained first, and the focus motor position corresponding to each frame of the N frames of images is determined according to a preset relative sampling sequence and the current position of the focus motor, and the focus motor position corresponding to each frame of the N frames of images includes the current position of the focus motor; each relative sampling parameter in the preset relative sampling sequence indicates the position difference between the current position of the focus motor and the focus motor position corresponding to each frame of the N frames of images, and when the focus motor moves to the focus motor position corresponding to each frame of the N frames of images in sequence, N frames of images are obtained, that is, the first group of images are obtained.

[0051] For example: in the embodiment of the present application, N is 5, the sampling position range of the focus motor is [0, 100], the current position of the focus motor is 50, and the preset relative sampling sequence is: {-4, -2, 0, +2, +4}. It can be determined that the focus motor position sequence corresponding to the first group of images is: {46, 48, 50, 52, 54}. The focus motor moves according to each focus motor position in the focus motor position sequence corresponding to the first group of images, and obtains image frames corresponding to each focus motor position in the focus motor position sequence corresponding to the first group of images, thereby obtaining N frames of images in the first group of images.

[0052] In a possible implementation manner, the camera divides each frame of the image in the i-th group of images into multiple image blocks.

[0053] In an embodiment of the present application, a frame of image is divided into multiple image blocks so that each frame of image includes multiple image blocks. For example, a frame of image is divided into 16*16 image blocks of the same size. Each frame of image in the image sequence to be processed is divided in the same or different manner. It can be understood that the number of multiple image blocks for each frame of image can be set according to actual needs, and the embodiment of the present application does not limit it.

[0054] As an example but not limitation, the first clarity evaluation value corresponding to each image block may be determined according to a gradient evaluation method, for example, a Brenner gradient method, a Tenengrad gradient method, and the like.

[0055] S302, determining a first sub-threshold and a second sub-threshold corresponding to each frame of the image according to first clarity evaluation values ​​corresponding to a plurality of image blocks in each frame of the image in the i-th group of images.

[0056] In S302, two clarity evaluation values ​​satisfying a preset condition may be determined from the first clarity evaluation values ​​corresponding to a plurality of image blocks in each frame of the i-th group of images as a first sub-threshold and a second sub-threshold corresponding to each frame.

[0057] In a possible implementation, the preset conditions include: when the first clarity evaluation values ​​corresponding to multiple image blocks in a frame of image are arranged in order, the first sub-threshold and the second sub-threshold corresponding to the frame of image are determined according to the first preset number and the second preset number, respectively.

[0058] Exemplarily, in one embodiment, when the first clarity evaluation values ​​corresponding to a plurality of image blocks in a frame of image are arranged in ascending order, the first sub-threshold and the second sub-threshold corresponding to the frame of image are determined according to the first preset number and the second preset number, respectively. In another embodiment, when the first clarity evaluation values ​​corresponding to a plurality of image blocks in a frame of image are arranged in descending order, the first sub-threshold and the second sub-threshold corresponding to the frame of image are determined according to the first preset number and the second preset number, respectively. In yet another embodiment, when the first clarity evaluation values ​​corresponding to a plurality of image blocks in a frame of image are arranged in ascending order, the first sub-threshold corresponding to the frame of image is determined according to the first preset number, and when the first clarity evaluation values ​​corresponding to a plurality of image blocks in a frame of image are arranged in descending order, the first sub-threshold corresponding to the frame of image is determined according to the second preset number.

[0059] For example, if a frame of image is equally divided into 16*16, then a frame of image includes 256 image blocks, and the first clarity evaluation values ​​corresponding to the 256 image blocks are arranged in ascending order, the 81st first clarity evaluation value is determined as the second sub-threshold corresponding to the frame of image, and the 175th clarity evaluation value is determined as the first sub-threshold corresponding to the frame of image. If the first clarity evaluation values ​​corresponding to the 256 image blocks are arranged in descending order, the 81st first clarity evaluation value is determined as the first sub-threshold corresponding to the frame of image, and the 175th clarity evaluation value is determined as the second sub-threshold corresponding to the frame of image.

[0060] It should be noted that, among the multiple image blocks in each frame image, the image blocks whose first clarity evaluation value is greater than the first sub-threshold have strong texture, and the image blocks whose first clarity evaluation value is less than the second sub-threshold have weak texture; the image blocks whose first clarity evaluation value is less than the first sub-threshold and greater than the second sub-threshold, that is, the image blocks whose first clarity evaluation value is between the first sub-threshold and the second sub-threshold, have average texture.

[0061] In a possible implementation, the preset number can be determined by the number of image blocks included in each frame of image and a preset ratio. As an example but not limitation, the preset ratio can be σ, σ can be 31.74%, and σ can also be selected from other values.

[0062] The first definition evaluation values ​​corresponding to the multiple image blocks in one frame of image may be arranged in ascending order, such as Figure 4 The figure shows a schematic diagram of the first sub-threshold and the second sub-threshold after the first clarity evaluation values ​​corresponding to the multiple image blocks in a frame of image provided by the embodiment of the present application are arranged in ascending order. Among them, the positions at the front σ correspond to the second sub-threshold corresponding to each frame of image, that is, the low threshold, and the positions at the rear σ correspond to the first sub-threshold corresponding to each frame of image, that is, the high threshold.

[0063] It should be noted that the first sub-threshold corresponding to each frame image is used to determine the number of image blocks with strong texture in each frame image, and the second sub-threshold corresponding to each frame image is used to determine the number of image blocks with weak texture in each frame image.

[0064] In another possible implementation, the first clarity evaluation values ​​corresponding to the multiple image blocks in each frame of image are interpolated to obtain multiple interpolated first clarity evaluation values ​​corresponding to each frame of image, and then the first sub-threshold and the second sub-threshold corresponding to each frame of image are determined according to the interpolated first clarity evaluation values ​​corresponding to each frame of image. Interpolating the first clarity evaluation values ​​corresponding to the multiple image blocks in each frame of image can improve the accuracy of the multiple image blocks in each frame of image in reflecting the distribution of image texture, thereby more accurately determining the first sub-threshold and the second sub-threshold corresponding to each frame of image.

[0065] For example, two-dimensional cubic spline interpolation is performed on the 16*16 first clarity evaluation values ​​corresponding to each frame of image to obtain 32*32 first clarity evaluation values ​​corresponding to each frame of image. According to the 32*32 first clarity evaluation values ​​corresponding to each frame of image, the first sub-threshold and the second sub-threshold corresponding to each frame of image are determined respectively.

[0066] In order to reduce the error in determining the first sub-threshold and the second sub-threshold and improve the image focusing accuracy, the ln logarithm of the 16*16 first clarity evaluation values ​​corresponding to each frame of the image can be taken to obtain the 16*16 evaluation values ​​after taking the logarithm corresponding to each frame of the image, and then two-dimensional cubic spline interpolation is performed on the 16*16 evaluation values ​​after taking the logarithm corresponding to each frame of the image to obtain the 32*32 evaluation values ​​corresponding to each frame of the image, and the 32*32 evaluation values ​​corresponding to each frame of the image are exponentially taken with e as the base to restore the original data magnitude to obtain the 32*32 first clarity evaluation values ​​corresponding to each frame of the image, and the first sub-threshold and the second sub-threshold corresponding to each frame of the image are determined respectively.

[0067] It should be noted that, in the above-mentioned embodiment, after obtaining the interpolated first clarity evaluation value corresponding to each frame of image, the implementation method of determining the first sub-threshold and the second sub-threshold corresponding to each frame of image is similar to other embodiments, such as a method that satisfies preset conditions, and this application will not go into details here.

[0068] It is understandable that before S302, the camera may first determine the first definition evaluation values ​​corresponding to the multiple image blocks in each frame of the image. In the embodiment of the present application, the first definition evaluation values ​​corresponding to the multiple image blocks in each frame of the image are determined by a gradient method (for example, a Brenner gradient method, a Tenegrad gradient method, etc.), a variance method, a peak signal-to-noise ratio, etc.

[0069] In an embodiment of the present application, first clarity evaluation values ​​corresponding to multiple image blocks in each frame image are provided when N is 5, as shown in Tables 1A-1E, wherein Table 1A shows the first clarity evaluation values ​​corresponding to multiple image blocks in the first frame image, Table 1B shows the first clarity evaluation values ​​corresponding to multiple image blocks in the second frame image, Table 1C shows the first clarity evaluation values ​​corresponding to multiple image blocks in the third frame image, Table 1D shows the first clarity evaluation values ​​corresponding to multiple image blocks in the fourth frame image, and Table 1E shows the first clarity evaluation values ​​corresponding to multiple image blocks in the fifth frame image.

[0070] Table 1A

[0071] 7.14641 8.95068 12.63927 11.08168 9.77434 6.56279 16.65017 15.06629 14.5274 6.97508 3.42603 4.54188 4.13421 2.65345 9.28226 11.51552 4.32808 4.05333 20.60562 6.15905 4.21222 5.22422 7.41638 26.9398 15.80165 5.20693 2.36447 4.197 4.18143 3.23788 6.27951 4.40294 9.16947 17.40265 11.57602 8.39053 11.5778 18.28279 15.99352 15.93732 21.28776 12.58597 3.65178 4.77464 13.31206 14.4096 14.21598 5.64753 20.81637 15.33682 10.17894 4.02749 7.07833 18.00375 17.29081 9.51434 11.63659 11.61471 6.49027 4.13995 5.37516 5.77647 12.58995 4.27022 6.68537 4.62137 6.06659 8.11853 11.97358 8.09016 9.9695 7.9849 9.36032 9.17318 3.36849 4.23659 3.88692 2.70741 5.12882 3.31421 5.38761 3.37682 17.70875 14.44759 5.40598 3.16311 8.4992 4.8508 6.36812 2.74201 1.37282 2.62524 1.84892 1.40255 1.45658 0.95741 2.38967 1.07761 1.0873 14.73061 14.20405 4.79838 23.40578 8.63855 3.43894 21.66801 3.41703 0.99905 0.88746 0.9313 0.86728 0.67335 1.30995 0.92733 0.75832 5.52407 10.36016 2.12111 5.06855 4.02859 3.9908 16.08527 2.46514 1.19965 0.84655 0.91361 0.70908 0.64547 3.2101 2.93158 3.49938 2.28709 6.20078 5.70173 3.10754 2.63894 3.29634 11.7959 3.36906 0.95635 0.68776 0.75536 0.60181 0.51758 3.70513 1.90596 1.6619 7.31345 9.91019 11.14757 8.04903 8.30515 6.39623 9.59232 2.06587 0.75239 0.82452 0.95524 1.17204 5.64588 16.84909 8.19484 9.31661 7.54597 7.61782 7.75221 6.93192 4.22382 4.14089 7.56863 1.44909 0.83541 0.64093 2.61958 4.23209 1.72969 10.88146 5.76247 1.04609 14.63844 21.72128 10.84169 10.17743 4.3866 3.80461 10.35908 2.63638 0.98665 0.89228 4.18633 6.85177 2.16904 7.38144 7.62231 2.31428 8.81854 6.43339 4.97121 8.28995 4.94995 10.22993 6.01873 2.65785 1.02566 0.63185 4.03376 7.02712 2.32293 13.67235 7.90454 1.23523 4.24981 8.08767 8.39935 10.02238 3.82995 8.30269 9.36787 8.20124 1.6159 0.71357 3.5163 7.31931 7.9911 6.88678 7.37763 3.32218 3.11349 3.76594 2.29088 8.00448 3.71048 3.9596 9.21469 2.09275 0.76134 0.56859 2.70702 6.21002 1.66834 4.36261 4.84125 4.59853 7.08123 16.75595 8.22203 8.73004 8.51511 3.75937 1.20509 0.71784 0.72868 0.62707 1.57276 4.55211 1.4822

[0072] Table 1B

[0073] 3.83322 6.6711 6.65387 10.70196 13.31577 11.83725 9.62543 6.54957 15.97981 15.12421 13.25554 5.75929 3.26519 3.91195 3.47935 2.29679 3.91532 9.15493 7.10504 5.5825 25.37974 6.82554 4.16616 5.97641 9.85511 27.4893 14.64621 4.91206 2.46305 4.42662 3.91101 3.03017 15.0542 17.18411 4.57944 18.77513 12.37638 9.58051 13.7539 19.35565 18.49704 18.47702 21.7842 11.70475 3.89042 5.00092 15.15629 12.02215 5.81744 6.82731 16.67932 17.74476 11.83136 4.88969 9.54698 24.7599 19.10768 14.08416 12.54416 14.22308 7.14701 4.94165 5.82183 6.48652 3.33141 3.21854 7.71649 7.13349 8.29568 11.53016 16.67355 12.26946 14.28044 12.46865 12.73278 10.7346 4.1749 5.78709 4.3582 3.06326 2.21088 2.48215 6.17939 4.75548 24.88982 18.10241 7.26112 6.14399 11.77048 8.08833 10.52355 3.99811 2.00123 3.6183 2.17521 1.61198 0.78503 0.9584 4.2163 1.68232 1.4163 26.50096 22.08791 11.54303 30.01993 11.02373 7.18708 30.12643 5.66076 1.36622 1.11864 1.13806 1.08209 1.30367 1.99675 1.53167 0.9069 11.1717 16.9907 4.20608 7.49012 7.29659 8.8007 27.14937 5.23011 1.73444 0.9747 1.04754 0.98289 1.09821 5.53478 5.57122 7.19308 4.36671 12.95986 9.62307 5.84231 4.86435 5.80995 23.74657 6.90238 1.15248 0.88606 0.8809 0.85521 0.92963 5.57151 2.57835 2.41922 12.73559 17.1657 18.34004 15.4948 17.13904 14.06192 17.86132 4.60325 1.3501 1.15433 1.55395 2.22121 2.30246 26.27399 15.50258 14.12695 12.90955 15.00988 16.62674 16.74162 8.73064 9.48084 12.97725 2.82599 1.27245 0.79479 5.02714 4.35439 11.82686 29.14148 10.61746 2.09534 22.28638 31.95109 20.01727 21.07907 8.24756 7.53786 21.74539 5.43712 1.09824 1.37035 7.75372 9.96119 17.8688 22.67063 33.83521 12.18573 16.15322 14.96888 10.00621 11.70821 10.80646 17.66992 10.71729 5.21107 1.41937 0.79496 7.20489 15.21034 11.15195 31.80891 14.38941 2.17712 6.52706 13.61846 12.32312 8.84381 7.39089 14.25283 14.25596 11.79648 1.77119 0.94787 6.21938 12.20872 5.68981 7.07031 12.94465 4.56749 5.64804 5.97819 5.24668 13.66068 4.69186 6.56748 15.677 2.79302 0.96828 0.6637 5.05639 7.02325 3.72305 8.00077 9.68032 5.50098 13.24402 21.30542 10.1863 13.17008 12.3136 5.41608 1.57293 0.85977 0.7694 0.61592 3.25212

[0074] Table 1C

[0075]

[0076]

[0077] Table 1D

[0078] 1.05634 1.29466 1.31623 0.97001 4.34555 5.34864 8.1531 11.61824 11.00007 9.14636 4.2877 11.39991 9.58084 10.0619 4.18267 1.71787 1.1453 1.31348 1.0346 0.93322 4.67637 5.70168 3.10179 18.04606 4.58875 4.00768 4.19377 4.51258 13.4273 9.40571 3.34064 1.18046 1.14548 1.17913 0.86914 0.88436 9.32692 2.29306 11.09102 9.8837 7.61248 9.34776 16.72023 14.52271 11.99948 11.99611 10.1636 2.40873 1.34802 1.50776 7.83206 5.30511 4.68116 6.65035 10.6285 6.31068 2.34185 6.11013 10.62665 9.34294 6.22054 8.80237 8.71402 4.82149 1.87876 1.69181 1.07762 0.75737 2.08482 3.16022 4.90356 4.07121 5.08645 8.75135 6.07505 8.27282 7.01744 6.94325 6.55719 1.88238 2.06052 1.58381 1.21987 0.83277 1.70445 2.06311 4.04681 10.75736 12.17047 4.66358 2.5048 5.74033 4.16325 2.91297 3.35771 1.13906 1.13745 0.98107 0.71865 0.73596 0.74828 2.09445 1.43862 1.16354 8.45834 14.58457 4.94768 14.12054 10.50542 3.5254 14.59575 5.84673 0.81095 0.69135 0.76477 0.89838 0.91184 1.04003 0.98598 0.92165 3.3091 12.28123 3.57313 4.04113 5.88988 2.96169 12.97911 4.25494 0.86266 0.68062 0.7742 0.87671 0.85157 2.05275 2.67701 5.93921 3.78892 4.84419 7.65375 5.35698 4.03008 2.19719 8.46712 6.29997 0.77392 0.65574 0.6294 0.8206 0.7112 2.8911 2.86701 1.46561 4.90805 14.55197 12.68514 9.62515 11.3013 6.13792 11.3519 5.79205 0.76959 0.75074 0.62045 0.79091 0.67169 8.96168 10.41969 9.12155 9.55268 11.87749 12.7191 11.48695 8.9841 6.25002 10.0122 4.33247 0.65958 0.63653 0.621 0.73349 1.83745 18.83438 11.53317 3.63556 8.73078 29.16292 15.73118 15.60129 9.12028 4.7005 10.84147 6.95362 1.03021 0.80118 0.65446 4.21612 9.51876 19.86408 8.74524 2.67039 5.68272 14.69781 8.37704 12.4562 6.28664 16.63888 8.48204 5.6426 1.53174 1.18442 0.67988 0.8072 2.83168 6.96674 17.51199 4.35588 3.58118 11.52025 10.63288 10.35141 4.73247 12.10878 10.30269 12.76907 1.49026 1.55949 3.21045 6.4761 11.19065 4.35969 11.43824 9.72282 3.90335 8.75724 4.39143 11.87416 8.08144 6.1289 11.61309 5.8741 5.46916 5.62274 47.22757 14.64785 4.744 7.14297 7.11735 11.00167 6.20035 23.46329 17.06999 11.65101 18.80929 9.86057 3.01257 1.19625

[0079] Table 1E

[0080]

[0081]

[0082] Based on the first clarity evaluation values ​​corresponding to the multiple image blocks in each frame image of the i-th group of images provided in Tables 1A-1E, executing S302 can obtain the first sub-threshold (high threshold) and the second sub-threshold (low threshold) corresponding to each frame image, as shown in Table 2.

[0083] Table 2

[0084]

[0085] The first sub-threshold (high threshold) corresponding to each frame of image may be different or the same. Similarly, the second sub-threshold (low threshold) corresponding to each frame of image may be different or the same.

[0086] S303: Determine a first threshold and a second threshold according to the first sub-threshold and the second sub-threshold respectively corresponding to each frame image in the i-th group of images.

[0087] In a possible implementation, the first threshold is a maximum value among the first sub-thresholds corresponding to each frame of image, and the second threshold is a minimum value among the second sub-thresholds corresponding to each frame of image.

[0088] For S303, the maximum value is determined from the first sub-threshold values ​​corresponding to each frame image in the i-th group of images, which is the first threshold value (i.e., the upper threshold value) corresponding to the i-th group of images, and the minimum value is determined from the second sub-threshold values ​​corresponding to each frame image, which is the second threshold value (i.e., the lower threshold value) corresponding to the i-th group of images.

[0089] Based on the data shown in Table 2, the first threshold and the second threshold of the i-th group of images are determined, as shown in Table 3.

[0090] Table 3

[0091] First threshold Second threshold 12.70 2.84

[0092] In another possible implementation, the first threshold may be an average value of first sub-thresholds corresponding to each frame of image, and the second threshold may be an average value of second sub-thresholds corresponding to each frame of image.

[0093] In another possible implementation, the first definition evaluation values ​​corresponding to all image blocks in the N frames of images are arranged in a high-to-low order or a low-to-high order, and the first threshold and the second threshold are determined by two values ​​corresponding to 1σ of the Gaussian distribution. It should be noted that 1σ of the Gaussian distribution can be 1σ on the left and 1σ on the right, wherein 1σ on the left represents 31.73% of the first definition evaluation values ​​corresponding to all image blocks, and 1σ on the right represents 68.27 of the first definition evaluation values ​​corresponding to all image blocks.

[0094] It is understandable that the first threshold and the second threshold may be determined by two values ​​corresponding to 2σ or 3σ of the Gaussian distribution, or may be determined according to other proportional values, which is not limited in the present application.

[0095] In an embodiment of the present application, the first threshold is a threshold used to filter out image blocks with strong texture in each frame of the sampled N frames of images, and the second threshold is a threshold used to filter out image blocks with weak texture in each frame of the sampled N frames of images.

[0096] S304, determining the first block number and the second block number respectively corresponding to each frame image in the i-th group of images.

[0097] Among them, the first block number is the number of image blocks in each frame image whose first clarity evaluation values ​​respectively correspond to multiple image blocks greater than the first threshold, and the second block number is the number of image blocks in each frame image whose first clarity evaluation values ​​respectively correspond to multiple image blocks in each frame image greater than the second threshold.

[0098] In a possible implementation, the first block number and the second block number corresponding to each frame of image can be determined by two counters. Specifically, the two counters are initialized, each evaluation value of the first clarity evaluation value corresponding to multiple image blocks in each frame of image is traversed, and the first clarity evaluation value corresponding to each image block is compared with the first threshold and the second clarity evaluation value threshold. When the clarity evaluation value corresponding to an image block is greater than the first threshold, the counter corresponding to the first block number is increased, and when the clarity evaluation value corresponding to an image block is greater than the second threshold, the counter corresponding to the second block number is increased.

[0099] In a possible implementation, the number of image blocks with weak textures can be eliminated from the total number of blocks corresponding to each frame of the image to determine the second number of blocks. Specifically, the number of image blocks with clarity evaluation values ​​less than the second threshold corresponding to multiple image blocks in each frame of the image can be determined first, that is, the number of image blocks with weak textures in each frame of the image can be determined, recorded as the third number of blocks, and then the third number of blocks can be subtracted from the total number of blocks corresponding to each frame of the image to determine the second number of blocks. It should be noted that the image blocks corresponding to the third number of blocks may be some white walls or solid color areas, which are regarded as weak texture areas and belong to interference areas in the image texture. These areas will affect the judgment of image clarity.

[0100] For example, based on the data in Table 1 and Table 3 above, the first number of blocks and the second number of blocks corresponding to each frame of image may be determined according to S304, as shown in Table 4.

[0101] Table 4

[0102] Image frame number 1 2 3 4 5 The first block number 30 74 40 24 71 The second block number 184 202 178 171 173

[0103] It can be understood that the first threshold and the second threshold are used to determine the first number of blocks and the second number of blocks corresponding to each frame image in the i-th group of images, thereby unifying the clarity evaluation system in the embodiment of the present application.

[0104] S305 , determining a second definition evaluation value corresponding to each frame of the image according to the first block number and the second block number corresponding to each frame of the image in the i-th group of images.

[0105] In the embodiment of the present application, the second definition evaluation value corresponding to each frame of image satisfies the following formula:

[0106]

[0107] In formula (1), represents the second clarity evaluation value corresponding to each frame of image, a represents the number of first blocks corresponding to each frame of image, and b represents the number of second blocks corresponding to each frame of image.

[0108] The above-mentioned formula for determining the clarity evaluation value is provided in an embodiment of the present application. Since the image blocks with weak textures are eliminated in the second block number, the calculated clarity evaluation value can more accurately reflect the clarity of the image and reduce the interference of weaker image texture in judging the image clarity.

[0109] Exemplarily, according to the first block number and the second block number corresponding to each frame image in the i-th group of images in Table 4 and the above formula (1), the second clarity evaluation value corresponding to each frame image as shown in Table 5 can be obtained.

[0110] Table 5

[0111] Image frame number 1 2 3 4 5 Second clarity rating 0.1630 0.3663 0.2247 0.1404 0.4104

[0112] S306 , determining a target focus position according to the second clarity evaluation value corresponding to each frame of the image in the i-th group of images.

[0113] In S306, based on the second clarity evaluation value corresponding to each frame image, the maximum value of the second clarity evaluation value can be determined, the image corresponding to the maximum value of the second clarity evaluation value is the clearest image in the i-th group of images, and the focus motor position corresponding to the image is the target focus position, which is the clearest position among the focus motor positions corresponding to each frame image in the i-th group of images, and the focus motor can be controlled to move to the target focus position.

[0114] In a possible implementation, a maximum value of the second clarity evaluation values ​​is determined from the second clarity evaluation values ​​corresponding to each frame of image, and a focus motor position corresponding to the maximum value of the second clarity evaluation values ​​is determined as a target focus position.

[0115] Since the second clarity evaluation value represents the clarity of each frame of image, the image corresponding to the maximum value of the second clarity evaluation value is the clearest image among the N frames of image, and the position of the focus motor corresponding to the image is the target focus position.

[0116] It should be noted that since the movement of the focus motor has a moving boundary (for example: the boundary 0 or 100 of the sampling position range), when the target focus position is the moving boundary position of the focus motor, the target focus position is considered to be the clearest position of the camera to capture the picture, and the focusing process is exited.

[0117] In some embodiments, when the target focus position is a position other than the moving boundary position of the focus motor, the target focus position may not be the clearest position of the image captured by the camera. In this case, the clearest position of the image captured by the camera needs to be re-determined.

[0118] Optionally, in some embodiments, when the image corresponding to the target clarity evaluation value is an image other than the first frame image and the last frame image in the i-th group of images, the focus motor position corresponding to the image corresponding to the target clarity evaluation value is determined as the target focus position. It can be understood that in the i-th group of images, each frame image corresponds to a focus motor position, the above-mentioned target focus position is the focus motor position corresponding to the clearest image in the i-th group of images, and the target focus position is the focus motor position corresponding to the image frame other than the first frame image and the last frame image in the i-th group of images, that is, the target focus position is the internal position of the focus motor position corresponding to the i-th group of images (i.e., the focus motor position corresponding to the image frame other than the first frame image and the last frame image in the i-th group of images), rather than the edge position (i.e., the focus motor position corresponding to the first frame image and the last frame image). After executing S306, sampling can be stopped, and it is considered that the target focus position is the focus motor position that makes the picture clearest.

[0119] Optionally, in other embodiments, when the image corresponding to the target clarity evaluation value is the first frame image or the last frame image in the i-th group of images, the focus motor position corresponding to the image corresponding to the target clarity evaluation value may not be the optimal focus position, and sampling is required again to obtain the i+1-th group of images, so as to determine the updated target clarity evaluation value from the i+1-th group of images, and the focus motor position corresponding to the updated target clarity evaluation value is determined as the target focus position.

[0120] Exemplarily, the focusing method provided in the embodiment of the present application further includes the following steps:

[0121] Step 1. When the image corresponding to the target clarity evaluation value is the first frame image or the last frame image in the i-th group of images, the focus motor position corresponding to any frame image in the i-th group of images except the first frame image or the last frame image is determined as the focus motor position corresponding to the first frame image in the i+1-th group of images.

[0122] Among them, the focus motor position corresponding to each frame image in the i+1th group of images in step 1 includes the target focus position determined in the i-th group, and the focus motor position corresponding to each frame image in the i-th group of images and the i+1th group of images partially overlaps.

[0123] Exemplarily, when the focus motor positions corresponding to each frame image in the i-th group of images include: 46, 48, 50, 52, 54, the focus motor positions corresponding to the first frame image and the last frame image in the i-th group of images are 46 and 54 respectively, and the focus motor position corresponding to any frame image other than the first frame image or the last frame image in the i-th group of images is 48, 50, 52, then the focus motor position corresponding to an image in the i+1-th group of images is any one of 48, 50, 52.

[0124] Preferably, in an embodiment of the present application, when the image corresponding to the target clarity evaluation value is the first frame image or the last frame image in the i-th group of images, the focus motor position corresponding to a frame image adjacent to the first frame image or the last frame image in the i-th group of images is determined as the focus motor position corresponding to the first frame image in the i+1-th group of images. For example, if the image corresponding to the target clarity evaluation value is the last frame image in the i-th group of images, and the focus motor position corresponding to the last frame image is 54, then 52 (adjacent to 54) is determined as the focus motor position corresponding to the first frame image in the i-th group. If the image corresponding to the target clarity evaluation value is the first frame image in the i-th group of images, and the focus motor position corresponding to the last frame image is 46, then 48 (adjacent to 54) is determined as the focus motor position corresponding to the first frame image in the i-th group.

[0125] Step 2: In the candidate direction, based on the focus motor position corresponding to the first frame image in the i+1th group of images, the preset sampling step length and the preset sampling step number, determine the focus motor position corresponding to each frame image in the i+1th group of images.

[0126] Among them, the candidate direction is the direction from the focus motor position corresponding to the first frame image in the i+1th group of images to the first position, and the first position is the focus motor position corresponding to the image corresponding to the target clarity evaluation value in the i-th group of images.

[0127] Exemplarily, if the focus position corresponding to the target clarity evaluation value in the i-th group of images is 54, the focus motor position corresponding to the first frame image in the i+1-th group of images is 52, and the candidate direction is the direction of increasing position parameters (the direction corresponding to 52 to 54 is the direction of increasing position parameters), based on the focus motor position 52 corresponding to the first frame image in the i+1-th group of images, the preset sampling step size 2, and the preset sampling step number 4, it is determined that the focus motor positions corresponding to each frame image in the i+1-th group of images are: 52, 54, 56, 58, 60.

[0128] Exemplarily, if the focus position corresponding to the target clarity evaluation value in the i-th group of images is 46, the focus motor position corresponding to the first frame image in the i+1-th group of images is 48, and the candidate direction is the direction in which the position parameter decreases (the direction corresponding to from 48 to 46 is the direction in which the position parameter decreases), based on the focus motor position 48 corresponding to the first frame image in the i+1-th group of images, the preset sampling step size 2, and the preset sampling step number 4, it is determined that the focus motor positions corresponding to each frame image in the i+1-th group of images are: 48, 46, 44, 42, and 40.

[0129] It can be understood that in the above two examples, the focus position corresponding to the target clarity evaluation value in the i-th group of images is the second position of the focus motor position corresponding to each frame image in the i+1-th group of images, and the starting focus motor position in the i+1-th group of images (the focus motor position corresponding to the first frame image) is adjacent to the focus motor position corresponding to the target clarity evaluation value in the i-th group of images. That is to say, the focus position corresponding to the target clarity evaluation value in the i-th group of images is not the focus motor position corresponding to the first frame image or the last frame image in the i+1-th group of images, and the focus position corresponding to the target clarity evaluation value in the i-th group of images is the focus motor position in the i+1-th group of images except the focus motor position corresponding to the first frame image or the last frame image.

[0130] In the embodiment of the present application, the determination of candidate focus positions is described by taking the camera in a stationary state and sampling three times to determine candidate focus positions. It can be understood that the focus motor position corresponding to the i-th group of images and the focus motor position corresponding to the i+1-th group of images can both be candidate focus positions. FIG. 5A to FIG. 5C As shown, Figure 5A A schematic diagram of determining a candidate focus position for the first time provided in an embodiment of the present application, Figure 5B A schematic diagram of determining a candidate focus position for the second time provided in an embodiment of the present application, Figure 5C A schematic diagram of determining a candidate focus position for the third time provided in an embodiment of the present application.

[0131] exist Figure 5A In the figure, the position indicated by the arrow is the current position of the focus motor. It can be understood that the current position of the focus motor is the position of the focus motor when the camera is turned on and not shooting. With the current position of the focus motor as the center, three candidate focus positions are determined on both sides of the current position of the focus motor according to the sampling step, for a total of 7 candidate positions. It should be noted that Figure 5A It can be seen that the clarity evaluation value corresponding to the last frame image is the largest.

[0132] Figure 5B Among the 7 candidate positions in Figure 5A The focus motor position corresponding to the sixth frame image is taken as the starting position, and the focus motor position corresponding to the last frame image is determined in sequence according to the preset sampling step length and the preset sampling step number. Figure 5B There are 7 candidate positions in . Among them, the position indicated by the arrow corresponds to Figure 5A The focus motor position corresponding to the mid-to-end frame image.

[0133] Figure 5C Among the 7 candidate positions, it can be understood that Figure 5BThe 7 candidate positions in are all moved 6 sampling steps (i.e., sampling range) toward the focus motor position corresponding to the last frame image (i.e., to the right). At this time, Figure 5B The clearest focus motor position (i.e. the rightmost position) determined in Figure 5C In order to avoid oscillation, the first candidate position of the 7 candidate positions is moved to the focus motor position corresponding to the first frame image by 1 sampling step. In other words, Figure 5B The 7 candidate positions in are all moved 5 sampling steps toward the focus motor position corresponding to the last frame image (i.e., to the right) to determine Figure 5C There are 7 candidate positions in . Among them, the position indicated by the arrow corresponds to Figure 5B The focus motor position corresponding to the mid-to-end frame image.

[0134] Step 3, acquiring the i+1th group of images according to the focus motor position corresponding to each frame of the image in the i+1th group of images, until the target focus position is determined.

[0135] Obviously, in Figure 5C Among the 7 candidate positions, the focus position corresponding to the maximum sharpness evaluation value is the third one among the 7 candidate positions. Figure 5C The focus positions except the first candidate position and the last candidate position among the 7 candidate positions can be used as the focus positions that make the picture clearest, and the focusing process is exited.

[0136] In an embodiment of the present application, according to the focus motor position corresponding to each frame image in the i+1th group of images, after obtaining the i+1th group of images, the steps corresponding to S302 to S306 can be executed again until the target focus position is determined.

[0137] Of course, after acquiring the (i+1)th group of images in step 3, other methods for determining the target focus position may also be executed until the target focus position is determined, and this application does not limit this.

[0138] In an embodiment of the present application, the above steps 1 to 3 and steps S302 to S306 can be executed repeatedly until the target focus position is determined when the image corresponding to the focus motor position corresponding to the target clarity evaluation value is an image other than the first frame image and the last frame image in the i+1th group of images.

[0139] It should be noted that, considering that the movement of the focus motor will cause changes in image clarity, thereby causing image oscillation, the embodiment of the present application redetermines the target clarity evaluation value from the i+1th group of images including the first position, and thereby determines the focus motor position corresponding to the image corresponding to the redetermined target clarity evaluation value as the target focus position, which can reduce image oscillation during the focusing process, make the camera's focusing process smoother, and achieve stable focus during camera movement.

[0140] In the focusing method provided by the embodiment of the present application, the first block number represents the number of image blocks with strong texture among multiple image blocks in a frame of image, and the second block number represents the number of image blocks remaining after excluding image blocks with weak texture among multiple image blocks in a frame of image. The target clarity evaluation value determined according to the first block number and the second block number can reduce the interference of weak image texture in judging image clarity, so that the clarity evaluation value determined according to the first block number and the second block number can more accurately reflect the clarity of the image, and can also more accurately determine the target focus position, so that the focusing effect of the camera is good. In addition, compared with the prior art, the focusing method provided by the present application does not require matching of image overlapping areas, the implementation process is relatively simple, the algorithm runs faster, and does not require high performance of the equipment. When shooting in scenes with poor imaging quality, the focus position of the focus motor can also be accurately determined, so that the camera can shoot clear images, and the scene adaptability is strong.

[0141] It should be understood 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.

[0142] Corresponding to the focusing method of the above embodiment, Figure 6 A structural block diagram of a focusing device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0143] Reference Figure 6 The focusing device 600 includes: an acquisition unit 610 and a determination unit 620, wherein:

[0144] An acquisition unit 610 is used to acquire an i-th group of images including N frames of images, where i is a positive integer, N is a positive integer greater than or equal to 3, different frames of images correspond to different focus motor positions, each frame of image includes a plurality of image blocks, and each image block corresponds to a first clarity evaluation value;

[0145] A determination unit 620 is configured to determine a first block number and a second block number respectively corresponding to each frame of image, wherein the first block number is the number of image blocks with first definition evaluation values ​​greater than a first threshold value respectively corresponding to a plurality of image blocks in each frame of image, and the second block number is the number of image blocks with first definition evaluation values ​​greater than a second threshold value respectively corresponding to a plurality of image blocks in each frame of image;

[0146] The determination unit 620 is further configured to determine a second definition evaluation value corresponding to each frame of the image according to the first number of blocks and the second number of blocks corresponding to each frame of the image, wherein each frame of the image corresponds to one second definition evaluation value;

[0147] The determination unit 620 is further configured to determine a target focus position according to the second clarity evaluation value corresponding to each frame of image.

[0148] Optionally, in a possible implementation, the determination unit 620 is further used to determine a first sub-threshold and a second sub-threshold corresponding to each frame of image according to first clarity evaluation values ​​corresponding to multiple image blocks in each frame of image; and to determine the threshold and the second threshold according to the first sub-threshold and the second sub-threshold corresponding to each frame of image.

[0149] Optionally, in a possible implementation, the first threshold is a maximum value among the first sub-thresholds corresponding to each frame of image, and the second threshold is a minimum value among the second sub-thresholds corresponding to each frame of image.

[0150] Optionally, in a possible implementation, the second definition evaluation value corresponding to each frame of image satisfies the following formula:

[0151]

[0152] in, represents the second clarity evaluation value corresponding to each frame of image, a represents the number of first blocks corresponding to each frame of image, and b represents the number of second blocks corresponding to each frame of image.

[0153] Optionally, in a possible implementation, the determination unit 620 is further used to determine a target clarity evaluation value from the second clarity evaluation values ​​corresponding to each frame of image, the target clarity evaluation value being the maximum value of the second clarity evaluation values ​​corresponding to each frame of image; and the focus motor position corresponding to the image corresponding to the target clarity evaluation value is determined as the target focus position.

[0154] Optionally, in a possible implementation, the determination unit 620 is further used to: determine a target clarity evaluation value from the second clarity evaluation values ​​corresponding to each frame of image, the target clarity evaluation value being the maximum value of the second clarity evaluation values ​​corresponding to each frame of image; when the image corresponding to the target clarity evaluation value is an image other than the first frame image and the last frame image in the i-th group of images, the focus motor position corresponding to the image corresponding to the target clarity evaluation value is determined as the target focus position.

[0155] Optionally, in a possible implementation manner, the determining unit 620 is further configured to:

[0156] When the image corresponding to the target definition evaluation value is the first frame image or the last frame image in the i-th group of images, the focus motor position corresponding to any frame image except the first frame image and the last frame image in the i-th group of images is determined as the focus motor position corresponding to the first frame image in the (i+1)-th group of images;

[0157] In the candidate direction, based on the focus motor position corresponding to the first frame image in the i+1th group of images, the preset sampling step length and the preset sampling step number, determine the focus motor position corresponding to each frame image in the i+1th group of images, the candidate direction is the direction corresponding to the focus motor position corresponding to the first frame image in the i+1th group of images to the first position, and the first position is the focus motor position corresponding to the image corresponding to the target clarity evaluation value in the i-th group of images;

[0158] According to the focus motor position corresponding to each frame of the image in the (i+1) group of images, the (i+1) group of images is acquired until the target focus position is determined.

[0159] Optionally, in a possible implementation, when i is 1, the acquiring unit 610 is further configured to:

[0160] According to a preset relative sampling sequence and a current position of a focus motor, the focus motor position corresponding to each frame in the i-th group of images is determined in sequence, wherein each relative sampling parameter in the preset relative sampling sequence indicates a position difference between the current position of the focus motor and the focus motor position corresponding to each frame in the i-th group of images;

[0161] When the focus motor is sequentially moved to the focus motor position corresponding to each frame image in the i-th group of images, the i-th group of images is acquired.

[0162] In the focusing device provided by the embodiment of the present application, the first block number represents the number of image blocks with strong texture among multiple image blocks in a frame of image, and the second block number represents the number of image blocks remaining after excluding image blocks with weak texture among multiple image blocks in a frame of image. The target clarity evaluation value determined according to the first block number and the second block number can reduce the interference of weak image texture in judging image clarity, so that the clarity evaluation value determined according to the first block number and the second block number can more accurately reflect the clarity of the image, and can also more accurately determine the target focus position, so that the focusing effect of the camera is good. In addition, compared with the prior art, the focusing method provided by the present application does not require matching of image overlapping areas, the implementation process is relatively simple, the algorithm runs faster, and does not require high performance of the equipment. When shooting in scenes with poor imaging quality, the focus position of the focus motor can also be accurately determined, so that the camera can shoot clear images, and the scene adaptability is strong.

[0163] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0164] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0165] The embodiment of the present application also provides a camera, Figure 7 is a schematic diagram of the structure of a camera provided in an embodiment of the present application, such as Figure 7 As shown, the camera provided in this embodiment includes: a memory 71 and a processor 72, the memory 71 is used to store a computer program 73; the processor 72 is used to execute the method described in the above method embodiment when calling the computer program 73.

[0166] The camera provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0167] An embodiment of the present application further 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 steps in the above-mentioned method embodiments can be implemented.

[0168] An embodiment of the present application provides a computer program product. When the computer program product runs on a camera, the camera can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0169] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0170] 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.

[0171] 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.

[0172] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. 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.

[0173] 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.

[0174] 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. A focusing method, characterized in that: include: Acquire an i-th group of images including N frames of images, where i is a positive integer, N is a positive integer greater than or equal to 3, different frames of images correspond to different focus motor positions, each frame of image includes a plurality of image blocks, and each image block corresponds to a first clarity evaluation value; Determine a first number of blocks and a second number of blocks respectively corresponding to each frame of image, wherein the first number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a first threshold value respectively corresponding to a plurality of image blocks in each frame of image, and the second number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a second threshold value respectively corresponding to a plurality of image blocks in each frame of image; Determine a second definition evaluation value corresponding to each frame of image according to the first block number and the second block number corresponding to each frame of image, wherein each frame of image corresponds to a second definition evaluation value; The target focus position is determined according to the second clarity evaluation value corresponding to each frame of image.

2. The method according to claim 1, characterized in that The method further comprises: Determine a first sub-threshold and a second sub-threshold corresponding to each frame of image according to first definition evaluation values ​​corresponding to a plurality of image blocks in each frame of image; The first threshold and the second threshold are determined according to the first sub-threshold and the second sub-threshold respectively corresponding to each frame of image.

3. The method according to claim 2, characterized in that The first threshold is the maximum value of the first sub-thresholds corresponding to each frame of image, and the second threshold is the minimum value of the second sub-thresholds corresponding to each frame of image.

4. The method according to claim 1, characterized in that The second definition evaluation value corresponding to each frame of image satisfies the following formula: in, represents the second clarity evaluation value corresponding to each frame of image, a represents the number of first blocks corresponding to each frame of image, and b represents the number of second blocks corresponding to each frame of image.

5. The method according to claim 1, characterized in that The step of determining the target focus position according to the second definition evaluation value corresponding to each frame of the image comprises: Determining a target clarity evaluation value from the second clarity evaluation values ​​corresponding to each frame of image, wherein the target clarity evaluation value is the maximum value of the second clarity evaluation values ​​corresponding to each frame of image; The focus motor position corresponding to the image corresponding to the target clarity evaluation value is determined as the target focus position.

6. The focusing method according to claim 1, wherein: The step of determining the target focus position according to the second definition evaluation value corresponding to each frame of the image comprises: Determining a target clarity evaluation value from the second clarity evaluation values ​​corresponding to each frame of image, wherein the target clarity evaluation value is the maximum value of the second clarity evaluation values ​​corresponding to each frame of image; When the image corresponding to the target clarity evaluation value is an image other than the first frame image and the last frame image in the i-th group of images, the focus motor position corresponding to the image corresponding to the target clarity evaluation value is determined as the target focus position.

7. The focusing method according to claim 6, wherein: The method further comprises: In a case where the image corresponding to the target definition evaluation value is the first frame image or the last frame image in the i-th group of images, the focus motor position corresponding to any frame image except the first frame image and the last frame image in the i-th group of images is determined as the focus motor position corresponding to the first frame image in the (i+1)-th group of images; In the candidate direction, based on the focus motor position corresponding to the first frame image in the i+1th group of images, a preset sampling step length and a preset sampling step number, determine the focus motor position corresponding to each frame image in the i+1th group of images, the candidate direction is the direction corresponding to the focus motor position corresponding to the first frame image in the i+1th group of images to the first position, and the first position is the focus motor position corresponding to the image corresponding to the target clarity evaluation value in the i-th group of images; The i+1th group of images is acquired according to the focus motor position corresponding to each frame of the image in the i+1th group of images until the target focus position is determined.

8. The focusing method according to claim 1 or 7, characterized in that: When i is 1, acquiring the i-th group of images including N frames of images includes: Determine the focus motor position corresponding to each frame in the i-th group of images in sequence according to a preset relative sampling sequence and a current position of the focus motor, wherein each relative sampling parameter in the preset relative sampling sequence indicates a position difference between the current position of the focus motor and the focus motor position corresponding to each frame in the i-th group of images; When the focus motor is sequentially moved to the focus motor position corresponding to each frame of the i-th group of images, the i-th group of images is acquired.

9. A focusing device, characterized in that: include: an acquisition unit, configured to acquire an i-th group of images including N frames of images, where i is a positive integer, and N is a positive integer greater than or equal to 3, where different frames of images correspond to different focus motor positions, and each frame of image includes a plurality of image blocks, and each image block corresponds to a first clarity evaluation value; a determining unit, configured to determine a first number of blocks and a second number of blocks respectively corresponding to each frame of image, wherein the first number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a first threshold value respectively corresponding to a plurality of image blocks in each frame of image, and the second number of blocks is the number of image blocks with first clarity evaluation values ​​greater than a second threshold value respectively corresponding to a plurality of image blocks in each frame of image; The determination unit is further used to determine the second definition evaluation value corresponding to each frame of the image according to the first block number and the second block number corresponding to each frame of the image, and each frame of the image corresponds to a second definition evaluation value; The determination unit is further used to determine the target focus position according to the second clarity evaluation value corresponding to each frame of image.

10. A camera comprising 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 focusing method according to any one of claims 1 to 8 is implemented.

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