A method, device, medium and equipment for controlling focusing of a camera module
By establishing a mapping relationship between the focus depth of the camera module, the dispersion value, and the motor position, the target motor position can be quickly determined, solving the problem of low testing efficiency during the focusing process of the camera module and achieving efficient focusing control.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KUNSHAN Q TECH CO LTD
- Filing Date
- 2024-11-27
- Publication Date
- 2026-04-14
AI Technical Summary
Existing technologies involve cumbersome processes during the focusing of camera modules, resulting in low testing efficiency.
By acquiring images of the camera module at different depths of focus, a mapping relationship between depth of focus and dispersion value is established. Combined with the mapping relationship between motor position and depth of focus, the target motor position of the camera module is determined to achieve focusing.
No special processing is required for the image sensor, shortening the processing time, improving focusing efficiency, and thus improving the testing efficiency of the camera module.
Smart Images

Figure CN119653232B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of camera module testing technology, and in particular to a method, apparatus, medium and equipment for controlling the focusing of a camera module. Background Technology
[0002] Before leaving the factory, camera modules need to undergo various tests after focusing. Currently, the most popular focusing method is to calculate the focal length using PD (phase difference) technology. However, this method requires special processing of the image sensor (such as masking the sensor and setting PD points), which not only increases the hardware cost of the sensor but also increases the overall testing process and time.
[0003] Therefore, there is an urgent need for a method to control the focus of the camera module in order to improve the overall testing efficiency of the camera module. Summary of the Invention
[0004] To address the problems existing in the prior art, embodiments of the present invention provide a method, apparatus, medium, and device for controlling the focusing of a camera module, so as to solve or partially solve the technical problem that the overall testing efficiency is affected by the cumbersome focusing process when testing a camera module.
[0005] A first aspect of the present invention provides a method for controlling the focusing of a camera module, the method comprising:
[0006] First images of the camera module at different focal depths are acquired, and a first mapping relationship between the focal depth of the camera module and the dispersion value of the first image is determined based on the first images; the focal depth is the distance between the lens of the camera module and the image sensor.
[0007] Determine second images of the camera module at different target motor positions, and determine a second mapping relationship between the motor position and the depth of focus of the camera module based on the second images;
[0008] A third mapping relationship between the motor position of the camera module and the dispersion value is determined based on the first mapping relationship and the second mapping relationship;
[0009] The target chromatic dispersion value of the camera module is obtained, the target motor position of the camera module is determined according to the target chromatic dispersion value and the third mapping relationship, and the camera module is focused based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
[0010] In the above scheme, each focusing depth corresponds to a first image; determining the first mapping relationship between the focusing depth of the camera module and the dispersion value of the first image based on the first image includes:
[0011] For each first image, a target region of the first image is obtained; the target region is separated into RGB channels to obtain corresponding R-channel, G-channel, and B-channel images; the R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on 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 based on 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 scheme, the dispersion value includes the color ratio value of each channel image; determining the dispersion value of each channel image based on the first mean, the second mean, and the third mean includes:
[0014] The color ratio of the R channel image relative to the B channel image is determined according to the formula R′ / B′.
[0015] The color ratio value of the R channel image relative to the G channel image is determined according to the formula R′ / G′.
[0016] The color ratio of the B channel image relative to the G channel image is determined according to the formula B′ / G′.
[0017] In the above scheme, after determining the first mapping relationship between the focus depth of the camera module and the dispersion value of the first image based on the first image, the method further includes:
[0018] The first function relating the depth of focus to the dispersion value is fitted using the first mapping relationship;
[0019] The target motor position includes a first motor position and a second motor position; determining the second mapping relationship between the motor position and the depth of focus of the camera module based on the second image includes:
[0020] The first chromatic dispersion value of the second image corresponding to the position of the first motor is determined, and the second chromatic dispersion value of the second image corresponding to the position of the second motor is determined.
[0021] The first focusing depth corresponding to the first dispersion value is determined based on the first function, and the second focusing depth corresponding to the second dispersion value is determined based on the first function;
[0022] A second function is fitted 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;
[0023] For each remaining motor position within the motor travel range, the focusing depth corresponding to each remaining motor position is determined according to the second function;
[0024] A second mapping relationship between motor position and focus depth is created based on 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 scheme, determining the third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship includes:
[0026] If the focus depths in the first mapping relationship and the second mapping relationship are consistent, the chromatic dispersion values in the first mapping relationship and the motor positions in the second mapping relationship are mapped one-to-one based on the focus depths in the first mapping relationship and the second mapping relationship, forming a third mapping relationship between the motor position of the camera module and the chromatic dispersion values.
[0027] In the above scheme, determining the target motor position of the camera module based on the target dispersion value and the third mapping relationship includes:
[0028] A third function is fitted between the dispersion value and the motor position based on the third mapping relationship;
[0029] Substituting the target dispersion value into the third function yields the target motor position of the camera module.
[0030] A second aspect of the present invention provides an apparatus for controlling the focusing of a camera module, the apparatus comprising:
[0031] The first determining unit is configured to acquire first images of the camera module at different focal depths, and determine a first mapping relationship between the focal depth of the camera module and the dispersion value of the first image based on the first image; the focal depth is the distance between the lens of the camera module and the image sensor.
[0032] The second determining unit is used to determine the second image of the camera module at different target motor positions, and to determine the second mapping relationship between the motor position and the focusing depth of the camera module based on the second image;
[0033] The third determining unit is used to determine a third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship;
[0034] The fourth determining unit is used to obtain the target chromatic dispersion value of the camera module, determine the target motor position of the camera module according to the target chromatic dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
[0035] In the above scheme, each focusing depth corresponds to one first image; the first determining unit is specifically used for:
[0036] For each first image, a target region of the first image is obtained; the target region is separated into RGB channels to obtain corresponding R-channel, G-channel, and B-channel images; the R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on 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 based on the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.
[0038] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in any of the first aspects.
[0039] A fourth aspect of the present invention 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, when executing the program, implements the steps of the method described in any of the first aspects.
[0040] This invention provides a method, apparatus, medium, and device for controlling the focusing of a camera module. The method includes: acquiring first images of the camera module at different depths of focus; determining a first mapping relationship between the depth of focus of the camera module and the chromatic aberration value of the first image based on the first image; wherein the depth of focus is the distance between the lens of the camera module and the image sensor; determining second images of the camera module at different target motor positions; determining a second mapping relationship between the motor position of the camera module and the depth of focus based on the second image; and determining the focusing distance based on the first mapping relationship and the second mapping relationship. The method describes a third mapping relationship between the motor position of the camera module and the chromatic dispersion value; obtains the target chromatic dispersion value of the camera module; determines the target motor position of the camera module based on the target chromatic dispersion value and the third mapping relationship; and focuses the camera module based on the target motor position. The target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module. In this way, when determining the target motor position of the camera module, no special processing of the image sensor is required, thus shortening the processing time, shortening the focusing time, improving the focusing efficiency of the camera module, and thus improving the testing efficiency. Attached Figure Description
[0041] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0042] Figure 1 A schematic flowchart of a method for controlling the focusing of a camera module according to an embodiment of the present invention is shown;
[0043] Figure 2 A schematic diagram of a device for controlling the focusing of a camera module according to an embodiment of the present invention is shown. Detailed Implementation
[0044] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0045] This invention provides a method for controlling the focusing of a camera module, such as... Figure 1 As shown, the method mainly includes the following steps:
[0046] S110, acquire first images of the camera module at different focal depths, and determine a first mapping relationship between the focal depth of the camera module and the dispersion value of the first image based on the first image; the focal depth is the distance between the lens of the camera module and the image sensor.
[0047] To better understand the technical solution of this application, the overall technical approach will be introduced first. For a certain type of camera module, before mass production (when the camera module is still in an incomplete assembly state), the depth of focus is adjustable, thus the first mapping relationship between the depth of focus 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, while the motor position is adjustable. Therefore, the second mapping relationship between the motor position and the focus depth can be determined at this stage.
[0049] Then, based on the first and second mapping relationships, a third mapping relationship between the dispersion value and the motor position is determined. The target motor position is quickly determined based on 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 fixed illuminance can be set at a preset location, and a checkerboard chart can be placed below the light source. Then, the focus depth is adjusted, and at each focus depth, the camera module is controlled to capture images of the checkerboard chart, obtaining the corresponding first image. Here, focus depth is the distance between the image sensor and the lens; a laser rangefinder can be used to measure the focus depth when adjusting it. Then, based on 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 depth of focus corresponds to a first image; determining a first mapping relationship between the depth of focus of the camera module and the dispersion value of the first image based on the first image includes:
[0052] For each first image, a target region of the first image is obtained; the target region is separated into RGB channels to obtain corresponding R-channel, G-channel, and B-channel images; the R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on the first mean, the second mean, and the third mean.
[0053] A first mapping relationship between focus depth and dispersion value is created based on the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.
[0054] It's understandable that light refracts through a lens, and since different wavelengths have different refractive indices, the positions reached by different wavelengths at different depths of focus are also different after light passes through the lens due to the varying refractive indices. Therefore, the degree of blurriness of the black and white boundaries of the checkerboard pattern in the first image varies at different depths of focus. The blurrier the first image, the less clear the black and white boundaries, and thus, the smaller the convolution value corresponding to the unclear locations when convolving the first image with a convolution kernel.
[0055] Therefore, for each first image, the present invention first determines the region of interest (ROI) of the first image, and then uses the ROI as the target region to separate the RGB channels to obtain the corresponding R channel image, G channel image and B channel image.
[0056] Taking the R channel as an example, the Sobel convolution kernel is used to convolve the R channel image, resulting in multiple first convolution values. As mentioned above, the smaller the convolution value, the less clear the boundaries in the image. The first convolution value greater than a preset threshold is selected from these multiple first convolution values as the first target value. The preset threshold can be set empirically or is the average of the multiple first convolution values.
[0057] The B-channel and G-channel images can be processed in the same way as the R-channel images, ultimately yielding multiple first target values, multiple second target values, and multiple third target values. Further details will not be elaborated here.
[0058] Then, determine the first mean R′ of multiple first target values, the second mean G′ of multiple second target values, and the third mean B′ of multiple third target values; determine the dispersion value of each channel image based on the first mean, second mean, and third mean.
[0059] In one implementation, the dispersion value includes the color ratio values of each channel image; determining the dispersion value of each channel image based on a first mean, a second mean, and a third mean includes:
[0060] The color ratio of the R channel image relative to the B channel image is determined using the formula R′ / B′.
[0061] The color ratio of the R channel image relative to the G channel image is determined using the formula R′ / G′.
[0062] The color ratio of the B channel image relative to the G channel image is determined using the formula B′ / G′.
[0063] By processing the first image at each focal depth, the dispersion value of each first image at each focal depth can be obtained, and thus a first mapping relationship between focal depth and dispersion value can be created.
[0064] S111, determine the second image of the camera module at different target motor positions, and determine the second mapping relationship between the motor position and the focus depth of the camera module based on the second image.
[0065] In one embodiment, after determining a first mapping relationship between the focus depth of the camera module and the dispersion value of the first image based on the first image, the method further includes:
[0066] A first function relating the depth of focus to the dispersion value is fitted using the first mapping relationship;
[0067] The target motor position includes the first motor position and the second motor position; the second mapping relationship between the motor position of the camera module and the depth of focus is determined based on the second image, including:
[0068] The first chromatic dispersion value of the second image corresponding to the position of the first motor is determined, and the second chromatic dispersion value of the second image corresponding to the position of the second motor is determined.
[0069] The first focusing depth corresponding to the first dispersion value is determined based on the first function, and the second focusing depth corresponding to the second dispersion value is determined based on the first function;
[0070] A second function is fitted 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, the focusing depth corresponding to each remaining motor position is determined according to the second function;
[0072] A second mapping relationship between motor position and focus depth is created based on 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 determining the first mapping relationship between the depth of focus and the dispersion value, it is necessary to fit a first function between the depth of focus and the dispersion value based on the first mapping relationship.
[0074] When fitting the first function, fitting functions from open databases (such as OpenCV) can be used to fit the dispersion value and depth of focus. Since each channel image contains three color ratio values, and the relationship between the color ratio value and the depth of focus for each channel image is linear, the color ratio value of one channel image can be selected to fit the depth of focus to obtain the first function; alternatively, the color ratio values of all three channel images can be fitted to the depth of focus to obtain the first function; no limit is imposed here.
[0075] Once the camera modules enter mass production, due to the large number of modules, to save testing time, a second image of each camera module is determined at different target motor positions. The target motor positions consist of only two motor positions: a first motor position and a second motor position. For example, if the motor travel range is -100code to 100code, then the first motor position could be -100code, and the second motor position could be 100code.
[0076] After obtaining 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 way as the dispersion value determined in step S110.
[0077] Then, the first dispersion value is substituted into the first function to obtain the first depth of focus, and the second dispersion value is substituted into the first function to obtain the second depth of focus.
[0078] Then, a second function is fitted between the focus depth and the motor position based on the first dispersion value, the first depth of focus, the second dispersion value, and the second depth of focus.
[0079] However, during the focus-finding process, the motor needs to be controlled to move sequentially along a preset step size within the travel range (for example, the preset step size is 1 code, and it moves 1 code at a time). In addition to -100 code and 100 code, there are also 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 position of the first motor and its corresponding first focusing depth, the position of the second motor and its corresponding second focusing depth, and the focusing depth corresponding to each of the remaining motor positions are determined, thus enabling the creation of a second mapping relationship between motor positions and focusing depths.
[0081] S112, determine a third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship.
[0082] Once the first mapping relationship between focus depth and dispersion value and the second mapping relationship between motor position and 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 the motor position and dispersion value of the camera module based on a first mapping relationship and a second mapping relationship includes:
[0084] Based on the depth of focus in the first and second mapping relationships, the dispersion values in the first mapping relationship and the motor positions in the second mapping relationship are mapped one-to-one to form a third mapping relationship between the motor positions and dispersion values of the camera module.
[0085] However, it is worth noting that the focusing depth obtained by substituting into the second function may not be consistent with the focusing depth in the first mapping relationship in step S110. For example, the focusing depth obtained based on the second function may be 2.1 μm, but the focusing depth sampled in step S110 may be 2 μm. 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 focusing depth.
[0086] Since the first mapping relationship between the depth of focus and the dispersion value can be determined in step S110, a linear fit can be performed based on the first mapping relationship to obtain the function between the depth of focus and the dispersion value.
[0087] Then, the depth of focus obtained from the second function is substituted into the function relating depth of focus and dispersion value to obtain a new dispersion value. Thus, based on the depth of focus corresponding to the second function and the new dispersion value, a fourth mapping relationship between depth of focus and dispersion value can be determined; this is equivalent to transforming the first mapping relationship into a fourth mapping relationship. Therefore, the depth of focus involved in the fourth mapping relationship and the second mapping relationship is now unified.
[0088] That is, when the focus depths in the first mapping relationship and the second mapping relationship are inconsistent, the first mapping relationship is converted into the fourth mapping relationship. Based on the focus 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 the third mapping relationship between the motor position and the dispersion value of the camera module.
[0089] S113, obtain the target chromatic dispersion value of the camera module, determine the target motor position of the camera module according to the target chromatic dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
[0090] After the third mapping relationship is determined, the clearest image captured by the camera module is obtained. The target chromatic dispersion value corresponding to the clearest image is determined according to the method for determining the chromatic dispersion value in step S110. Then, the target motor position of the camera module is determined based on the target chromatic dispersion value and the third mapping relationship. The camera module is then focused based on the target motor position.
[0091] In one implementation, determining the target motor position of the camera module based on the target dispersion value and a third mapping relationship includes:
[0092] A third function is fitted between the dispersion value and the motor position based on the third mapping relationship;
[0093] Substituting the target dispersion value into the third function yields the target motor position of the camera module.
[0094] Similarly, when fitting the third function, the fitting function in the open database can be called to fit the dispersion value and the motor position to obtain the third function.
[0095] Then, the target chromatic aberration value corresponding to the clearest image is substituted into the third function to obtain the corresponding target motor position. The motor drive of the camera module is then controlled to move the lens to the target motor position to achieve focusing.
[0096] As can be seen, when determining the target motor position of the camera module, the present invention does not require special processing of the image sensor, thus shortening the processing time and focusing time, improving the focusing efficiency of the camera module, and thus improving the overall testing efficiency of the camera module.
[0097] Based on the same inventive concept as the foregoing embodiments, the present invention also provides a device for controlling the focusing of a camera module, such as... Figure 2 As shown, the device includes:
[0098] The first determining unit 21 is used to acquire first images of the camera module at different focusing depths, and determine a first mapping relationship between the focusing depth of the camera module and the dispersion value of the first image based on the first image; the focusing depth is the distance between the lens of the camera module and the image sensor.
[0099] The second determining unit 22 is used to determine the second image of the camera module at different target motor positions, and to determine the second mapping relationship between the motor position and the focusing depth of the camera module based on the second image;
[0100] The third determining unit 23 is used to determine a third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship;
[0101] The fourth determining unit 24 is used to obtain the target chromatic dispersion value of the camera module, determine the target motor position of the camera module according to the target chromatic dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
[0102] In one implementation, each focusing depth corresponds to one first image; the first determining unit 21 is specifically used for:
[0103] For each first image, a target region of the first image is obtained; the target region is separated into RGB channels to obtain corresponding R-channel, G-channel, and B-channel images; the R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on 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 based on the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.
[0105] Since the apparatus described in the embodiments of this invention is used to implement the method of controlling the focusing of the camera module according to the embodiments of this invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in the embodiments of this invention, and therefore will not be described in detail here. All apparatuses used in the methods of the embodiments of this invention fall within the scope of protection of this 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. When the processor executes the computer program, it implements any step of the method described above.
[0107] Based on the same inventive concept, this embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods described above.
[0108] Through one or more embodiments of the present invention, the present invention has the following beneficial effects or advantages:
[0109] This invention provides a method, apparatus, medium, and device for controlling the focusing of a camera module. The method includes: acquiring first images of the camera module at different depths of focus; determining a first mapping relationship between the depth of focus of the camera module and the chromatic aberration value of the first image based on the first image; wherein the depth of focus is the distance between the lens of the camera module and the image sensor; determining second images of the camera module at different target motor positions; determining a second mapping relationship between the motor position of the camera module and the depth of focus based on the second image; and determining the focusing distance of the camera module based on the first mapping relationship and the second mapping relationship. A third mapping relationship is established between the motor position of the image module and the chromatic dispersion value; the target chromatic dispersion value of the image module is obtained, and the target motor position of the image module is determined according to the target chromatic dispersion value and the third mapping relationship; the image module is then focused based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the image module; thus, when determining the target motor position of the image module, no special processing of the image sensor is required, thereby shortening the processing time, and consequently shortening the focusing time, improving the focusing efficiency of the image module, and thus improving the testing efficiency.
[0110] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0111] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0112] Similarly, it should be understood that, in order to simplify this disclosure and aid in understanding one or more of the various aspects of the invention, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this method of disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0113] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0114] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0115] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components of the gateway, proxy server, or system according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing some or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0116] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0117] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0118] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for controlling the focusing of a camera module, characterized in that, The method includes: First images of the camera module at different focal depths are acquired, and a first mapping relationship between the focal depth of the camera module and the dispersion value of the first image is determined based on the first images; the focal depth is the distance between the lens of the camera module and the image sensor. Determine second images of the camera module at different target motor positions, and determine a second mapping relationship between the motor position and the depth of focus of the camera module based on the second images; A third mapping relationship between the motor position of the camera module and the dispersion value is determined based on the first mapping relationship and the second mapping relationship; The target chromatic dispersion value of the camera module is obtained, the target motor position of the camera module is determined according to the target chromatic dispersion value and the third mapping relationship, and the camera module is focused based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
2. The method as described in claim 1, characterized in that, Each depth of focus corresponds to a first image; determining the first mapping relationship between the depth of focus of the camera module and the dispersion value of the first image based on the first image includes: For each first image, a target region of the first image is obtained; the target region is separated into RGB channels to obtain corresponding R-channel, G-channel, and B-channel images; the R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on the first mean, the second mean, and the third mean. A first mapping relationship between the focus depth and the dispersion value is created based on the focus depth corresponding to each first image and the dispersion value corresponding to each channel image of each first image.
3. The method as described in claim 2, characterized in that, The dispersion value includes the color ratio value of each channel image; determining the dispersion value of each channel image based on the first mean, the second mean, and the third mean includes: The color ratio of the R channel image relative to the B channel image is determined according to the formula R′ / B′. The color ratio value of the R channel image relative to the G channel image is determined according to the formula R′ / G′. The color ratio of the B channel image relative to the G channel image is determined according to the formula B′ / G′.
4. The method as described in claim 1, characterized in that, After determining the first mapping relationship between the focus depth of the camera module and the dispersion value of the first image based on the first image, the method further includes: The first function relating the depth of focus to the dispersion value is fitted using the first mapping relationship; The target motor position includes a first motor position and a second motor position; determining the second mapping relationship between the motor position and the depth of focus of the camera module based on the second image includes: The first chromatic dispersion value of the second image corresponding to the position of the first motor is determined, and the second chromatic dispersion value of the second image corresponding to the position of the second motor is determined. The first focusing depth corresponding to the first dispersion value is determined based on the first function, and the second focusing depth corresponding to the second dispersion value is determined based on the first function; A second function is fitted 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; For each remaining motor position within the motor travel range, the focusing depth corresponding to each remaining motor position is determined according to the second function; A second mapping relationship between motor position and focus depth is created based on 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 as described in claim 1, characterized in that, Determining the third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship includes: If the focus depths in the first mapping relationship and the second mapping relationship are consistent, the chromatic dispersion values in the first mapping relationship and the motor positions in the second mapping relationship are mapped one-to-one based on the focus depths in the first mapping relationship and the second mapping relationship, forming a third mapping relationship between the motor position of the camera module and the chromatic dispersion values.
6. The method as described in claim 1, characterized in that, Determining the target motor position of the camera module based on the target dispersion value and the third mapping relationship includes: A third function is fitted between the dispersion value and the motor position based on the third mapping relationship; Substituting the target dispersion value into the third function yields the target motor position of the camera module.
7. A device for controlling the focusing of a camera module, characterized in that, The device includes: The first determining unit is configured to acquire first images of the camera module at different focal depths, and determine a first mapping relationship between the focal depth of the camera module and the dispersion value of the first image based on the first image; the focal depth is the distance between the lens of the camera module and the image sensor. The second determining unit is used to determine the second image of the camera module at different target motor positions, and to determine the second mapping relationship between the motor position and the focusing depth of the camera module based on the second image; The third determining unit is used to determine a third mapping relationship between the motor position of the camera module and the dispersion value based on the first mapping relationship and the second mapping relationship; The fourth determining unit is used to obtain the target chromatic dispersion value of the camera module, determine the target motor position of the camera module according to the target chromatic dispersion value and the third mapping relationship, and focus the camera module based on the target motor position; the target chromatic dispersion value is the chromatic dispersion value of the clearest image captured by the camera module.
8. The apparatus as claimed in claim 7, characterized in that, Each focusing depth corresponds to one first image; the first determining unit is specifically used for: For each first image, the target region of the first image is obtained; the target region is separated into RGB channels to obtain the corresponding R channel image, G channel image and B channel image; The R-channel image is convolved using preset convolution kernels to obtain multiple first convolution values; the G-channel image is convolved to obtain multiple second convolution values; the B-channel image is convolved to obtain multiple third convolution values; the multiple first convolution values, the multiple second convolution values, and the multiple third convolution values are filtered using preset thresholds to obtain multiple first target values, multiple second target values, and multiple third target values; a first mean R′ of the multiple first target values, a second mean G′ of the multiple second target values, and a third mean B′ of the multiple third target values are determined; the dispersion value of each channel image is determined based on the first mean, the second mean, and the third mean. A first mapping relationship between the focus depth and the dispersion value is created based on 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 executed by a processor, the program implements the steps of the method according to any one of claims 1-6.
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, it implements the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Quick focusing method and device for multispectral imaging
CN104516085A
Lens automatic focusing method and device, electronic equipment and computer storage medium
CN116095473A