Camera module focus finding method, device and testing equipment

By building a KNN algorithm model to predict the optimal focusing point of the camera module at different object distances, the problem of low focus finding efficiency of traditional camera modules is solved and fast focus finding is achieved.

CN115734075BActive Publication Date: 2025-09-30KUNSHAN QIUTI PHOTOELECTRIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211331296.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-28
Publication Date
2025-09-30
Estimated Expiration
2042-10-28

AI Technical Summary

Technical Problem

Traditional camera module focus-finding methods are inefficient and require multiple motor movements, which is time-consuming.

Method used

Using a pre-built KNN algorithm model, the optimal focus point of the test camera module at N object distances is predicted based on the optimal focus point at M object distances, reducing the number of actual tests.

Benefits of technology

The camera module's focus-finding efficiency is improved, the number of motor movements is reduced, and the focus-finding time is shortened.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115734075B_ABST
    Figure CN115734075B_ABST
Patent Text Reader

Abstract

The present invention discloses a camera module focus-finding method, device, and testing equipment, applicable to the field of camera module generation and testing. The method comprises: testing M optimal focus points corresponding to M object distances of a target camera module; processing the M optimal focus points based on a pre-built target KNN algorithm model to predict N optimal focus points corresponding to the target camera module at N object distances, wherein the N object distances are different from the M object distances. The present invention solves the technical problem of low efficiency of camera module focus-finding methods in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of camera module generation and testing, and in particular to a camera module focus finding method, device and testing equipment. Background Art

[0002] Based on the optical principle of a convex lens, traditional camera module focus algorithms use a voice coil motor (VCM) to move the lens in steps, capturing each image. After the motor completes its full range of motion, the position corresponding to the clearest image is selected as the optimal focus point (AFCode). While this focus method minimizes error, it requires multiple motor movements, which is time-consuming and inefficient. Summary of the Invention

[0003] The embodiments of the present invention solve the technical problem of low efficiency of the camera module focus finding method in the prior art by providing a camera module focus finding method, device and testing equipment, and realize rapid focus finding when testing the camera module.

[0004] In a first aspect, an embodiment of the present invention provides a camera module focus finding method, comprising: testing M optimal focusing points corresponding to M object distances of a target camera module; processing the M optimal focusing points based on a pre-built target KNN algorithm model to predict N optimal focusing points corresponding to the target camera module at N object distances, wherein the N object distances are different from the M object distances, and M and N are positive integers.

[0005] Optionally, the method also includes the step of pre-constructing the target KNN algorithm model: obtaining multiple groups of historical test data of camera modules of the same specification, each group of the historical test data including N optimal focusing points obtained by testing the same camera module at the N object distances; dividing the training data set, the verification data set and the test data set according to the multiple groups of historical test data; constructing and verifying the KNN algorithm model based on the training data set and the test data set, and if the verification passes, obtaining the target KNN algorithm model.

[0006] Optionally, dividing the training data set, the validation data set, and the test data set according to the multiple groups of historical test data includes: randomly dividing the multiple groups of historical test data into the test data set and the training data set according to a preset ratio; selecting K data sub-columns corresponding to K types of object distances to be predicted from the training data set as a result comparison data set of the validation data set; generating a blank data set corresponding to the K types of object distances to be predicted based on the result comparison data set, and using the blank data set as a prediction result data set of the validation data set; selecting each data sub-column corresponding to the remaining object distances from the training data set as a complement data set of the validation data set, wherein the remaining object distances refer to various object distances in the training data set other than the K types of object distances to be predicted.

[0007] Optionally, constructing and verifying the KNN algorithm model based on the training data set and the test data set includes: taking each row component of the complementary data set as the target row component; calculating a first distance data set for the target row component, the first distance data set including distance data between the target row component and all row components of the test data set; using the KNN algorithm model, calculating each optimal focus point value corresponding to the predicted result data set and the target row component according to multiple nearest neighbor row components of the first distance data set; performing an offset calculation based on the optimal focus point value corresponding to each row component of the result comparison data set and the optimal focus point value corresponding to each row component of the predicted result data set to obtain an offset data set; determining the test accuracy of the KNN algorithm model based on the offset data set, and if the test accuracy reaches a preset accuracy threshold, it indicates that the KNN algorithm model has passed the verification.

[0008] Optionally, the calculation of the first distance data set for the target row component includes: for the current row component of the test data set, using a target distance measurement method to calculate the distance data between the target row component of the complement data set and the current row component of the test data set, and forming the first distance data set based on the calculated distance data.

[0009] Optionally, the calculating of the respective optimal focus point values ​​corresponding to the predicted result dataset and the target row component based on the multiple nearest neighbor row components of the first distance dataset includes: arranging the first distance dataset in ascending order; selecting the multiple nearest neighbor row components from the first distance dataset after the ascending order according to the number of nearest neighbors customized by the KNN algorithm model to form a nearest neighbor dataset; performing arithmetic averaging on the respective row components of the nearest neighbor dataset to obtain new row components; and using the to-be-predicted column values ​​of the new row components as the optimal focus point values ​​corresponding to the predicted result dataset and the target row components.

[0010] Optionally, performing an offset calculation based on the best focus point value corresponding to each row component of the result comparison dataset and the best focus point value corresponding to each row component of the prediction result dataset to obtain an offset dataset includes: performing an absolute value calculation of the difference between the row components of the result comparison dataset and the prediction result dataset corresponding to the same module identifier to obtain the offset value of the row component corresponding to the module identifier; and constructing the offset dataset based on the difference offset values ​​corresponding to each module identifier.

[0011] Optionally, the pre-built target KNN algorithm model is used to process the M optimal focusing points to predict the N optimal focusing points of the target camera module corresponding to N object distances, including: taking the N object distances as the target object distances to be predicted respectively; for the target object distances to be predicted, calculating a second distance data set between the target camera module and the test data set used by the KNN algorithm model through the target KNN algorithm model, and arranging them in ascending order; according to the custom number of nearest neighbors of the target KNN algorithm model, selecting multiple nearest neighbor row components from the second distance data set after ascending order; performing mean calculation based on the multiple nearest neighbor row components to predict the optimal focusing point of the target camera module at the target object distance to be predicted.

[0012] In second aspect, an embodiment of the present invention provides a camera module focus finding device, comprising: a testing unit, for testing M optimal focusing points of a target camera module corresponding to M object distances; a prediction unit, for processing the M optimal focusing points based on a pre-built target KNN algorithm model to predict the N optimal focusing points of the target camera module corresponding to N object distances, wherein the N object distances are different from the M object distances, and M and N are positive integers.

[0013] In a third aspect, an embodiment of the present invention provides a testing device, 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 the method described in any one of the embodiments of the first aspect are implemented.

[0014] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:

[0015] Since the target KNN algorithm model is used to process the M best focusing points under M object distances tested to predict the N best focusing points of the target camera module under other N object distances, it is only necessary to test the best focusing point of the camera module under one or a few object distances and predict the best focusing point of the camera module at other object distances. This eliminates the need to move the motor multiple times to test the best focusing points under all object distances one by one, thereby improving the focus-finding efficiency of the camera module. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0017] Figure 1 The flowchart of the camera module focus finding method in an embodiment of the present invention is shown;

[0018] Figure 2 The process of constructing the target KNN algorithm model in an embodiment of the present invention is shown;

[0019] Figure 3 A schematic structural diagram of a camera module focus-finding device according to an embodiment of the present invention is shown;

[0020] Figure 4 A schematic structural diagram of a testing device in an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0021] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0022] refer to Figure 1 As shown, an embodiment of the present invention provides a camera module focus finding method, comprising the following steps:

[0023] S101: Test the M optimal focus points of the target camera module at M object distances. You can test only one optimal focus point of the target camera module at a single object distance (the optimal focus point can be represented by the AFcode value later), or test two optimal focus points of the target camera module at two object distances. Common object distances can be 500cm, 9cm, 2.5cm, 15cm, 35cm, etc. For example, you can test the optimal focus points of the target camera module at object distances of 500cm and 9cm to predict the optimal focus points of the target camera module at object distances of 2.5cm, 15cm, and 35cm.

[0024] S102. Process the M best focusing points based on a pre-built target KNN (K-Nearest Neighbor) algorithm model to predict the N best focusing points corresponding to the target camera module at N object distances, where the N object distances are different from the M object distances, and M and N are positive integers.

[0025] Below, reference Figure 2 The process of pre-building the target KNN algorithm model is described to understand the process of building the target KNN algorithm model used in the embodiment of the present invention:

[0026] S201. Acquire multiple groups of historical test data of a camera module of the same specification, where each group of historical test data includes N optimal focus points obtained by testing the same camera module at N object distances.

[0027] Historical test data is collected in advance to create a large test data pool. This pool includes historical test data from each camera module of the same specification tested at N different object distances. Each camera module corresponds to a set of historical test data. During implementation, more than 500 sets of historical test data can be selected from the large test data pool for the construction and verification of the current KNN algorithm model.

[0028] In the embodiment of the present invention, the N object distances can be selected from the following five commonly used object distances: 500 cm, 9 cm, 2.5 cm, 15 cm, and 35 cm. That is, the five commonly used object distances correspond to five different test chart distances. Of course, in specific implementations, historical test data obtained from tests at other object distances can also be used based on actual needs.

[0029] Each set of historical test data includes N optimal focus points obtained by testing the same camera module at N object distances. Module identifiers can be used to distinguish different sets of historical test data. For example, module identifiers could be DA1001, DA1002, DA1003, DA1004, and so on.

[0030] Taking N=5 as an example, the data structure of a set of historical test data can be: the first column corresponds to the module identifier representing different camera modules, and the second to sixth columns correspond to the five best focusing points obtained by testing at five object distances, for example: the second column is the AFCode value obtained by testing at an object distance of 500cm, the third column corresponds to the clearest AFCode value obtained by testing at an object distance of 9cm, the fourth column corresponds to the clearest AFCode value obtained by testing at an object distance of 2.5cm, the fifth column corresponds to the clearest AFCode value obtained by testing at an object distance of 15cm, and the sixth column corresponds to the clearest AFCode value obtained by testing at an object distance of 35cm.

[0031] For example, 500 sets of historical test data can be seen in Table 1 below:

[0032]

[0033]

[0034] After step S201 , step S202 is performed: dividing the multiple groups of historical test data into a training data set, a validation data set, and a test data set.

[0035] In some implementations, step S202 may include the following sub-steps S2021 to S2023:

[0036] S2021: Randomly divide the multiple groups of historical test data into test data sets and training data sets according to a preset ratio.

[0037] Specifically, the preset ratio can be 7:3, that is, the multiple sets of historical test data are randomly divided into 70% test data sets and 30% training data sets. Below, taking 500 sets of historical test data as an example, 350 sets of historical test data are randomly divided into the test data set, denoted as DA; the remaining 150 sets of historical test data are divided into the training data set, denoted as DT.

[0038] In the specific implementation process, the row component length can be used to represent the data column size of each set of historical test data. Different sets of historical test data correspond to different row components. Taking Table 1 above as an example, the row component length of each set of historical test data is 5, corresponding to the AFcode values ​​at object distances of 500 cm, 9 cm, 2.5 cm, 15 cm, and 35 cm.

[0039] It should be noted that the test data set DA = {da1 = (x1, y1, ..., z1), {da2 = (x2, y2, ..., z2), ..., {da i =(xi,yi,…,zi),…,dan=(xm,ym,…,zm)}. Among them, (xi,yi,…,zi) is any camera module da i The AFcode values ​​corresponding to each object distance are shown in the figure as an example. The length of each row component DCols is 5, and (xi,yi,…,zi) corresponds to the AFcode values ​​of object distances of 500cm, 9cm, 2.5cm, 15cm, and 35cm respectively. i Indicates the module ID of the camera module in the test dataset.

[0040] It should be noted that the training data set DT = {dt1 = (x1, y1, ..., z1), ..., {dt i=(xi,yi,…,zi),…,dt n =(xn,yn,…,zn)}, where (xi,yi,…,zi) is the number of any camera module dt i The AFcode values ​​corresponding to each object distance. Taking Table 1 as an example, the length of each row component is 5, and (xi,yi,…,zi) corresponds to the AFcode values ​​of object distances of 500 cm, 9 cm, 2.5 cm, 15 cm, and 35 cm, respectively. dti represents the module identifier of the camera module in the training dataset.

[0041] S2022: Selecting K data sub-columns corresponding to K types of object distances to be predicted from the training dataset as a result comparison dataset of the validation dataset.

[0042] It should be noted that the result comparison data set can be expressed as DTR = {dt1 = {p1, q1,…, s1},…, {dti = {pi, qi,…, si},…, dtn = {pn, qn,…, sn}}, where the length (number of rows) of the result comparison data set is the same as the length (number of rows) of the training data set, and the row component length of the result comparison data set is smaller than the row component length of the training data set.

[0043] Taking the training dataset with a row component length of 5 (including AFcode values ​​at 5 object distances) as an example, K can be 1, 2, 3 or 4, that is, 1, 2, 3 or 4 data sub-columns can be selected from the training dataset as the result comparison dataset DTR.

[0044] Taking Table 1 above as an example, if the AFcode values ​​at object distances of 15cm and 35cm need to be predicted, the result comparison dataset DTR will select the two AFcode columns corresponding to the object distances of 15cm and 35cm in the training dataset. The result comparison dataset formed based on Table 1 above can be referred to as shown in Table 2 below:

[0045] Table 2.

[0046]

[0047] S2023: Generate a blank data set corresponding to the K types of object distances to be predicted based on the result comparison data set, and use the blank data set as a prediction result data set of the verification data set.

[0048] The prediction result dataset is expressed as DTRET = {dt1 = {null, null,…, null},…, {dti = {null, null,…, null},…, dtn = {null, null,…, null}}. The column names of the prediction result dataset DTRET are the same as those of the result comparison dataset DRT, and the row component lengths are equal. The row component value corresponding to RET in DT is null, which needs to be obtained through KNN algorithm model calculation (calculation process described later).

[0049] Taking Table 1 above as an example, if the AFcode values ​​corresponding to object distances of 15 cm and 35 cm need to be predicted, the prediction result dataset only includes the optimal focus point values ​​at object distances of 15 cm and 35 cm, and the AFCode value is empty. The module identifier dti of the camera module corresponds one-to-one with the module identifier dti in the result comparison dataset DTR.

[0050] S2024: Selecting data sub-columns corresponding to the remaining object distances from the training dataset as a complementary dataset of the validation dataset, wherein the remaining object distances refer to various object distances in the training dataset other than the K object distances to be predicted.

[0051] It should be noted that the complement data set can be expressed as DTC = {dt1 = {u1, v1, …, w1}, …, dtn = {un, vn, …, wn}}, where the data set length (number of rows) of the complement data set is the same as the data set length (number of rows) of the training data set, the row component length (DCols) of the complement data set is smaller than the row component length of the training data set, and the sum of the row component length (DCols) of the complement data set and the row component length of the result comparison data set is equal to the row component length of the training data set, and the following conditions are satisfied: DTC∪DTR = DT.

[0052] Referring to Table 1 and Table 2 above, if the AFcode values ​​to be predicted are at object distances of 15cm and 35cm, the complementary dataset is the AFcode values ​​at object distances of 500cm, 9cm, and 2.5cm. The complementary dataset corresponding to Table 1 above can be referred to as shown in Table 3 below:

[0053] Table 3

[0054]

[0055] S203: Construct and verify a KNN algorithm model based on the training data set and the test data set. If the verification passes, obtain a target KNN algorithm model.

[0056] Specifically, the KNN algorithm model is used to calculate the AFcode value of each row component in the prediction column (for example, 15cm, 35cm) of the prediction result dataset. For each camera module's module identifier dti, the AFcode value of the row component where the module identifier dti is located in the prediction column is calculated. The specific calculation process includes the following steps:

[0057] S2031. Taking each row component of the complement data set as a target row component;

[0058] S2032. Calculate a first distance data set for the target row component, where the first distance data set includes distance data between the target row component and all row components of the test data set.

[0059] For the current row component of the test dataset, a target distance measurement method is used to calculate the distance data between the target row component of the complement dataset and the current row component of the test dataset; and the first distance dataset is formed based on the calculated distance data.

[0060] It should be noted that the target distance measurement method in the embodiments of the present invention can use the Euclidean distance calculation formula. Taking dti = {ui, vi, …, wi} as an example, representing the i-th row component of camera module dti in the complement dataset DTC, the Euclidean distance calculation formula can be used to calculate the distance data from the i-th row component of the complement dataset to all row components of the test dataset DA, thereby obtaining a first distance dataset.

[0061] It should be noted that when calculating the distance data between any row component in the test dataset and the target row component, only the columns that are common to the test and complement datasets are used. For example, if the complement dataset only contains the AFcode values ​​for object distances of 500cm, 9cm, and 2.5cm, then the AFcode values ​​for object distances of 500cm, 9cm, and 2.5cm in the test dataset DA will be used, while the AFcode values ​​for object distances of 15cm and 35cm in the test dataset will not be used.

[0062] S2032: Using a KNN algorithm model, calculate the best focus point values ​​corresponding to the predicted result dataset and the target row component according to the multiple nearest neighbor row components of the first distance dataset.

[0063] In step S2032, the first distance data set is arranged in ascending order, and multiple nearest neighbor row components are selected from the sorted first distance data set to form a nearest neighbor data set; the arithmetic average is performed on each row component of the nearest neighbor data set to obtain a new row component; and the to-be-predicted column value of the new row component is used as the optimal focus point value corresponding to the prediction result data set and the target row component.

[0064] Specifically, the first meanCount row components (that is, the nearest neighbor row components) closest to the test dataset DA are selected from the sorted first distance dataset and the remaining row components are deleted to obtain the nearest neighbor dataset, where MeanCount is the number of nearest neighbors customized by the KNN algorithm model, which can be 3 to 5. The sorted result can be expressed as Dist = {dist(dti,dak1),…,dist(dti,dakmeanCount)}, where dak1 to dakmeanCount represent the first meanCount row components closest to the camera module dti and the dataset DA. The first meanCount row components in the sorted result are extracted as the nearest neighbor dataset, and the nearest neighbor dataset can be expressed as DKN = {dak1,…,dakmeanCount}.

[0065] Take the arithmetic mean of all components of the nearest neighbor data set to obtain a new row component: damean = (dak1 + ... + dakmeanCount) / meanCount, and extract the predicted column value corresponding to the new row component damean as the corresponding column value of the prediction result data set in the camera module dti, that is, the optimal focus point value of the corresponding target row component in the predicted column.

[0066] S2033: Perform an offset calculation on the best focus point value corresponding to each row component of the result comparison dataset and the best focus point value corresponding to each row component of the prediction result dataset to obtain an offset dataset.

[0067] Specifically, the absolute value of the difference between the row components corresponding to the same module identifier of the result comparison dataset and the prediction result dataset is calculated to obtain the offset value of the row component corresponding to the module identifier; and the offset dataset is constructed based on the difference offset values ​​corresponding to each module identifier.

[0068] Specifically, the absolute difference between the row components dti = {pi', qi', ..., si'} of the result comparison dataset corresponding to the same module identifier dti and the row components dti = {pi', qi', ..., si'} of the prediction result dataset is calculated to obtain the offset data dti = {|pi-pi'|, |qi-qi'|, ..., |si-si'|} corresponding to the module identifier dti. The constructed offset dataset can be expressed as DSHIFT = {dt1 = dti = {|p1-p1'|, |q1-q1'|, ..., |s1-s1'|}, ..., dti = {|pi-pi'|, |qi-qi'|, ..., |si-si'|}, ..., dtn = {|pn-pn'|, |qn-qn'|, ..., |sn-sn'|}}.

[0069] S2034: Determine a test accuracy of the KNN algorithm model based on the offset data set. If the test accuracy reaches a preset accuracy threshold, it indicates that the KNN algorithm model has passed the verification.

[0070] Among them, the test accuracy is expressed as Acc, which can be determined as follows: Acc = the number of rows in the offset data set row component that are less than the offset threshold ÷ the length of the offset data set (number of rows) * 100%, the offset threshold can be set to any offset value between 30 and 120 rows, and the accuracy threshold can be set to a value above 95%.

[0071] It should be noted that if the test accuracy is less than the preset accuracy threshold, it indicates that there is abnormal data in the test dataset DA and the training dataset DT, that is, the currently constructed KNN algorithm model has failed verification, and the process returns to steps S201 to S203 to reselect multiple sets of historical test data from the test big data pool and reconstruct the KNN algorithm model based on each reselected set of historical test data. In other words, steps S201 to S203 are executed repeatedly until the constructed KNN algorithm model passes verification, thereby obtaining the target KNN algorithm model.

[0072] After the constructed KNN algorithm model is verified, it can be used to predict the optimal focus point (AFCode value) of the camera module generated in actual production at various object distances to be predicted.

[0073] In S102, the N object distances are respectively used as target object distances to be predicted; for the target object distance to be predicted, a second distance data set between the target camera module and the test data set used by the KNN algorithm model is calculated by the target KNN algorithm model, and the data sets are arranged in ascending order; according to the customized number of nearest neighbors of the target KNN algorithm model, multiple nearest neighbor row components are selected from the second distance data set after the ascending order; and a mean value is calculated based on the multiple nearest neighbor row components to predict the optimal focusing point of the target camera module at the target object distance to be predicted.

[0074] For example, the optimal focusing point (i.e., AFcode value) corresponding to the target camera module at object distances of 500cm and 9cm is {910, 1500}. This is used as a parameter to predict the optimal focusing point of the target camera module at other object distances. The optimal focusing point of the target camera module at object distances of 2.5cm, 15cm, and 35cm is predicted respectively.

[0075] For example, a target camera module m1 is tested and the object distance is 500cm. The AFcode value corresponding to 9cm is {910,1500}. For example, the AFcode value corresponding to 2.5cm needs to be predicted. Assume that the collected test data set needs to be as shown in Table 4 below (only the columns required are shown):

[0076] Table 4:

[0077]

[0078] Next, the second distance dataset obtained by calculating the target camera module m1 and the test dataset is arranged in ascending order according to the Euclidean distance calculation formula, and the results are shown in Table 5 below:

[0079] Table 5.

[0080]

[0081] Finally, according to the model parameter of the target KNN algorithm model - the custom nearest neighbor number MeanCount = 3, the first three closest distance data are selected and the corresponding column AFcode value of the object distance 2.5 cm is calculated as the predicted AFCode value of the camera module m1 corresponding to 2.5 cm. The AFcode value of the target camera module m1 corresponding to the object distance of 2.5 cm is calculated to be 3226, as shown in Table 6 below:

[0082] Table 6.

[0083]

[0084] It should be understood that the AFcode values ​​of the target camera module m1 at 15 cm and 35 cm can also be predicted by similarity.

[0085] Based on the same inventive concept, the embodiment of the present invention provides a camera module focus finding device, referring to Figure 3 As shown, it includes: a testing unit 301, which is used to test M optimal focusing points of a target camera module corresponding to M object distances; a prediction unit 302, which is used to process the M optimal focusing points based on a pre-built target KNN algorithm model to predict N optimal focusing points of the target camera module corresponding to N object distances, wherein the N object distances are different from the M object distances, and M and N are positive integers.

[0086] In some embodiments, the device also includes a model construction unit for executing the steps of pre-constructing the target KNN algorithm model, which includes: a data acquisition subunit for acquiring multiple groups of historical test data of camera modules of the same specification, each group of the historical test data including N optimal focus points obtained by testing the same camera module at the N object distances; a data set division subunit for dividing the multiple groups of historical test data into a training data set, a verification data set and a test data set; a calculation and verification subunit for constructing and verifying the KNN algorithm model based on the training data set and the test data set, and if the verification passes, obtaining the target KNN algorithm model.

[0087] In some embodiments, the data set division subunit is specifically used to: randomly divide the multiple groups of historical test data into a test data set and a training data set according to a preset ratio; select K data sub-columns corresponding to K types of object distances to be predicted from the training data set as a result comparison data set of the verification data set; generate a blank data set corresponding to the K types of object distances to be predicted based on the result comparison data set, and use the blank data set as a prediction result data set of the verification data set; select each data sub-column corresponding to the remaining object distances from the training data set as a complement data set of the verification data set, wherein the remaining object distances refer to various object distances in the training data set other than the K types of object distances to be predicted.

[0088] In some embodiments, the calculation and verification subunit is specifically used to: take each row component of the complementary data set as the target row component; calculate a first distance data set for the target row component, the first distance data set including the distance data between the target row component and all row components of the test data set; use the KNN algorithm model to calculate the respective optimal focus point values ​​corresponding to the predicted result data set and the target row component based on the multiple nearest neighbor row components of the first distance data set; perform an offset calculation based on the optimal focus point value corresponding to each row component of the result comparison data set and the optimal focus point value corresponding to each row component of the predicted result data set to obtain an offset data set; determine the test accuracy of the KNN algorithm model based on the offset data set, and if the test accuracy reaches a preset accuracy threshold, it indicates that the KNN algorithm model has passed the verification.

[0089] In some embodiments, the calculation and verification subunit is specifically used to: for the current row component of the test data set, use the target distance measurement method to calculate the distance data between the target row component of the complement data set and the current row component of the test data set, and form the first distance data set based on the calculated distance data.

[0090] In some embodiments, the calculation and verification subunit is specifically used to: arrange the first distance data set in ascending order; select multiple nearest neighbor row components from the first distance data set after ascending order according to the number of nearest neighbors customized by the KNN algorithm model to form a nearest neighbor data set; perform arithmetic averaging on each row component of the nearest neighbor data set to obtain a new row component; and use the to-be-predicted column value of the new row component as the optimal focusing point value corresponding to the prediction result data set and the target row component.

[0091] In some embodiments, the calculation verification subunit is specifically used to: calculate the absolute value of the difference between the row components corresponding to the same module identifier of the result comparison data set and the prediction result data set to obtain the offset value of the row component corresponding to the module identifier; and construct the offset data set based on the difference offset value corresponding to each module identifier.

[0092] In some embodiments, the prediction unit 302 is specifically used to: respectively use the N types of object distances as the target object distances to be predicted; for the target object distances to be predicted, calculate a second distance data set between the target camera module and the test data set used by the KNN algorithm model through the target KNN algorithm model, and arrange them in ascending order; according to the customized number of nearest neighbors of the target KNN algorithm model, select multiple nearest neighbor row components from the second distance data set after ascending order; perform mean calculation based on the multiple nearest neighbor row components to predict the optimal focusing point of the target camera module at the target object distance to be predicted.

[0093] The specific functions of each unit in the above-mentioned device have been described in detail in the above-mentioned embodiment of the camera module focus finding method. For the sake of brevity of the description, they will not be repeated here.

[0094] In the third aspect, based on the same inventive concept as the camera module focus search method provided in the above embodiment, the embodiment of this specification also provides a testing device. Figure 4 As shown, the test device includes a memory 404, one or more processors 402, and a computer program stored on the memory 404 and executable on the processor 402. When the processor 402 executes the program, the steps of any implementation method of the camera module focusing method provided in the first aspect above are implemented.

[0095] Among them, Figure 4 In the embodiment of the present invention, a bus architecture (represented by bus 400) is shown. Bus 400 may include any number of interconnected buses and bridges, and bus 400 links together various circuits including one or more processors represented by processor 402 and memory represented by memory 404. Bus 400 may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. Bus interface 405 provides an interface between bus 400 and receiver 401 and transmitter 403. Receiver 401 and transmitter 403 may be the same component, namely a transceiver, which provides a unit for communicating with various other devices over a transmission medium. Processor 402 is responsible for managing bus 400 and general processing, while memory 404 may be used to store data used by processor 402 when performing operations.

[0096] It is understandable that Figure 4 The structure shown is for illustration only. The test equipment provided in the embodiment of this specification may also include Figure 4 More or fewer components than shown, or with Figure 4 Different configurations shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0097] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0098] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that performs the functions specified in one or more boxes.

[0099] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0100] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0101] Although the preferred embodiments of this specification have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of this specification.

[0102] Obviously, those skilled in the art may make various changes and modifications to this specification without departing from the spirit and scope of this specification. Thus, if such changes and modifications fall within the scope of the claims of this specification and their equivalents, this specification is intended to include such changes and modifications.

Claims

1. A camera module focus finding method, characterized in that: include: Test the M best focusing points of the target camera module at M object distances; The M best focusing points are processed based on a pre-built target KNN algorithm model to predict the N best focusing points of the target camera module corresponding to N object distances, including: taking the N object distances as target object distances to be predicted respectively; for the target object distances to be predicted, calculating a second distance data set between the target camera module and the test data set used by the KNN algorithm model through the target KNN algorithm model, and arranging the data sets in ascending order; according to the custom number of nearest neighbors of the target KNN algorithm model, selecting multiple nearest neighbor row components from the second distance data set after ascending order; performing mean calculation based on the multiple nearest neighbor row components to predict the best focusing point of the target camera module at the target object distance to be predicted, wherein the N object distances are different from the M object distances, and M and N are positive integers.

2. The method according to claim 1, wherein The method further comprises the step of pre-building the target KNN algorithm model: Acquire multiple sets of historical test data of a camera module of the same specification, each set of the historical test data including N optimal focus points obtained by testing the same camera module at the N object distances; Divide the multiple sets of historical test data into a training data set, a validation data set, and a test data set; A KNN algorithm model is constructed and verified based on the training data set and the test data set. If the verification passes, the target KNN algorithm model is obtained.

3. The method according to claim 2, wherein The step of dividing the training data set, the validation data set, and the test data set according to the multiple groups of historical test data includes: Randomly divide the multiple sets of historical test data into test data sets and training data sets according to a preset ratio; Selecting K data subcolumns corresponding to K object distances to be predicted from the training data set as a result comparison data set of the validation data set; Generating a blank data set corresponding to the K object distances to be predicted based on the result comparison data set, and using the blank data set as a prediction result data set of the verification data set; Data subcolumns corresponding to the remaining object distances are selected from the training data set as a complementary data set of the validation data set, wherein the remaining object distances refer to various object distances in the training data set except the K object distances to be predicted.

4. The method according to claim 3, wherein The constructing and verifying the KNN algorithm model based on the training data set and the test data set includes: Taking each row component of the complementary data set as a target row component; Calculating a first distance data set for the target row component, where the first distance data set includes distance data between the target row component and all row components of the test dataset; Using a KNN algorithm model, calculate the best focus point values ​​corresponding to the target row component of the prediction result dataset based on the nearest neighbor row components of the first distance dataset; performing an offset calculation based on the optimal focus point value corresponding to each row component of the comparison dataset and the optimal focus point value corresponding to each row component of the prediction result dataset to obtain an offset dataset; The test accuracy of the KNN algorithm model is determined according to the offset data set. If the test accuracy reaches a preset accuracy threshold, it indicates that the KNN algorithm model has passed the verification.

5. The method according to claim 4, wherein The calculating the first distance data set of the target row component includes: For the current row component of the test dataset, a target distance measurement method is used to calculate the distance data between the target row component of the complement dataset and the current row component of the test dataset, and the first distance dataset is formed based on the calculated distance data.

6. The method according to claim 4, wherein The calculating, based on the nearest multiple row components of the first distance dataset, the respective best focus point values ​​corresponding to the prediction result dataset and the target row component, includes: Arranging the first distance data set in increasing order; According to the number of nearest neighbors customized by the KNN algorithm model, multiple row components of the nearest neighbors are selected from the first distance data set arranged in increasing order to form a nearest neighbor data set; Performing arithmetic averaging on each row component of the nearest neighbor data set to obtain a new row component; The to-be-predicted column value of the new row component is used as the optimal focus point value corresponding to the prediction result data set and the target row component.

7. The method according to claim 4, wherein The performing offset calculation based on the best focus point value corresponding to each row component of the result comparison dataset and the best focus point value corresponding to each row component of the prediction result dataset to obtain an offset dataset includes: Calculating the absolute value of the difference between the row components of the result comparison dataset and the prediction result dataset corresponding to the same module identifier to obtain an offset value of the row component corresponding to the module identifier; The offset data set is constructed based on the difference offset values ​​corresponding to the module identifiers.

8. A camera module focus-finding device, characterized in that: include: A testing unit, used to test M optimal focusing points of a target camera module corresponding to M object distances; A prediction unit is used to process the M best focusing points based on a pre-built target KNN algorithm model to predict the N best focusing points of the target camera module corresponding to N object distances, including: respectively taking the N object distances as target object distances to be predicted; for the target object distances to be predicted, calculating a second distance data set between the target camera module and the test data set used by the KNN algorithm model through the target KNN algorithm model, and arranging the data set in ascending order; according to the custom number of nearest neighbors of the target KNN algorithm model, selecting multiple nearest neighbor row components from the second distance data set after ascending order; performing mean calculation based on the multiple nearest neighbor row components to predict the best focusing point of the target camera module at the target object distance to be predicted, wherein the N object distances are different from the M object distances, and M and N are positive integers.

9. A testing device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the method according to any one of claims 1 to 7 are implemented when the processor executes the program.

Citation Information

Patent Citations

  • Method and system for testing batch focus of camera modules

    CN109451304A

  • Focusing method and device, storage medium and electronic equipment

    CN109963072A