High-efficiency and high-precision pixel size conversion method for camera

By creating standard blocks and combining linear regression and cross-validation, the camera calibration process is optimized, and the problem of camera calibration is solved, and efficient and high-precision pixel size conversion is achieved to meet the high-precision needs of industrial manufacturing.

CN120374702APending Publication Date: 2025-07-25CHENGDU AIRCRAFT INDUSTRY GROUP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510324795.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In the prior art, the camera calibration method is cumbersome and takes a long time to meet the high-precision calibration requirements of domestic computers. The conversion of image size and real physical size is inaccurate, and the high-precision requirements of 0.01mm cannot be met.

Method used

Using linear regression and cross-validation methods, we use standard blocks to calculate the scale factor, fit the scale factor model, optimize the calibration process, reduce the camera calibration time, and improve the accuracy of image size measurement.

Benefits of technology

It realizes efficient and high-precision pixel size conversion for camera calibration, improves image measurement accuracy, meets the high-precision needs of industrial manufacturing, and saves calibration time and computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120374702A_ABST
    Figure CN120374702A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a high-efficiency and high-precision pixel size conversion method for a camera, which comprises the following steps of: manufacturing a plurality of standard blocks according to the visual field of the camera to obtain the real physical sizes of the standard blocks; calculating a scale factor of each standard block; fitting a scale factor model by adopting a linear regression mode according to the real physical size of each standard block and the scale factor of the corresponding standard block; evaluating the scale factor model; and optimizing the scale factor model through cross validation. Through the method, the camera calibration time can be shortened, and the accuracy of image size measurement is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and particularly to a method for efficiently and accurately converting pixel sizes of a camera. Background Art

[0002] Sealing is an important process in aircraft manufacturing and maintenance. Generally, rubber O-rings are used as sealing materials for aviation products. The inner and outer diameters and cross-sectional dimensions of O-rings are important characteristics for measuring the manufacturing quality of O-rings. Since the cross-sectional dimension is very small compared to the inner and outer diameters, manual caliper measurement often cannot meet the high-precision requirement of 0.01 mm. To improve the measurement accuracy and efficiency, an optical projection imaging method is currently used for measurement. By taking a projection image of the O-ring on a plane, then obtaining the rubber ring contour through an algorithm, and then performing the conversion between the image size and the actual physical size to obtain the inner and outer diameters of the O-ring, and finally obtaining the cross-sectional dimension by taking the difference between the inner and outer diameters. A key step is the conversion between the image size and the actual physical size. Affected by factors such as camera distortion and the position of the camera optical axis relative to the shooting platform, the conversion between the image size and the actual physical size is not an absolute linear relationship and cannot be obtained through simple proportional calculation.

[0003] In the prior art, a Chinese invention patent document with a publication number of CN113012234A and a publication date of June 22, 2021 was proposed. The technical solution disclosed in this patent document is as follows: A high-precision camera calibration method based on planar transformation, including the following steps: S1: On a planar calibration board with circles as marker points, extract the corner points on the inner and outer frames of the calibration board and accurately determine the coordinates of the corner points to the sub-pixel level, and project the ellipse into an approximate standard circle through perspective transformation; S2: Use image moments to calculate the centroid to complete the extraction of the coordinates of the center of the standard circle; S3: Project the extracted center coordinates back to the original calibration board plane through inverse perspective transformation to obtain the actual pixel coordinates of the center of the marker point; S4: Complete camera calibration according to the pixel coordinates and spatial coordinates corresponding to the center of the circular marker point in combination with the Zhang Zhengyou calibration method.

[0004] For the calibration method proposed in the above technical solution, it is necessary to perform corner point calculations on a calibration board with circles as marker points, and then perform calibration through the center coordinates and the Zhang Zhengyou calibration method. In actual use, the following problems will occur: The operation is cumbersome, and the corner point calculation time depends on the computer performance and the accuracy of the calibration board. This method is not suitable for high-precision calibration of domestic computers and takes a long time. Summary of the Invention

[0005] To solve the above technical problems, the present invention proposes a method for efficiently and accurately converting pixel sizes of a camera, which can reduce the camera calibration time and improve the accuracy of image size measurement.

[0006] The present invention is realized by adopting the following technical solutions:

[0007] An efficient and high-precision pixel size conversion method for a camera, comprising the following steps:

[0008] Step S1. Make a number of standard blocks according to the camera field of view, and obtain the actual physical size of the standard blocks;

[0009] Step S2. Calculate the scale factor of each standard block;

[0010] Step S3. According to the actual physical size of each standard block and the corresponding standard block scale factor, fit the scale factor model by means of linear regression;

[0011] Step S4. Evaluate the scale factor model;

[0012] Step S5. Optimize the scale factor model through cross-validation.

[0013] The specific steps of the said Step S1 include the following steps:

[0014] Step S 11 . Determine the standard block diameter size interval and the diameter size of the standard block according to the camera field of view size and the number of standard blocks;

[0015] Step S 12 . Process the standard blocks and ensure the dimensional accuracy of the standard blocks.

[0016] If the camera field of view size is M×N, the method for determining the standard block diameter size interval is:

[0017]

[0018] The method for determining the diameter size of the standard block is:

[0019] I={i, 2i,......, n·i}

[0020] In the formula, i is the standard block diameter size interval, I is the diameter size of the standard block, represents rounding down.

[0021] The specific steps of the said Step S2 include the following steps:

[0022] Step S 21 . Collect the original image S of the standard block, and preprocess the original image S to obtain the transformed image F;

[0023] Step S 22 . Extract all the contours on the image F;

[0024] Step S 23 . Calculate the pixel area of each contour, and set the contour filtering threshold thres according to the minimum rubber ring pixel area S0 to be measured:

[0025]

[0026] Step S 24 . Retain the contours above the contour filtering threshold. If the actual number of retained contours is greater than the theoretical value, increase the contour filtering threshold until the theoretical contour quantity is satisfied;

[0027] Step S 25 . Through ellipse fitting, calculate the major axis a and minor axis b of the retained contours, and thus calculate the diameter d:

[0028]

[0029] Step S 26 . Obtain the scale factor g:

[0030]

[0031] where t is the actual physical size of the standard block;

[0032] Step S 27 . Repeat Step S 21 ~Step S 26 , and obtain n scale factors of the standard block diameters, which are {g1, g2,......, g n}.

[0033] Preprocess the original image S, including converting the original image to a grayscale image, image inversion, and thresholding.

[0034] The thresholding specifically refers to: using an adaptive threshold algorithm to select the threshold by maximizing the between-class variance, setting the pixels of the standard block to 255, and the rest to 0.

[0035] The specific steps of Step S3 are as follows:

[0036] Step S 31 . Divide the data into a training set and a test set, and set the division point to j; where the data includes the scale factor of each standard block and the corresponding actual physical size;

[0037] Step S 32 . Perform a natural logarithm transformation on the actual physical sizes of the training set;

[0038] Step S 33 . Use linear regression fitting and the differential method to find the extreme value, so as to obtain the scale factor model.

[0039] The specific evaluation of the scale factor model refers to: using the root mean square error of the test set and the R of the training set 2 as the evaluation index.

[0040] Step S4 specifically includes the following steps:

[0041] Step S 41 . Calculate the predicted value, which specifically includes the following steps:

[0042] Through step S 21 ~Step S 27 Obtain a series of standard block pixel sizes {d1, d2,......, d n} and the corresponding scale factors {g1, g2,......, g n}, select the middle scale factor, denoted as g0; Calculate the initially estimated physical size according to the following method

[0043]

[0044] Substitute the initially estimated physical size into the scale factor model to obtain the predicted values of the scale factors for the corresponding training set and test set Then obtain the finally estimated standard block physical size through the following method

[0045]

[0046] Step S 42 . Calculate the root mean square error of the test set and the training set R 2 .

[0047] Step S5 specifically includes the following steps:

[0048] Step S 51 . Divide n groups of standard block data {(t i , g i ), i = 1, 2, ……, n} into k equal parts;

[0049] Step S 52 . Divide the data set into a training set and a test set to obtain kinds of data partitioning methods; where p is the number of parts of the training set;

[0050] Step S 53 . For each of the training sets in the 52 kinds of data partitions in step S , perform linear fitting one by one to obtain the corresponding scale factor model, and then evaluate the scale factor model respectively. Finally, obtain a series of scale factor models and the corresponding evaluation indicators;

[0051] Step S 54 . Select the scale factor model according to the evaluation indicators.

[0052] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0053] 1. Through the high-efficiency and high-precision pixel size conversion method of the camera in the present invention, the camera calibration time can be reduced, and the accuracy of image size measurement can be improved. Specifically, the present invention combines camera calibration with linear regression, fits the scale factor model based on statistical methods, reduces the complexity of traditional camera calibration, improves the camera calibration accuracy, and approximates the true value to the greatest extent. Then, cross-validation is used to optimize the scale factor model. Based on the root mean square error of the test set and the R 2 of the training set, the quality of the scale factor model is measured from two angles, so as to select the best scale factor model.

[0054] 2. This method performs scale factor conversion based on linear regression, and improves the measurement accuracy of the O-ring vision measurement system to 0.01 mm, meeting the high-precision requirements of industrial manufacturing.

[0055] 3. This method is based on the calibration of circular standard blocks. Compared with the calibration of a 0.01 mm ceramic black-and-white grid calibration plate, it saves the time for calculating the corner points and adjusting the calibration plate. Assuming that a domestic industrial computer is used to calculate the corner points of a single calibration plate, it takes 10 minutes for one, and generally 10 calibration plate pictures are taken, totaling 100 minutes. Using this set of methods, it takes 30 seconds to take a picture of a circular calibration standard block. Assuming 10 pictures are taken and the model fitting takes 10 minutes, the total is 15 minutes, and the calibration efficiency is increased by 85%. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The present invention will be further described in detail below in conjunction with the drawings in the specification and specific embodiments, wherein:

[0057] Figure 1 is a schematic flow chart of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0058] Embodiment 1

[0059] As a basic embodiment of the present invention, the present invention includes a high-efficiency and high-precision pixel size conversion method for a camera, comprising the following steps:

[0060] Step S1. Make a number of standard blocks according to the camera field of view to obtain the actual physical size of the standard blocks.

[0061] Step S2. Calculate the scale factor of each standard block.

[0062] Step S3. According to the actual physical size of each standard block and the corresponding standard block scale factor, fit the scale factor model by means of linear regression.

[0063] Step S4. Evaluate the scale factor model.

[0064] Step S5. Optimize the scale factor model through cross - validation.

[0065] Embodiment 2

[0066] As a preferred embodiment of the present invention, the present invention includes a method for efficient and high - precision pixel size conversion of a camera, comprising the following steps:

[0067] Step S1. Make a number of standard blocks according to the camera field of view and obtain the actual physical size of the standard blocks.

[0068] Step S2. Calculate the scale factor of each standard block.

[0069] Step S3. Fit the scale factor model by linear regression according to the actual physical size of each standard block and the corresponding scale factor of the standard block. Specifically, it includes the following steps:

[0070] Step S 31 . Divide the data into a training set and a test set, and set the division point as j. Among them, the data includes the scale factor of each standard block and the corresponding actual physical size.

[0071] Step S 32 . Perform a natural logarithm transformation on the actual physical size of the training set.

[0072] Step S 33 . Use linear regression to fit and find the extreme value by the differential method to obtain the scale factor model.

[0073] Step S4. Evaluate the scale factor model to obtain its evaluation index. The evaluation index includes the root - mean - square error of the test set and the R of the training set 2 .

[0074] Step S5. Optimize the scale factor model through cross - validation. Specifically, it includes the following steps:

[0075] Step S 51 . Divide the n - group standard block data {(t i , g i ), i = 1, 2, ……, n} into k equal parts.

[0076] Step S 52 . Divide the data set into a training set and a test set to obtain data division methods; where p is the number of parts of the training set.

[0077] Step S 53 . For each of the training sets of the 52 data divisions in Step S , perform linear fitting one by one to obtain the corresponding scale factor model, then evaluate the scale factor model respectively, and finally obtain a series of scale factor models and corresponding evaluation indexes.

[0078] Step S 54 . Screen the scale factor model according to the evaluation index.

[0079] Embodiment 3

[0080] As another preferred embodiment of the present invention, the present invention includes a method for efficient and high-precision pixel size conversion of a camera, comprising the following steps:

[0081] Step S1. Make a number of standard blocks according to the camera field of view to obtain the actual physical size of the standard blocks. Specifically, it includes the following steps:

[0082] Step S 11 . Determine the standard block diameter size interval and the diameter size of the standard blocks according to the camera field of view size and the number of standard blocks.

[0083] Step S 12 . Process the standard blocks and ensure the dimensional accuracy of the standard blocks.

[0084] Step S2. Calculate the scale factor of each standard block. Specifically, it includes the following steps:

[0085] Step S 21 . Collect the original image S of the standard block and preprocess the original image S to obtain the transformed image F.

[0086] Step S 22 . Extract all the contours on the image F.

[0087] Step S 23 . Calculate the pixel area of each contour, and set the contour filtering threshold thres according to the minimum rubber ring pixel area S0 to be measured:

[0088]

[0089] Step S 24 . Retain the contours above the contour filtering threshold. If the actual number of retained contours is greater than the theoretical value, increase the contour filtering threshold until the theoretical contour quantity is satisfied.

[0090] Step S 25 . Through ellipse fitting, calculate the major axis a and minor axis b of the retained contours, and thus calculate the diameter d:

[0091]

[0092] Step S 26 . Obtain the scale factor g:

[0093]

[0094] Wherein, t is the actual physical size of the standard block.

[0095] Step S 27 . Repeat step S 21 ~ step S 26 , and obtain the scale factors of the diameters of n standard blocks, which are {g1, g2,......, g n}}.

[0096] Step S3. According to the actual physical sizes of the standard blocks and the corresponding scale factors of the standard blocks, fit the scale factor model by means of linear regression.

[0097] Step S4. Evaluate the scale factor model.

[0098] Step S5. Optimize the scale factor model through cross-validation.

[0099] Embodiment 4

[0100] As another preferred embodiment of the present invention, the present invention includes a method for efficiently and accurately converting pixel sizes of a camera, comprising the following steps:

[0101] Step S1. Make a number of standard blocks according to the camera field of view to obtain the actual physical sizes of the standard blocks. Specifically, it includes the following steps:

[0102] Step S 11 . Determine the diameter size interval of the standard block and the diameter size of the standard block according to the size of the camera field of view and the number of standard blocks. Specifically, if the size of the camera field of view is M×N, in millimeters, and the number of required standard blocks is n (n≥5), the method for determining the diameter size interval of the standard block is:

[0103]

[0104] Wherein, i is the diameter size interval of the standard block, represents rounding down. If the camera field of view is less than 5 mm, the diameter size interval of the standard block is 1 mm.

[0105] The method for determining the diameter size I of the standard block is:

[0106] I = {i, 2i,......, n·i}.

[0107] Step S 12 . Process the standard block and ensure the dimensional accuracy of the standard block. Specifically, the standard block can be processed by a high-precision processing device. The material is stainless steel, the shape is cylindrical, the height of the cylinder is 5 mm, and the diameter of the bottom circle is the diameter size I set in step S 11 , and the accuracy is at least 0.01 mm.

[0108] Further, to ensure high precision, the standard block needs to be measured by a metrology station at or above the third level to ensure the dimensional accuracy of the standard block. The measurement accuracy must be above 0.01 mm. Thus, the actual physical dimensions of the diameter of the standard block are obtained: {t1, t2, ……, t n}.

[0109] Step S2. Calculate the scale factor of each standard block, which specifically includes the following steps:

[0110] Step S 21 . Collect the original image S of the standard block and preprocess the original image S to obtain the transformed image F. Among them, preprocessing the original image S includes converting the original image to a grayscale image, image inversion, and threshold processing. Specifically, place the standard block in the center of the camera's field of view. The standard block is directly above the light source, and backlight shooting is used to obtain the original image S. If the camera is a color camera, convert the original image to a grayscale image. At this time, the image background is white and the standard block is black. For image inversion, swap the black and white colors of the image. For each pixel value of the original image, perform the following operation:

[0111] f = 255 - s, s ∈ S,

[0112] where s is each pixel value of the original image.

[0113] The threshold processing specifically refers to: using the adaptive threshold algorithm (1979, maximum inter-class variance method) to select the threshold by maximizing the inter-class variance, setting the pixels of the standard block to 255, and the rest to 0, to obtain the transformed image F.

[0114] Step S 22 . Use the openCV contour extraction algorithm to extract all the contours on the image F.

[0115] Step S 23 . Calculate the pixel area of each contour, and set the contour filtering threshold thres according to the minimum pixel area S0 of the rubber ring to be measured:

[0116]

[0117] Among them, the minimum pixel area S0 of the rubber ring can be obtained by replacing the standard block with a rubber ring for measurement in the manner of Step S 21 ~Step S 22 to obtain the outer contour, and the pixel area of this contour is S0.

[0118] Step S 24 . Retain the contours above the contour filtering threshold and remove the contours below the contour filtering threshold. At this time, the number of retained contours is 1. If the actual number of retained contours is greater than the theoretical value, the contour filtering threshold can be increased in steps of 100 until the theoretical number of contours is satisfied.

[0119] Step S 25 . Use the ellipse fitting algorithm of openCV to calculate the major axis a and minor axis b of the remaining contours, and then calculate the diameter d:

[0120]

[0121] Step S 26 . Divide the pixel diameter d by the corresponding actual physical size t to obtain the scale factor g:

[0122]

[0123] Step S 27 . Repeat Step S 21 ~Step S 26 , and obtain the scale factors of the diameters of n standard blocks, which are {g1, g2,......, g n}.

[0124] Step S3. According to the actual physical sizes of the standard blocks and the corresponding standard block scale factors, use linear regression to fit the scale factor model. Specifically, it includes the following steps:

[0125] Step S 31 . At this time, the data participating in the fitting is as shown in the following table:

[0126] Serial number 1 2 …… n Actual physical size t <![CDATA[t1]]> <![CDATA[t2]]> …… <![CDATA[t n > Scale factor g <![CDATA[g1]]> <![CDATA[g2]]> …… <![CDATA[g n >

[0127] Divide the data into a training set and a test set according to 9:1, 8:2, 7:3, 6:4 or 5:5. Set the division point as j, then the data is organized as shown in the following table:

[0128]

[0129] Step S 32 . Perform a natural logarithm transformation on the actual physical sizes of the training set, that is:

[0130] b i = ln(t i ), i = 1, 2, ……, j.

[0131] Then the data is organized as shown in the following table:

[0132]

[0133] Step S 33 . Use linear regression fitting and use the differential method to find the extreme value, so as to obtain the scale factor model. Among them, using linear regression fitting means minimizing:

[0134]

[0135] Use the differential method to find the extreme value, that is:

[0136]

[0137] Specifically:

[0138]

[0139] The solution is:

[0140]

[0141] Among them,

[0142] Thus, the scale factor model is obtained:

[0143]

[0144] Step S4. Evaluate the scale factor model. Use the root mean square error of the test set and the training set R 2 as the evaluation index. Specifically, it includes the following steps:

[0145] Step S 41 . Calculate the predicted value, specifically including the following steps:

[0146] Through steps S 21 ~Step S 27 A series of standard block pixel sizes {d1, d2,..., d n} and the corresponding scale factors {g1, g2,..., g n} are obtained. Select the middle scale factor (if n is even, select the two middle ones and take the average), denoted as g0. Calculate the initially estimated physical size according to the following method

[0147]

[0148] Substitute the initially estimated physical size into the scale factor model in step S 33 to obtain the scale factor predicted values for the corresponding training set and test set Then, obtain the finally estimated standard block physical size through the following method

[0149] Arrange the table as follows:

[0150]

[0151] Step S 42. Calculate the root mean square error of the test set and R of the training set 2 . Among them, the calculation method of the root mean square error RMSE is as follows:

[0152]

[0153] R 2 . The calculation method is as follows:

[0154]

[0155] Among them,

[0156] Step S5. Optimize the scale factor model through cross-validation. Specifically, it includes the following steps:

[0157] Step S 51 . Divide n groups of standard block data {(t i , g i ), i = 1, 2,..., n} into k equal parts, k ≤ n, k = 5, 10. If the number of standard blocks is not an integer multiple of k, round it to the nearest integer. The specific number allocation is as follows:

[0158]

[0159] Among them, <> means rounding to the nearest integer.

[0160] Step S 52 . Divide the data set into a training set and a test set. Refer to Step S 31 . If k = 5, divide it into a training set and a test set according to 4:1 and 3:2. If k = 10, divide it into a training set and a test set according to 9:1, 8:2, 7:3, 6:4 or 5:5. After selecting the division ratio, assuming the number of parts of the training set is p, according to the combination formula, then there are a total of data division methods. Among them, . The specific determination method is:

[0161]

[0162] Step S 53 . For each of the 52 data divisions of the training set in Step S , perform linear fitting one by one according to Step S 32 to Step S 33 to obtain the corresponding scale factor model. Then evaluate the scale factor model separately, and calculate the root mean square error RMSE and R 41 to 42 through Step S 2 . Finally, obtain a series of scale factor models and corresponding evaluation indicators.

[0163] Step S 54 . Select the scale factor model according to the evaluation index. Specifically, the smaller the root mean square error, the better, and the 2 larger the is better. If there is a model in the scale factor models in step S3 that can meet the minimum root mean square error and the maximum 2 , then this model is the best scale factor model. If not, set the root mean square error threshold to 0.01 and the 2 threshold to 99%. Select from the scale factor models in step S3 those with a root mean square error less than 0.01 and a 2 greater than 99%. Then calculate the average values of and respectively to obtain the best scale factor model.

[0164] Example 5

[0165] As another preferred embodiment of the present invention, the present invention includes a method for efficient and high-precision pixel size conversion of a camera, comprising the following steps:

[0166] Step S1. Make a number of standard blocks according to the camera field of view to obtain the actual physical size of the standard blocks. Specifically, it includes the following steps:

[0167] Step S 11 . The size of the camera field of view of the vision measurement system is 50×50, with the unit of millimeter, the number of required standard blocks is n = 5, and the diameter size interval of the standard blocks is . Among them, the symbol is for rounding down. Then the diameter sizes are: I = {10, 20,..., 50}.

[0168] Step S 12 . Process the standard blocks through a high-precision processing device. The material is stainless steel, the shape is cylindrical, the height of the cylinder is 5 mm, the diameter of the bottom circle is the above-set diameter I, and the precision is 0.01 mm.

[0169] Step S 13 . The standard blocks are measured by a metrology station above level three to obtain the actual physical sizes {t1, t2,..., t n} = {10.000 mm, 20.000 mm, 30.000 mm, 40.000 mm, 50.000 mm} of the diameters of the standard blocks.

[0170] Step S2. Calculate the scale factor of each standard block, specifically including the following steps:

[0171] Step S 21. Place the standard block at the center of the camera's field of view. The standard block is located directly above the light source. Take a backlight shot to obtain the original image S. The camera is a black-and-white camera. At this time, the image background is white and the standard block is black.

[0172] Invert the image, swap the black and white colors of the image. For each pixel value of the original image, perform the following operation:

[0173] f = 255 - s, s ∈ S,

[0174] where s is each pixel value of the original image.

[0175] Threshold processing, use the adaptive threshold algorithm to select the threshold by maximizing the between-class variance. The threshold is 150. Set the pixels of the standard block to 255 and the rest to 0. The transformed image is F.

[0176] Step S 22 . Use the openCV contour extraction algorithm to extract all the contours on the image F.

[0177] Step S 23 . Calculate the pixel area of each contour. According to the minimum pixel area S0 of the rubber ring to be measured, set the contour filtering threshold, that is, the filtering threshold thres is:

[0178]

[0179] where S0 is obtained by replacing the standard block with the rubber ring measurement in the way of Step S 21 ~Step S 22 to obtain the outer contour. The pixel area of this contour is S0.

[0180] Step S 24 . Retain the contours above the filtering threshold and remove the contours below the filtering threshold. At this time, the number of retained contours is 1.

[0181] Step S 25 . Use the ellipse fitting algorithm of openCV to calculate the major axis a and minor axis b of the retained contour, and then estimate the diameter d:

[0182]

[0183] Step S 26 . Divide the pixel diameter d by the corresponding actual physical size t to obtain the scale factor g:

[0184]

[0185] Step S 27 . Repeat Step S 21 ~Step S 26, the proportionality factors of the diameters of n standard blocks are obtained, which are {g1, g2, ……, g n} = {36.22, 36.68, 36.95, 37.14, 37.29}.

[0186] Step S3. According to the actual physical sizes of the standard blocks and the corresponding proportionality factors of the standard blocks, a proportionality factor model is fitted by means of linear regression. Specifically, it includes the following steps:

[0187] Step S 31 . At this time, the data participating in the fitting is shown in the following table:

[0188] Serial number 1 2 …… n Actual physical size t <![CDATA[t1]]> <![CDATA[t2]]> …… <![CDATA[t n > Scale factor g <![CDATA[g1]]> <![CDATA[g2]]> …… <![CDATA[g n >

[0189] Divide the data, and divide the data into a training set and a test set according to 6:4. Set the division point to 3, then the data is organized as shown in the following table:

[0190]

[0191] Step S 32 . Perform a natural logarithm transformation on the actual physical sizes of the training set, that is: b i = ln(t i ), i = 1, 2, ……, j,

[0192] Then the data is organized as shown in the following table:

[0193]

[0194] Step S 33 . Perform linear regression fitting, that is, minimize:

[0195]

[0196] Use the differential method to find the extreme value, that is

[0197]

[0198] Specifically:

[0199]

[0200] The solution is:

[0201]

[0202] Among them, Thus, the proportionality factor model is obtained:

[0203] g = 34.68 + 0.6667ln(t).

[0204] Step S4. Evaluate the scale factor model. Use the root mean square error of the test set and the training set R 2 as the evaluation indicators. Specifically, it includes the following steps:

[0205] Step S 41 . Calculate the predicted values. Through Step S 21 ~Step S 27 obtain a series of standard block pixel sizes {d1, d2, ……, d5} and the corresponding scale factors {g1, g2, ……, g5}, select the middle scale factor, denoted as g0 = 36.95. Calculate the initially estimated physical size according to the following method

[0206]

[0207] For Step S 33 calculate the scale factor model, substitute the data to obtain the predicted scale factor values for the corresponding training set and test set and then obtain the finally estimated standard block physical size through the following method

[0208]

[0209] Arrange the table as follows:

[0210]

[0211] Step S 42 . Calculate the root mean square error of the test set. Calculate the root mean square error RMSE of the test set according to the following formula:

[0212]

[0213] Step S 43 . Calculate the training set R 2 , calculate R according to the following formula 2 :

[0214]

[0215] Among them,

[0216] Step S5. Optimize the scale factor model through cross-validation. Specifically, it includes the following steps:

[0217] Step S 51 . First, divide the 5 groups of standard block data {(t i , g i ), i = 1, 2, ……, 5} into 5 equal parts, with each part being a group of data.

[0218] Step S 52 . Divide the data set into a training set and a test set, referring to Step S 31 . Divide it into a training set and a test set according to a ratio of 3:2. After determining the division ratio, the number of parts of the training set is 3. According to the combination formula, there are a total of 10 data division methods.

[0219] Step S 53 . For the training sets of the 10 data divisions in Step S 52 , perform linear fitting one by one according to S 32 ~Step S 33 . Then the corresponding scale factor model can be obtained. Then, through Step S 41 ~Step S 43 , calculate the root mean square error RMSE and R 2 . Finally, a series of scale factor models and corresponding evaluation indicators are obtained.

[0220] Step S 54 . Screen the model. The smaller the root mean square error, the better, and the larger R 2 . The larger the better. At this time, the model g = 34.68 + 0.6667ln(t) meets the requirements.

[0221] In summary, after those of ordinary skill in the art read the present invention document, all other corresponding transformation schemes made without creative mental labor according to the technical solutions and technical concepts of the present invention fall within the scope protected by the present invention.

Claims

1. An efficient and high-precision pixel size conversion method for a camera, characterized in that: It includes the following steps: Step S1. Make a number of standard blocks according to the camera's field of view, and obtain the actual physical size of the standard blocks; Step S2. Calculate the scale factor of each standard block; Step S3. According to the actual physical size of each standard block and the corresponding scale factor of the standard block, fit the scale factor model by means of linear regression; Step S4. Evaluate the scale factor model; Step S5. Optimize the scale factor model through cross-validation.

2. The high-efficiency and high-precision pixel size conversion method of a camera according to claim 1, wherein: The specific steps of the said Step S1 include the following steps: Step S 11 . Determine the standard block diameter size interval and the diameter size of the standard block according to the camera field of view size and the number of standard blocks; Step S 12 . Process the standard block and ensure the dimensional accuracy of the standard block.

3. The high-efficiency and high-precision pixel size conversion method for a camera according to claim 2, wherein: If the size of the camera's field of view is M×N, the method for determining the diameter size interval of the standard block is: The method for determining the diameter size of the standard block is: I = {i, 2i,......, n·i} Where i is the interval of the standard block diameter dimension and I is the diameter dimension of the standard block, represents rounding down.

4. A method for efficient and high-precision pixel size conversion of a camera according to claim 1, characterized in that: The specific steps of the said Step S2 include the following steps: Step S 21 .Collect the original image S of the standard block and preprocess the original image S to obtain the transformed image F; Step S 22 .Extract all the contours on the image F; Step S 23 . Calculate the pixel area of each contour, and set the contour filtering threshold thres according to the minimum pixel area S0 of the rubber ring to be measured: Step S 24 . Retain the contours above the contour filtering threshold. If the actual number of retained contours is greater than the theoretical value, increase the contour filtering threshold until the theoretical contour quantity is satisfied; Step S 25 . By ellipse fitting, calculate the major axis a and minor axis b of the retained contour, and thus calculate the diameter d: Step S 26 . Obtain the scale factor g: In the formula, t is the actual physical size of the standard block; Step S 27 . Repeat Step S 21 ~ Step S 26 , and obtain the scale factors of the diameters of n standard blocks, which are {g1, g2,......, g n}.

5. The high-efficiency and high-precision pixel size conversion method for a camera according to claim 4, characterized in that: The preprocessing of the original image S includes converting the original image into a grayscale image, image inversion, and threshold processing.

6. The high-efficiency and high-precision pixel size conversion method for a camera according to claim 5, wherein: The specific threshold processing refers to: using an adaptive threshold algorithm to select the threshold by maximizing the between-class variance, setting the pixels of the standard block to 255, and the rest to 0.

7. A method for efficient and high-precision pixel size conversion of a camera according to claim 4, characterized in that: The specific steps of the said Step S3 include the following steps: Step S 31 . Divide the data into a training set and a test set, and set the division point as j; where the data includes the scale factor of each standard block and the corresponding actual physical size; Step S 32 . Perform a natural logarithm transformation on the actual physical size of the training set; Step S 33 . Adopt linear regression fitting and use the differential method to find the extreme value, so as to obtain the scale factor model.

8. A method for efficiently and highly accurately converting pixel sizes of a camera according to claim 7, characterized in that: The specific evaluation ratio factor model refers to: using the root mean square error of the test set and the R of the training set 2 as the evaluation index.

9. A method for efficient and high-precision pixel size conversion of a camera according to claim 8, characterized in that: The specific steps of the said Step S4 include the following steps: Step S 41 . Calculate the predicted value, which specifically includes the following steps: Through step S 21 ~ step S 27 A series of standard block pixel sizes {d1, d2,......, d n} and corresponding scale factors {g1, g2,......, g n} are obtained. Select the middle scale factor and denote it as g0; The initial estimated physical size is calculated according to the following method Substitute the initially estimated physical size into the scale factor model to obtain the predicted scale factor values for the corresponding training set and test set and then obtain the finally estimated physical size of the standard block through the following method Step S 42 . Calculate the root mean square error of the test set and the training set R 2 .

10. A method for efficient and high-precision pixel size conversion of a camera according to claim 4, characterized in that: The specific steps of the said Step S5 include the following steps: Step S 51 . Divide n groups of standard block data {(t i , g i ), i = 1, 2,..., n} into k equal parts; Step S 52 . Divide the data set into a training set and a test set to obtain data partitioning methods; where p is the number of parts of the training set; Step S 53 . For each of the training sets divided by the 52 types of data in step S, perform linear fitting one by one to obtain the corresponding scale factor models, then evaluate the scale factor models respectively, and finally obtain a series of scale factor models and the corresponding evaluation indicators; Step S 54 . Screen the scale factor model according to the evaluation index.

Citation Information

Patent Citations

  • High-precision camera calibration method based on plane transformation

    CN113012234A