Method and device for controlling focusing of camera module, medium and equipment

By acquiring the images of the camera module at different focus depths, establishing a mapping relationship between the focus depth and the dispersion value, the motor position and the focus depth, quickly determining the target motor position for focusing, solving the problem of low testing efficiency caused by the cumbersome focus process in the prior art, and achieving more efficient focus and testing.

CN119653232AActive Publication Date: 2025-03-18KUNSHAN Q TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411713527.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-18
Estimated Expiration
2044-11-27

AI Technical Summary

Technical Problem

When testing camera modules in the prior art, the overall testing efficiency is affected due to the cumbersome focus process.

Method used

By acquiring the first image of the camera module at different focusing depths, the first mapping relationship between the focus depth and the dispersion value is determined; then, the second mapping relationship between the motor position and the focus depth is determined; finally, the third mapping relationship between the motor position and the dispersion value is determined based on the first and second mapping relationships, and the target motor position is quickly determined for focusing.

Benefits of technology

There is no need to perform special process processing on the image sensor, shortening process processing and focusing time, and improving focus efficiency and testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119653232A_ABST
    Figure CN119653232A_ABST
Patent Text Reader

Abstract

The invention provides a method for controlling the focusing of a camera module, and the method comprises the steps: obtaining a first image of the camera module under different focusing depths, and determining a first mapping relation between the focusing depth and a dispersion value according to the first image; determining a second image of the camera module at different target motor positions, and determining a second mapping relation between the motor position of the camera module and the focusing depth according to the second image; determining a third mapping relation between the motor position and the dispersion value according to the first mapping relation and the second mapping relation; acquiring a target dispersion value of the camera module, determining a target motor position of the camera module according to the target dispersion value and the third mapping relation, and focusing the camera module based on the target motor position; thus, when the target motor position of the camera module is determined, special process processing does not need to be carried out on the image sensor, the process processing time can be shortened, the focusing time is further shortened, and the focusing efficiency and the testing efficiency of the camera module are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of camera module testing technology, and in particular to a method, device, medium and equipment for controlling the focus of a camera module. Background Art

[0002] Before leaving the factory, the camera module needs to be tested for various items after the focus is completed. The current popular focusing method is to calculate the focal length through PD (phase difference) technology. However, this method requires special processing of the image sensor (such as masking the sensor, setting PD points, etc.), which will not only increase the hardware cost of the sensor, but also increase the overall testing process and testing time.

[0003] Based on this, there is an urgent need for a method for controlling the focus of a camera module to improve the overall testing efficiency of the camera module. Summary of the invention

[0004] In response to the problems existing in the prior art, the embodiments of the present invention provide a method, device, medium and equipment for controlling the focus of a camera module, so as to solve or partially solve the technical problem in the prior art that when testing the camera module, the overall test efficiency is affected due to the complicated focusing process.

[0005] A first aspect of the present invention provides a method for controlling the focus of a camera module, the method comprising:

[0006] Acquire a first image of the camera module at different focus depths, and determine a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor;

[0007] Determine a second image of the camera module at different target motor positions, and determine a second mapping relationship between the motor position of the camera module and the focus depth according to the second image;

[0008] Determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship;

[0009] Obtain a target dispersion value of the camera module, determine a target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module.

[0010] In the above solution, each focus depth corresponds to a first image; and determining a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image includes:

[0011] For each first image, obtain a target area of ​​the first image; perform RGB channel separation on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; use a preset convolution kernel to convolve the R channel image to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; use a preset threshold to filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean;

[0012] A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

[0013] In the above solution, the dispersion value includes a color ratio value of each channel image; and determining the dispersion value of each channel image according to the first mean value, the second mean value and the third mean value includes:

[0014] Determine the color ratio value of the R channel image relative to the B channel image according to the formula R′ / B′;

[0015] Determine the color ratio value of the R channel image relative to the G channel image according to the formula R′ / G′;

[0016] The color ratio value of the B channel image relative to the G channel image is determined according to the formula B′ / G′.

[0017] In the above solution, after determining the first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image, the method further includes:

[0018] Using the first mapping relationship to fit a first function between the depth of focus and the dispersion value;

[0019] The target motor position includes a first motor position and a second motor position; and determining a second mapping relationship between the motor position of the camera module and the focus depth according to the second image includes:

[0020] respectively determining a first dispersion value of the second image corresponding to the first motor position, and determining a second dispersion value of the second image corresponding to the second motor position;

[0021] determining a first focusing depth corresponding to the first dispersion value based on the first function, and determining a second focusing depth corresponding to the second dispersion value based on the first function;

[0022] fitting a second function between focus depth and motor position based on the first dispersion value, the second dispersion value, the first focus depth, and the second focus depth;

[0023] For each remaining motor position within the motor travel range, determining a focus depth corresponding to each remaining motor position according to the second function;

[0024] A second mapping relationship between motor position and focus depth is created according to the focus depth corresponding to each remaining motor position, the first motor position, the first focus depth, the second motor position, and the second focus depth.

[0025] In the above solution, the determining of the third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship includes:

[0026] If the focusing depths in the first mapping relationship and the second mapping relationship are consistent, based on the focusing depths in the first mapping relationship and the second mapping relationship, the dispersion value in the first mapping relationship and the motor position in the second mapping relationship are matched one-to-one to form a third mapping relationship between the motor position of the camera module and the dispersion value.

[0027] In the above solution, determining the target motor position of the camera module according to the target dispersion value and the third mapping relationship includes:

[0028] Fitting a third function between the dispersion value and the motor position according to the third mapping relationship;

[0029] Substitute the target dispersion value into the third function to obtain the target motor position of the camera module.

[0030] A second aspect of the present invention provides a device for controlling the focus of a camera module, the device comprising:

[0031] A first determination unit is used to obtain a first image of the camera module at different focus depths, and determine a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor;

[0032] A second determining unit, used to determine a second image of the camera module at different target motor positions, and determine a second mapping relationship between the motor position of the camera module and the focus depth according to the second image;

[0033] A third determining unit, configured to determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship;

[0034] The fourth determination unit is used to obtain the target dispersion value of the camera module, determine the target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module.

[0035] In the above solution, each focus depth corresponds to a first image; and the first determination unit is specifically used for:

[0036] For each first image, obtain a target area of ​​the first image; perform RGB channel separation on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; use a preset convolution kernel to convolve the R channel image to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; use a preset threshold to filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean;

[0037] A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

[0038] According to a third aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.

[0039] According to a fourth aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any one of the methods described in the first aspect are implemented.

[0040] The present invention provides a method, device, medium and equipment for controlling the focus of a camera module, the method comprising: acquiring a first image of the camera module at different focus depths, determining a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens and the image sensor of the camera module; determining a second image of the camera module at different target motor positions, determining a second mapping relationship between the motor position of the camera module and the focus depth according to the second image; determining the second mapping relationship between the motor position of the camera module and the focus depth according to the first mapping relationship and the second mapping relationship; a third mapping relationship between the motor position of the camera module and the dispersion value; obtaining the target dispersion value of the camera module, determining the target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focusing the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module; in this way, when determining the target motor position of the camera module, there is no need to perform special process processing on the image sensor sensor, thereby shortening the process processing time, shortening the focusing time, improving the focusing efficiency of the camera module, and thus improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0042] Figure 1 A schematic flow chart of a method for controlling the focus of a camera module according to an embodiment of the present invention is shown;

[0043] Figure 2 A schematic diagram of the structure of a device for controlling the focus of a camera module according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0044] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0045] The present invention provides a method for controlling the focus of a camera module, such as Figure 1 As shown, the method mainly includes the following steps:

[0046] S110, obtaining a first image of the camera module at different focusing depths, and determining a first mapping relationship between the focusing depth of the camera module and the dispersion value of the first image according to the first image; the focusing depth is the distance between the lens of the camera module and the image sensor.

[0047] In order to better understand the technical solution of the present application, the overall technical idea is first introduced here. For a certain type of camera module, before mass production (the camera module is still in an incompletely assembled state at this time), the focus depth is adjustable, so the first mapping relationship between the focus depth and the image dispersion value can be determined.

[0048] Then in the mass production stage, since the camera module has been assembled at this stage, the focus depth is not adjustable at this stage, while the motor position is adjustable, so the second mapping relationship between the motor position and the focus depth can be determined at this stage.

[0049] Then, a third mapping relationship between the dispersion value and the motor position is determined according to the first mapping relationship and the second mapping relationship, the target motor position is quickly determined according to the third mapping relationship, and the focus of the camera module is controlled based on the target motor position.

[0050] Specifically, before the mass production stage of the camera module, a light source with a fixed color temperature and a fixed illumination can be set at a preset position, and a checkerboard chart can be set below the light source. Then adjust the focus depth, and at each focus depth, control the camera module to shoot the checkerboard chart to obtain the corresponding first image. Among them, the focus depth is the distance between the image sensor and the lens; when adjusting the focus depth, a laser rangefinder can be used to measure the focus depth. Then, according to the first image, a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image is determined.

[0051] In one implementation, each focus depth corresponds to a first image; determining a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image includes:

[0052] For each first image, obtain a target area of ​​the first image; perform RGB channel separation on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; use a preset convolution kernel to convolve the R channel image to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; use a preset threshold to filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean;

[0053] A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

[0054] It is understandable that, because light will be refracted when passing through the lens and the refractive index of each wavelength is different, after the light passes through the lens, due to the different refractive index, the position reached by each wavelength at different focus depths is also different. Therefore, at different focus depths, the blur degree of the black and white boundary of the checkerboard in the first image is also different. If the first image is more blurred, the black and white boundary in the first image is less clear, then when the convolution kernel is used to convolve the first image, the convolution value corresponding to the unclear position is also smaller.

[0055] Therefore, the present invention first determines the region of interest (ROI) of each first image, and uses the ROI region as the target region to perform RGB channel separation to obtain corresponding R channel image, G channel image and B channel image.

[0056] Taking the R channel as an example, the R channel image is convolved using the Sobel convolution kernel to obtain multiple first convolution values. As mentioned above, the smaller the convolution value, the less clear the boundary in the image. The first convolution value greater than the preset threshold is selected from the multiple first convolution values ​​as the first target value. The preset threshold can be set based on experience or can be the average of multiple first convolution values.

[0057] The B channel image and the G channel image can be processed in the same manner as the R channel image, and finally a plurality of first target values, a plurality of second target values ​​and a plurality of third target values ​​are obtained, which will not be described in detail here.

[0058] Then determine a first mean R′ of multiple first target values, a second mean G′ of multiple second target values, and a third mean B′ of multiple third target values; and determine the dispersion value of each channel image according to the first mean, the second mean, and the third mean.

[0059] In one embodiment, the dispersion value includes a color ratio value of each channel image; determining the dispersion value of each channel image according to the first mean, the second mean, and the third mean includes:

[0060] Determine the color ratio value of the R channel image relative to the B channel image according to the formula R′ / B′;

[0061] Determine the color ratio value of the R channel image relative to the G channel image according to the formula R′ / G′;

[0062] The color ratio value of the B channel image relative to the G channel image is determined according to the formula B′ / G′.

[0063] After processing the first images at each focus depth in this way, the dispersion value of each first image at each focus depth can be obtained, and then a first mapping relationship between the focus depth and the dispersion value can be established.

[0064] S111, determining a second image of the camera module under different target motor positions, and determining a second mapping relationship between the motor position of the camera module and the focusing depth according to the second image.

[0065] In one embodiment, after determining a first mapping relationship between a focus depth of the camera module and a dispersion value of the first image according to the first image, the method further includes:

[0066] Fitting a first function between the focus depth and the dispersion value using a first mapping relationship;

[0067] The target motor position includes a first motor position and a second motor position; and determining a second mapping relationship between the motor position of the camera module and the focus depth according to the second image includes:

[0068] respectively determining a first dispersion value of the second image corresponding to the first motor position, and determining a second dispersion value of the second image corresponding to the second motor position;

[0069] Determine a first focusing depth corresponding to the first dispersion value based on the first function, and determine a second focusing depth corresponding to the second dispersion value based on the first function;

[0070] fitting a second function between the focus depth and the motor position based on the first dispersion value, the second dispersion value, the first focus depth, and the second focus depth;

[0071] For each remaining motor position within the motor travel range, determining a focal depth corresponding to each remaining motor position according to a second function;

[0072] A second mapping relationship between the motor position and the focus depth is created according to the focus depth corresponding to each remaining motor position, the first motor position, the first focus depth, the second motor position and the second focus depth.

[0073] Specifically, after the first mapping relationship between the focus depth and the dispersion value is determined, it is necessary to fit the first function between the focus depth and the dispersion value based on the first mapping relationship.

[0074] When fitting the first function, the fitting function in an open database (such as OpenCV) can be called to fit the dispersion value and the focus depth. Since each channel image includes three color ratio values, but the relationship between the color ratio value of each channel image and the focus depth is a linear relationship, the color ratio value of one channel image is selected to fit the focus depth to obtain the first function; the color ratio values ​​of the three channel images can also be fitted with the focus depth to obtain the first function; no limit is set here.

[0075] When the camera module enters the mass production stage, due to the large number of camera modules, in order to save testing time, the second image of the camera module under different target motor positions is determined for each camera module. Among them, the target motor position only includes two motor positions, namely the first motor position and the second motor position. For example, if the motor travel range is -100 code to 100 code, then the first motor position can be -100 code, and the second motor position can be 100 code.

[0076] After acquiring the second image at the first motor position and the second image at the second motor position, the first dispersion value of the second image at the first motor position and the second dispersion value of the second image at the second motor position are determined in the same manner as in step S110.

[0077] Then, the first dispersion value is substituted into the first function to obtain the first focus depth, and the second dispersion value is substituted into the first function to obtain the second focus depth.

[0078] A second function between the focus depth and the motor position is fitted according to the first dispersion value, the first focus depth, the second dispersion value, and the second focus depth.

[0079] However, during the focus search process, the motor is controlled to move in sequence along the preset step length within the travel range (for example, the preset step length is 1 code, and it moves 1 code at a time). In addition to -100 code and 100 code, there are multiple remaining motor positions. For each remaining motor position, it can be substituted into the second function to obtain the corresponding focus depth.

[0080] In this way, the first motor position and the corresponding first focal depth, the second motor position and the corresponding second focal depth, and the focal depth corresponding to each remaining motor position are determined, so that a second mapping relationship between motor position and focal depth can be created.

[0081] S112: Determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship.

[0082] After the first mapping relationship between the focus depth and the dispersion value and the second mapping relationship between the motor position and the focus depth are determined, if the focus depth in the first mapping relationship and the focus depth in the second mapping relationship are completely consistent, the third mapping relationship between the motor position of the camera module and the dispersion value can be determined based on the first mapping relationship and the second mapping relationship.

[0083] In one embodiment, determining a third mapping relationship between a motor position of a camera module and a dispersion value according to the first mapping relationship and the second mapping relationship includes:

[0084] Based on the focus depth in the first mapping relationship and the second mapping relationship, the dispersion value in the first mapping relationship and the motor position in the second mapping relationship are matched one by one to form a third mapping relationship between the motor position and the dispersion value of the camera module.

[0085] However, it is worth noting that the focus depth obtained by substituting into the second function may be inconsistent with the focus depth in the first mapping relationship in the above step S110. For example, the focus depth obtained based on the second function may be 2.1 μm, but the focus depth sampled in the above step S110 may be 2 μm. In order to facilitate the subsequent determination of the third mapping relationship between the motor position and the dispersion value, it is also necessary to unify the focus depth.

[0086] Since the first mapping relationship between the focus depth and the dispersion value can be determined in step S110, a linear fitting can be performed according to the first mapping relationship to obtain a function between the focus depth and the dispersion value.

[0087] Then, the focal depth obtained according to the second function is substituted into the function between the focal depth and the dispersion value to obtain a new dispersion value. In this way, the fourth mapping relationship between the focal depth and the dispersion value can be determined according to the focal depth corresponding to the second function and the new dispersion value; this is equivalent to converting the first mapping relationship into the fourth mapping relationship. Then, the focal depth involved in the fourth mapping relationship and the second mapping relationship is unified at this time.

[0088] That is, when the focusing depths in the first mapping relationship and the second mapping relationship are inconsistent, the first mapping relationship is converted into a fourth mapping relationship, and based on the focusing depths in the fourth mapping relationship and the second mapping relationship, the dispersion value in the fourth mapping relationship and the motor position in the second mapping relationship are matched one-to-one to form a third mapping relationship between the motor position and the dispersion value of the camera module.

[0089] S113, obtaining a target dispersion value of the camera module, determining a target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focusing the camera module based on the target motor position; the target dispersion value is a dispersion value of the clearest image taken by the camera module.

[0090] After the third mapping relationship is determined, the clearest image taken by the camera module is obtained, and the target dispersion value corresponding to the clearest image is determined according to the method of determining the dispersion value in step S110. Then, the target motor position of the camera module is determined according to the target dispersion value and the third mapping relationship, and the camera module is focused based on the target motor position.

[0091] In one implementation, determining a target motor position of a camera module according to a target dispersion value and a third mapping relationship includes:

[0092] fitting a third function between the dispersion value and the motor position according to a third mapping relationship;

[0093] Substitute the target dispersion value into the third function to obtain the target motor position of the camera module.

[0094] Similarly, when fitting the third function, the fitting function in the open database can also be called to fit the dispersion value and the motor position to obtain the third function.

[0095] Then, the target dispersion value corresponding to the clearest image is substituted into the third function to obtain the corresponding target motor position, and the motor drive of the camera module is controlled to push the lens to move to the target motor position to achieve focusing.

[0096] It can be seen that when determining the target motor position of the camera module, the present invention does not need to perform special process processing on the image sensor sensor, thereby shortening the process processing time and further shortening the focusing time, thereby improving the focusing efficiency of the camera module and further improving the overall testing efficiency of the camera module.

[0097] Based on the same inventive concept as the above-mentioned embodiment, the present invention also provides a device for controlling the focus of a camera module, such as Figure 2 As shown, the device comprises:

[0098] A first determination unit 21 is used to obtain a first image of the camera module at different focus depths, and determine a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor;

[0099] A second determining unit 22, used to determine a second image of the camera module at different target motor positions, and determine a second mapping relationship between the motor position of the camera module and the focus depth according to the second image;

[0100] A third determining unit 23, configured to determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship;

[0101] The fourth determination unit 24 is used to obtain the target dispersion value of the camera module, determine the target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module.

[0102] In one implementation, each focus depth corresponds to a first image; the first determination unit 21 is specifically configured to:

[0103] For each first image, obtain a target area of ​​the first image; perform RGB channel separation on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; use a preset convolution kernel to convolve the R channel image to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; use a preset threshold to filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean;

[0104] A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

[0105] Since the device introduced in the embodiment of the present invention is a device used to implement the method of controlling the focus of the camera module in the embodiment of the present invention, based on the method introduced in the embodiment of the present invention, the person skilled in the art can understand the specific structure and deformation of the device, so it is not repeated here. All devices used in the method of the embodiment of the present invention belong to the scope of protection of the present invention.

[0106] Based on the same inventive concept, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any step of the method described above when executing the computer program.

[0107] Based on the same inventive concept, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the methods described above are implemented.

[0108] Through one or more embodiments of the present invention, the present invention has the following beneficial effects or advantages:

[0109] The present invention provides a method, device, medium and equipment for controlling the focus of a camera module, the method comprising: acquiring a first image of the camera module at different focus depths, determining a first mapping relationship between the focus depth of the camera module and a dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor; determining a second image of the camera module at different target motor positions, determining a second mapping relationship between the motor position of the camera module and the focus depth according to the second image; determining the camera module according to the first mapping relationship and the second mapping relationship a third mapping relationship between the motor position of the camera module and the dispersion value; obtaining the target dispersion value of the camera module, determining the target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focusing the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module; in this way, when determining the target motor position of the camera module, there is no need to perform special process processing on the image sensor sensor, thereby shortening the process processing time, thereby shortening the focusing time, improving the focusing efficiency of the camera module, and thereby improving the testing efficiency.

[0110] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description of the above specific languages ​​is for disclosing the best mode of the present invention.

[0111] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0112] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.

[0113] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0114] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0115] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in a gateway, proxy server, or system according to an embodiment of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0116] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0117] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0118] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for controlling the focus of a camera module, characterized in that: The method comprises: Acquire a first image of the camera module at different focus depths, and determine a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor; Determine a second image of the camera module at different target motor positions, and determine a second mapping relationship between the motor position of the camera module and the focus depth according to the second image; Determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship; Obtain a target dispersion value of the camera module, determine a target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module.

2. The method according to claim 1, characterized in that Each focus depth corresponds to a first image; and determining a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image includes: For each first image, obtain a target area of ​​the first image; perform RGB channel separation on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; use a preset convolution kernel to convolve the R channel image to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; use a preset threshold to filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean; A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

3. The method according to claim 2, characterized in that The dispersion value includes a color ratio value of each channel image; and determining the dispersion value of each channel image according to the first mean value, the second mean value, and the third mean value includes: Determine the color ratio value of the R channel image relative to the B channel image according to the formula R′ / B′; Determine the color ratio value of the R channel image relative to the G channel image according to the formula R′ / G′; The color ratio value of the B channel image relative to the G channel image is determined according to the formula B′ / G′.

4. The method according to claim 1, characterized in that After determining a first mapping relationship between a focus depth of the camera module and a dispersion value of the first image according to the first image, the method further includes: Using the first mapping relationship to fit a first function between the depth of focus and the dispersion value; The target motor position includes a first motor position and a second motor position; and determining a second mapping relationship between the motor position of the camera module and the focus depth according to the second image includes: respectively determining a first dispersion value of the second image corresponding to the first motor position, and determining a second dispersion value of the second image corresponding to the second motor position; determining a first focusing depth corresponding to the first dispersion value based on the first function, and determining a second focusing depth corresponding to the second dispersion value based on the first function; fitting a second function between focus depth and motor position based on the first dispersion value, the second dispersion value, the first focus depth, and the second focus depth; For each remaining motor position within the motor travel range, determining a focus depth corresponding to each remaining motor position according to the second function; A second mapping relationship between motor position and focus depth is created according to the focus depth corresponding to each remaining motor position, the first motor position, the first focus depth, the second motor position, and the second focus depth.

5. The method according to claim 1, characterized in that The determining, according to the first mapping relationship and the second mapping relationship, a third mapping relationship between the motor position of the camera module and the dispersion value comprises: If the focusing depths in the first mapping relationship and the second mapping relationship are consistent, based on the focusing depths in the first mapping relationship and the second mapping relationship, the dispersion value in the first mapping relationship and the motor position in the second mapping relationship are matched one-to-one to form a third mapping relationship between the motor position of the camera module and the dispersion value.

6. The method according to claim 1, characterized in that The step of determining a target motor position of the camera module according to the target dispersion value and the third mapping relationship includes: Fitting a third function between the dispersion value and the motor position according to the third mapping relationship; Substitute the target dispersion value into the third function to obtain the target motor position of the camera module.

7. A device for controlling the focus of a camera module, characterized in that: The device comprises: A first determination unit is used to obtain a first image of the camera module at different focus depths, and determine a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image according to the first image; the focus depth is the distance between the lens of the camera module and the image sensor; A second determining unit, used to determine a second image of the camera module at different target motor positions, and determine a second mapping relationship between the motor position of the camera module and the focus depth according to the second image; A third determining unit, configured to determine a third mapping relationship between the motor position of the camera module and the dispersion value according to the first mapping relationship and the second mapping relationship; The fourth determination unit is used to obtain the target dispersion value of the camera module, determine the target motor position of the camera module according to the target dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target dispersion value is the dispersion value of the clearest image taken by the camera module.

8. The device according to claim 7, characterized in that Each focus depth corresponds to a first image; the first determination unit is specifically used for: For each first image, a target area of ​​the first image is obtained; RGB channel separation is performed on the target area to obtain a corresponding R channel image, a G channel image and a B channel image; Convolve the R channel image using a preset convolution kernel to obtain a plurality of first convolution values; convolve the G channel image to obtain a plurality of second convolution values; convolve the B channel image to obtain a plurality of third convolution values; filter the plurality of first convolution values, the plurality of second convolution values ​​and the plurality of third convolution values ​​using a preset threshold to obtain a plurality of first target values, a plurality of second target values ​​and a plurality of third target values; determine a first mean R′ of the plurality of first target values, a second mean G′ of the plurality of second target values ​​and a third mean B′ of the plurality of third target values; determine the dispersion value of each channel image according to the first mean, the second mean and the third mean; A first mapping relationship between the focus depth and the dispersion value is created according to the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer device 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 program, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Quick focusing method and device for multispectral imaging

    CN104516085A

  • Focusing method and mobile terminal

    CN105827944A

  • Method for calculating image definition value for focusing, computing device and focusing system

    CN108833770A

  • Lens automatic focusing method and device, electronic equipment and computer storage medium

    CN116095473A

  • Automatic focus device

    JP1991284069A