A method, device, medium and equipment for determining camera module distortion parameters

CN122289397APending Publication Date: 2026-06-26KUNSHAN QIUTI PHOTOELECTRIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
KUNSHAN QIUTI PHOTOELECTRIC TECH CO LTD
Filing Date
2026-03-26
Publication Date
2026-06-26

Smart Images

  • Figure CN122289397A_ABST
    Figure CN122289397A_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, medium, and device for determining distortion parameters of a camera module. The method requires only capturing one image of a checkerboard pattern and performing anti-distortion processing on the corner points of the checkerboard image to reduce deviations caused by image distortion. Furthermore, through homography matrix transformation, perspective distortion caused by the shooting angle is reduced, minimizing the impact of perspective interference on distortion parameters. Then, through fine-tuning of distortion parameters, anti-distortion processing, and closed-loop processing of matrix deviation, the distortion parameters are ensured to always be optimized towards the direction of minimum deviation. The final target distortion parameters closely match the true distortion characteristics of the camera module under test, ensuring the accuracy of distortion parameter determination. The entire testing process does not require limiting the shooting environment or capturing multiple images for analysis, making the operation relatively simple and thus improving the efficiency of distortion parameter determination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of camera parameter calibration technology, and in particular to a method, apparatus, medium and device for determining the distortion parameters of a camera module. Background Technology

[0002] Before leaving the factory, the vehicle camera module needs to be calibrated internally, and the deviation between the distortion center and the image center needs to be controlled. In order to reduce the defect rate caused by large deviations, the distortion center needs to be quickly calculated in the active alignment process (AA) to adjust the relative position of the lens and the image sensor.

[0003] In related technologies, Zhang's calibration method is generally used to calibrate the intrinsic parameters of camera modules. This involves taking pictures of the chessboard pattern in different poses and calculating the module's inherent intrinsic parameters, distortion data, and extrinsic parameters for each pose. However, this calibration method is cumbersome and has very high requirements for the image capture environment.

[0004] Therefore, there is an urgent need for a method to determine the distortion parameters of a camera module in order to improve the efficiency of determining the distortion parameters of a camera module. Summary of the Invention

[0005] To address the problems existing in the prior art, embodiments of the present invention provide a method, apparatus, medium, and device for determining the distortion parameters of a camera module, thereby solving or partially solving the technical problem that the operation of determining the distortion parameters of a camera module is relatively complex, thus affecting the efficiency of determining the distortion parameters.

[0006] A first aspect of the present invention provides a method for determining distortion parameters of a camera module, the method comprising: S1, determine the initial corner points of the chessboard image; S2, under the initial distortion parameters, perform anti-distortion processing on the initial chessboard corner points to obtain the target chessboard corner points; S3, determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, determine the homography matrix based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid. S4, determine the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points; S5, determine the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, adjust the initial distortion parameters and repeat steps S2 to S4 until the matrix deviation meets the requirements. Output the adjusted target distortion parameters. The reference chessboard corner point matrix includes all reference chessboard corner points.

[0007] In the above scheme, determining the initial corner points of the chessboard image includes: The chessboard image is preprocessed to obtain a preprocessed image; The preprocessed image is traversed to select all gradient extreme points as candidate corner points; From the candidate corner points, a seed point is selected as the starting point, and candidate corner points that meet the distance requirements are searched step by step along the horizontal and vertical directions to obtain the target corner point; Determine whether the consistency of the target corner point meets the requirements. If so, determine the target corner point as the initial chessboard corner point.

[0008] In the above scheme, determining the straightness deviation of the target chessboard corner points includes: For each row and column of the target chessboard corner point in the chessboard image, the least squares method is used to fit the target chessboard corner point in each row and column to obtain the corresponding first straight line and second straight line. Determine the first perpendicular distance between each target chessboard corner point in each row and the first straight line, and determine the second perpendicular distance between each target chessboard corner point in each column and the second straight line; Determine a first sum of squares for each of the first vertical distances and determine a second sum of squares for each of the second vertical distances; The first sum of squares and the second sum of squares are determined as the straightness deviation.

[0009] In the above scheme, if the straightness deviation does not meet the preset requirements, the method further includes: With the goal of reducing the straightness deviation, the initial distortion parameters are iteratively optimized until the iteration conditions are met, and the required initial distortion parameters are output. Under the required initial distortion parameters, the initial chessboard corner points are re-distorted to obtain the target chessboard corner points.

[0010] In the above scheme, determining the homography matrix based on the corner points of the full square matrix includes: Obtain the actual coordinates of each target chessboard corner point in the Cartesian coordinate system and the theoretical coordinates of each target chessboard corner point in the world coordinate system; The actual coordinates are converted into first homogeneous coordinates, and the theoretical coordinates are converted into second homogeneous coordinates. The homography matrix is ​​determined based on the first homogeneous coordinates, the second homogeneous coordinates, and the scale factor.

[0011] In the above scheme, determining the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points includes: Multiply the actual coordinates of the target chessboard corner point in the Cartesian coordinate system with the homography matrix to obtain the third homogeneous coordinates of the target chessboard corner point; The third homogeneous coordinates are converted into actual coordinates in the world plane coordinate system, and the reference chessboard corner points are determined based on the actual coordinates in the world plane coordinate system.

[0012] In the above scheme, determining the square deviation of the reference chessboard corner point square matrix includes: Determine the Euclidean distance between the actual coordinates and the corresponding theoretical coordinates of each reference chessboard corner point in the reference chessboard corner point matrix; The average value of all Euclidean distances is determined as the matrix deviation of the reference chessboard corner point matrix.

[0013] A second aspect of the present invention provides an apparatus for determining distortion parameters of a camera module, the apparatus comprising: The first determining unit is used to execute S1, determine the initial chessboard corner points of the chessboard image, and perform anti-distortion processing on the initial chessboard corner points under preset initial distortion parameters to obtain the target chessboard corner points. The second determining unit is used to execute S2 to determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, the homography matrix is ​​determined based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid. The third determining unit is used to execute S3, which determines the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points. The fourth determining unit is used to execute S5 to determine the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, the initial distortion parameters are adjusted. Steps S2 to S4 are executed repeatedly until the matrix deviation meets the requirements, and the adjusted target distortion parameters are output.

[0014] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in any of the first aspects.

[0015] A fourth aspect of the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the steps of the method described in any of the first aspects.

[0016] This invention provides a method, apparatus, medium, and device for determining distortion parameters of a camera module. The method includes: S1, determining initial checkerboard corner points of a checkerboard image; S2, performing anti-distortion processing on the initial checkerboard corner points under the initial distortion parameters to obtain target checkerboard corner points; S3, determining the straightness deviation of the target checkerboard corner points; if the straightness deviation meets a preset requirement, determining a homography matrix based on the full matrix corner points; the full matrix corner points are the corner point matrix determined based on the target checkerboard corner points; S4, determining reference checkerboard corner points after homography transformation based on the homography matrix and the target checkerboard corner points; S5, determining the matrix deviation of the reference checkerboard corner point matrix; if the matrix deviation does not meet a preset requirement, adjusting the initial distortion parameters, and cyclically executing steps S2 to S4 until the matrix deviation meets the requirement, outputting the adjusted target distortion parameters; the reference checkerboard corner point matrix includes all reference checkerboard corner points. In this way, only one image of the chessboard needs to be captured, and the corner points of the chessboard image are subjected to anti-distortion processing to reduce the deviation caused by image distortion. Furthermore, through homography matrix transformation, perspective distortion caused by the shooting angle is reduced, thus minimizing the impact of perspective interference on distortion parameters. Then, through closed-loop processing of distortion parameters, anti-distortion processing, and matrix deviation, it is ensured that the distortion parameters are always optimized in the direction of minimizing deviation. The final target distortion parameters can fit the true distortion characteristics of the camera module under test, ensuring the accuracy of distortion parameter determination. The entire testing process does not require limiting the shooting environment or taking multiple images for analysis, making the operation relatively simple and thus improving the efficiency of distortion parameter determination. Attached Figure Description

[0017] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A schematic flowchart of a method for determining camera module distortion parameters according to an embodiment of the present invention is shown; Figure 2 A schematic diagram of a chessboard image according to an embodiment of the present invention is shown; Figure 3 A schematic diagram of a first straight line fitted by the least squares method according to an embodiment of the present invention is shown; Figure 4 A schematic diagram of a first straight line determined by the angles of the first and last checkerboard squares according to an embodiment of the present invention is shown. Figure 5 A schematic diagram of a reference chessboard corner point array according to an embodiment of the present invention is shown; Figure 6 A schematic diagram of a device for determining camera module distortion parameters according to an embodiment of the present invention is shown. Detailed Implementation

[0018] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0019] This invention provides a method for determining the distortion parameters of a camera module, such as... Figure 1 As shown, the method mainly includes the following steps: S1, determine the initial corner points of the chessboard image.

[0020] The checkerboard background is photographed using the camera under test to obtain a checkerboard image. During photography, the angle of the checkerboard background and the shooting posture are not strictly required; the goal is simply to maximize the area of ​​the checkerboard background within the image's field of view to better calculate overall image distortion. The checkerboard image can be obtained as follows: Figure 2 As shown.

[0021] A checkerboard pattern is composed of black and white squares. A checkerboard image contains many corner points, also called interior corner points (the outer vertices of the checkerboard image's edges are not corner points). These are mainly the intersections of adjacent black and white squares. For example, if the checkerboard background has m*n rows of squares, then the number of corner points is (m-1)*(n-1), and the final output can be a (m-1)*(n-1) corner point array.

[0022] This invention requires first determining the initial corner points of the chessboard image to provide a data basis for subsequently determining distortion parameters.

[0023] In one implementation, determining the initial corner points of the chessboard image includes: The checkerboard image is preprocessed to obtain a preprocessed image; The preprocessed image is traversed to select all gradient extreme points as candidate corner points; Select a seed point from the candidate corner points as the starting point, and search for candidate corner points that meet the distance requirements along the horizontal and vertical directions respectively to obtain the target corner point; Determine if the consistency of the target corner point meets the requirements. If so, determine the target corner point as the initial chessboard corner point.

[0024] Specifically, since the grids in the chessboard image have the characteristic of alternating black and white, the corner point array should conform to the regular grid arrangement of m*n. Therefore, this application can first determine the candidate corner points, then determine whether the array formed by the candidate corner points is a regular grid arrangement, and then determine the accurate initial chessboard corner points.

[0025] First, adaptive threshold binarization is performed on the checkerboard image to obtain a preprocessed image (binarized image) to reduce the influence of uneven lighting and strengthen the boundaries of black and white squares.

[0026] Since the corners of a checkerboard image are the areas with the most dramatic changes in grayscale gradient, and the grayscale changes abruptly from black to white or from white to black at the intersection of black and white squares, the image can be traversed in the preprocessed image to filter out the gradient extrema points (points where the grayscale value changes abruptly) located at the intersections, and these gradient extrema points are determined as candidate corners.

[0027] If the number of candidate corner points identified is less than half of the theoretical total number of corner points, or if the identified candidate corner points are concentrated in a local area of ​​the image and do not cover the entire chessboard image, it is necessary to re-traverse the preprocessed image and re-identify the candidate corner points.

[0028] If the number of identified candidate corner points is greater than or equal to half of the theoretical total number of corner points, and the candidate corner points cover the entire checkerboard image, then a seed point is selected from the candidate corner points. Starting from the seed point, candidate corner points that meet the distance requirements are searched along the horizontal and vertical directions to obtain the target corner point. The seed point is generally a candidate corner point located at the center of the checkerboard image.

[0029] Since the distance between adjacent corner points in a checkerboard image is fixed (equivalent to the side length of the checkerboard), we can start from the seed point and search for adjacent candidate corner points to the left, right, up, and down. If the distance between a candidate corner point and the seed point is within a preset threshold range, the candidate corner point meets the requirement and is selected as the target corner point. The preset threshold range is (checkerboard side length - 3, checkerboard side length + 3).

[0030] Then, using the target corner point as a new starting point, search for candidate corner points that meet the distance requirements using the same method as above, until the search reaches the edge of the chessboard and all target corner points are obtained.

[0031] For example, suppose the coordinates of the seed point are (320, 240), the distance between adjacent corner points is 40 pixels, and the preset threshold range is (37, 43). When searching to the right, the expected coordinates of the adjacent point should be (320+40, 240). Suppose the candidate corner point with the nearest expected adjacent point coordinates is (362, 238). Then calculate the Euclidean distance between the candidate corner point and the seed point, which is approximately 42 pixels. This is within the preset threshold range, indicating that the candidate corner point is the right adjacent corner point of the seed point, and the candidate corner point can be determined as the target corner point.

[0032] Then, starting from the target corner point, continue searching in the horizontal and vertical directions, and so on, until all target corner points are found, forming a grid array.

[0033] In the grid array, it is determined whether the spacing between all adjacent target corner points in each row is uniform, whether the spacing between all adjacent target corner points in each column is uniform, and whether the angle between the row direction vector and the column direction vector is less than or equal to a preset angle threshold (that is, whether the row direction vector and the column direction vector are perpendicular). If all of the above are true, then all target corner points are determined as initial chessboard corner points. This ensures that the determined initial chessboard corner points are a corner point array that conforms to the chessboard grid rules.

[0034] S2, under the initial distortion parameters, perform anti-distortion processing on the initial chessboard corner points to obtain the target chessboard corner points.

[0035] In order to eliminate the interference of lens distortion on the calculation and make the initial chessboard corner points closer to the ideal distortion-free state, so as to accurately solve the true distortion parameters, it is also necessary to perform anti-distortion processing on the initial chessboard corner points under the initial distortion parameters to obtain the target chessboard corner points.

[0036] Distortion parameters include the distortion center and distortion coefficients. The distortion coefficients differ depending on the camera model used in the camera module under test. For example, when the camera model is a pinhole camera, the distortion coefficients can be radial and tangential. When the camera model is a fisheye camera, the distortion coefficients can be angular distortion coefficients.

[0037] The initial distortion parameters can be determined in the following two ways: First, the center of the checkerboard image is directly set as the initial distortion center, and the initial distortion coefficients are set to 0. This method is simple to operate, but the iterative convergence speed may be slightly slower.

[0038] Secondly, the initial distortion center and initial distortion coefficients can be determined based on a standard camera module of the same model. A standard camera module can be understood as a camera module calibrated using other calibration methods (such as Zhang's calibration method). Since the lens used in the standard camera module of the same model has roughly the same distortion characteristics as the lens of the camera under test, the distortion coefficients of the standard camera module (the calibrated distortion coefficients) can be directly used as the initial distortion coefficients of the camera module under test, and the center of the checkerboard image can be directly set as the initial distortion center. This method, because the initial distortion coefficients are close to the true values, can significantly improve the convergence speed and calculation accuracy of subsequent iterations.

[0039] Then, under the initial distortion parameters, the corner points of the initial chessboard are subjected to anti-distortion processing to eliminate the positional deviation under the initial distortion assumption, thus preparing data for the straightness deviation calculation.

[0040] Specifically, the distortion correction model in OpenCV (Open Source Computer Vision Library) can be called to correct the distortion of the coordinates of the initial chessboard corner points under the initial distortion parameters, and output the corrected target chessboard corner points.

[0041] S3, determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, determine the homography matrix based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid.

[0042] A standard corner point should be able to form an array, consisting of multiple rows and columns of corner points. When an image is distorted, points that should originally lie on a straight line will be bent into a curve. Therefore, by determining the straightness deviation of the target checkerboard corner points, the degree of distortion can be initially reflected.

[0043] This invention uses two methods to determine the straightness deviation of the corner points of the target chessboard grid, as follows: In one implementation, determining the straightness deviation of the target chessboard corner points includes: For each row and column of the target chessboard corner point in the chessboard image, the least squares method is used to fit the target chessboard corner point in each row and column to obtain the corresponding first and second straight lines. Determine the first perpendicular distance between each target chessboard corner point in each row and the first straight line, and determine the second perpendicular distance between each target chessboard corner point in each column and the second straight line; Determine the first sum of squares for each first vertical distance and determine the second sum of squares for each second vertical distance; The first sum of squares and the second sum of squares are defined as the straightness deviation.

[0044] Taking a corner point of a target chessboard grid as an example, the first straight line fitted is as follows: Figure 3 As shown, at this point, it is necessary to calculate the first vertical distance between each target chessboard corner point in the row and the first straight line, and then determine the sum of the squares of all the first vertical distances.

[0045] In this approach, if both the first sum of squares and the second sum of squares are less than a preset threshold, it indicates that the straightness deviation meets the requirements.

[0046] In another implementation, determining the straightness deviation of the target chessboard corner points includes: For each target chessboard corner point in the chessboard image, determine the third line based on the first and last target chessboard corner points in each row; determine the Des line based on the first and last target chessboard corner points in each column. Determine the third perpendicular distance between each remaining target chessboard corner point in each row and the third line, and determine the fourth perpendicular distance between each remaining target chessboard corner point in each column and the fourth line; Determine the third sum of squares for each third vertical distance and the second sum of squares for each fourth vertical distance; The third sum of squares and the fourth sum of squares are determined as the straightness deviation.

[0047] Taking a corner point of a target chessboard square as an example, the fitted third straight line is as follows: Figure 4 As shown, in Figure 4 In the process, after removing the first and last target chessboard corner points of the row, determine the third perpendicular distance between each remaining target chessboard corner point in the row and the third line, and then determine the sum of the squares of all third perpendicular distances.

[0048] In this approach, when it is determined that the sum of the third squares and the sum of the fourth squares are both less than or equal to a preset threshold, it indicates that the straightness deviation meets the preset requirements.

[0049] If the straightness deviation is greater than the preset threshold, it means that the straightness deviation does not meet the preset requirements. The method then includes: With the goal of reducing straightness deviation, the initial distortion parameters are iteratively optimized until the iteration conditions are met, and the required initial distortion parameters are output. Under the required initial distortion parameters, the initial chessboard corner points are re-distorted to obtain the target chessboard corner points.

[0050] Specifically, if the straightness deviation is greater than the preset threshold, with the goal of minimizing the straightness deviation, the initial distortion parameters can be iteratively optimized using the Levenberg-Marquardt (LM) optimization algorithm or the gradient descent algorithm in deep learning until the straightness deviation meets the first deviation threshold, and the required initial distortion parameters are output.

[0051] The above-mentioned LM optimization algorithm and the gradient descent algorithm in deep learning have the same implementation logic. In each iteration, the initial distortion parameters are used as the optimization target and adjusted. The straightness deviation is used as the objective function (loss function). After each adjustment of the initial distortion parameters, the corner anti-distortion processing and straightness deviation calculation steps are re-executed to generate a new straightness deviation. The above method is used to continuously iterate until the straightness deviation is less than or equal to the preset first deviation threshold, at which point the iteration ends and the initial distortion parameters that meet the requirements are output.

[0052] Among them, the LM optimization algorithm is a nonlinear least squares optimization algorithm used to solve unconstrained or constrained nonlinear optimization problems. It can directly iterate over the current distortion parameters without training.

[0053] The deep learning gradient descent algorithm can be a conventional deep learning neural network model, including: an input layer, hidden layers, and an output layer; the training process is as follows: 1. Data preparation stage Obtain multiple sets of labeled training samples, each set containing initial distortion parameters and corresponding true straightness deviation labels, to construct a training dataset; divide the dataset into a training set and a validation set for model training and performance verification.

[0054] 2. Model initialization phase Construct a deep learning neural network model to fit the mapping relationship between distortion parameters and straightness deviation, and initialize the model's weights and bias parameters; define straightness deviation as the model's loss function, which is used to measure the error between the model's prediction and the true label.

[0055] 3. Forward propagation phase The initial distortion parameters from the training set are input into the deep learning neural network model. Based on the current model parameters, forward calculation is performed to obtain the straightness deviation result predicted by the model. The loss value between the predicted result and the true straightness deviation label is calculated through the loss function to quantify the error degree of the current model.

[0056] 4. Backpropagation phase Calculate the gradient of the loss function with respect to each trainable parameter (e.g., weights, biases) in the model. This gradient represents the direction and magnitude of the influence of changes in each parameter on the change in the loss value. Determine the direction of parameter updates based on the gradient values, so that the loss value iterates in the direction of decreasing.

[0057] 5. Parameter update phase The gradient descent algorithm is used to update the trainable parameters of the model in the opposite direction of the gradient according to a preset learning rate. The learning rate is used to control the step size of each parameter update, balancing the training convergence speed and stability.

[0058] 6. Iterative convergence phase Repeat the iterative process of "forward propagation - loss calculation - back propagation - parameter update" until the convergence condition is met. At this point, the model has completed training.

[0059] Then, under the required initial distortion parameters, the initial chessboard corner points are re-distorted to obtain the target chessboard corner points.

[0060] When the straightness deviation meets the preset requirements, in order to further improve the accuracy of the distortion parameters, the characteristic that the horizontal and vertical grids of the chessboard are of the same size can be used to further optimize the initial distortion parameters, so that the distortion center and distortion coefficients are more accurate.

[0061] Specifically, since there are not many requirements for the pose of the chessboard background when shooting chessboard images, according to the principle of perspective projection, even chessboards without distortion will become non-square grids. Since all the corner points of these chessboards are on the same plane, the homography matrix can be used to convert non-square grids into square grids. Then the actual coordinates of the corner points of the target chessboard will also be corrected accordingly, making them closer to the theoretical coordinates.

[0062] Therefore, the homography matrix is ​​determined based on the corner points of the full square matrix formed by the corner points of the target chessboard, including: Obtain the actual coordinates of each target chessboard corner point in the Cartesian coordinate system and the theoretical coordinates of each target chessboard corner point in the world coordinate system; Convert each actual coordinate to first homogeneous coordinates, and convert each theoretical coordinate to second homogeneous coordinates; The homography matrix is ​​determined based on the first homogeneous coordinates, the second homogeneous coordinates, and the scale factor.

[0063] Specifically, assume that the set of coordinate points formed by the actual coordinates of each target chessboard corner point in the Cartesian coordinate system in the full square matrix corner points is as follows: (1) n The total number of corner points on the target chessboard. For the first n The actual coordinates of the corner points of the target chessboard grid in the Cartesian coordinate system.

[0064] Then for any one (the first) i The actual coordinates can be converted into first homogeneous coordinates using a formula. : (2) The set of coordinate points formed by the theoretical coordinates of each target chessboard corner point in the world coordinate system is: (3) For the first n The theoretical coordinates of the corner points of the target chessboard grid in the world coordinate system.

[0065] Then, the theoretical coordinates can be converted into second homogeneous coordinates according to formula (4). : (4) homography matrix H It is a 3×3 matrix used to describe the perspective projection transformation relationship between pixels in the world coordinate system and pixels in the Cartesian coordinate system, satisfying formula (5): (5) In formula (5), s is the scale factor.

[0066] (6) Substituting formulas (2), (4), and (6) into formula (5) and rearranging, we can obtain the following: H The linear equation.

[0067] Since the target chessboard corner points are n, 2n linear equations can be generated, forming an overdetermined system of equations. Solving this system of equations using singular value decomposition yields the values ​​of each element in the homography matrix.

[0068] Then, the values ​​of each element in the homography matrix are normalized to obtain the final homography matrix.

[0069] S4. Determine the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points.

[0070] Once the homography matrix is ​​determined, it can be used to perform perspective transformation on the actual coordinates of the target chessboard corner points, eliminating perspective distortion caused by the shooting angle. In one implementation, the reference chessboard corner points after homography transformation can be determined based on the homography matrix and the target chessboard corner points, including: Multiply the actual coordinates of the target chessboard corner point in the Cartesian coordinate system with the homography matrix to obtain the third homogeneous coordinates of the target chessboard corner point; The third homogeneous coordinates are converted to actual coordinates in the world plane coordinate system, and the reference chessboard corner points are determined based on the actual coordinates in the world plane coordinate system.

[0071] For example, suppose there are 4 target chessboard corner points, their actual coordinates (in pixels) in Cartesian coordinates are as follows: Corner 1: ; Corner 2: ; Corner 3: ; Corner 4: ; The homography matrix obtained by solving is:

[0072] Let's take corner point 1 as an example: Convert the actual coordinates of corner point 1 to the corresponding homogeneous coordinates: ; According to the formula Determine the third homogeneous coordinates ; Transform the third homogeneous coordinates into actual coordinates in the world plane coordinate system: .

[0073] Following the method described in Corner Point 1, the actual coordinates of the remaining target chessboard corner points can be converted to their actual coordinates in the world plane coordinate system, yielding the corresponding reference chessboard corner points. Ultimately, all reference chessboard corner points can be obtained. The reference chessboard corner points can be represented as follows: Figure 5 As shown.

[0074] S5, determine the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, adjust the initial distortion parameters and repeat steps S2 to S4 until the matrix deviation meets the requirements. Output the adjusted target distortion parameters. The reference chessboard corner point matrix includes all reference chessboard corner points.

[0075] from Figure 5As can be seen, each reference chessboard corner point has corresponding coordinates, and the reference chessboard corner points can form a corner point matrix. Therefore, the accuracy of the reference chessboard corner point determination can be judged by determining the matrix deviation of the reference chessboard corner point matrix.

[0076] In one implementation, the reference chessboard corner point matrix includes all reference chessboard corner points; determining the matrix deviation of the reference chessboard corner point matrix includes: Determine the Euclidean distance between the actual coordinates and the corresponding theoretical coordinates of each corner point of the reference chessboard grid in the reference chessboard grid corner point matrix; The average value of all Euclidean distances is determined as the matrix deviation of the reference chessboard corner point matrix.

[0077] If the matrix deviation is less than or equal to the preset second deviation threshold, it means that the matrix deviation meets the preset requirements, and the initial distortion parameters can be directly used as the distortion parameters of the camera under test.

[0078] If the matrix deviation is greater than the second deviation threshold, it means that the matrix deviation does not meet the preset requirements. In this case, the initial distortion parameters need to be adjusted. Under the adjusted initial distortion parameters, steps S2 to S4 are executed repeatedly until the matrix deviation meets the requirements, and the adjusted target distortion parameters are output.

[0079] This invention requires only one image of the chessboard pattern, followed by anti-distortion processing of the corner points to reduce the deviation caused by image distortion. Furthermore, through homography matrix transformation, perspective distortion caused by the shooting angle is reduced, minimizing the impact of perspective interference on distortion parameters. Then, through fine-tuning of distortion parameters, anti-distortion processing, and closed-loop processing of matrix deviation, the distortion parameters are ensured to always be optimized towards the direction of minimum deviation. The resulting target distortion parameters closely match the true distortion characteristics of the camera module under test, ensuring the accuracy of distortion parameter determination. The entire testing process does not require a specific shooting environment or multiple images for analysis, making the operation relatively simple and thus improving the efficiency of distortion parameter determination.

[0080] Based on the same inventive concept as in the foregoing embodiments, this embodiment also provides a device for determining the distortion parameters of a camera module, such as... Figure 6 The device includes: The first determining unit 61 is used to execute S1, determine the initial chessboard corner points of the chessboard image, and perform anti-distortion processing on the initial chessboard corner points under preset initial distortion parameters to obtain the target chessboard corner points. The second determining unit 62 is used to execute S2 to determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, the homography matrix is ​​determined based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid. The third determining unit 63 is used to execute S3, which determines the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points. The fourth determining unit 64 is used to execute S5, determining the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, the initial distortion parameters are adjusted, and steps S2 to S4 are executed cyclically until the matrix deviation meets the requirements, and the adjusted target distortion parameters are output. Since the device described in this embodiment of the invention is used to implement the method for determining the distortion parameters of a camera module according to this embodiment, those skilled in the art can understand the specific structure and variations of this device based on the method described in this embodiment, and therefore will not be described in detail here. All devices used in the method of this embodiment of the invention fall within the scope of protection of this invention.

[0081] Based on the same inventive concept, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any step of the method described above.

[0082] Based on the same inventive concept, this embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods described above.

[0083] Through one or more embodiments of the present invention, the present invention has the following beneficial effects or advantages: This invention provides a method, apparatus, medium, and device for determining distortion parameters of a camera module. The method includes: S1, determining initial checkerboard corner points of a checkerboard image; S2, performing anti-distortion processing on the initial checkerboard corner points under the initial distortion parameters to obtain target checkerboard corner points; S3, determining the straightness deviation of the target checkerboard corner points; if the straightness deviation meets a preset requirement, determining a homography matrix based on the full square matrix corner points; the full square matrix corner points are the corner point matrix determined based on the target checkerboard corner points; S4, determining reference checkerboard corner points after homography transformation based on the homography matrix and the target checkerboard corner points; S5, determining the square matrix deviation of the reference checkerboard corner point square matrix; if the square matrix deviation does not meet a preset requirement, adjusting the initial distortion parameters, and repeatedly executing steps S1 and S2. Steps S2 to S4 continue until the matrix deviation meets the requirements, then the adjusted target distortion parameters are output. This process only requires capturing one image of the chessboard pattern and performing anti-distortion processing on the corner points of the chessboard image to reduce the deviation caused by image distortion. Furthermore, through homography matrix transformation, perspective distortion caused by the shooting angle is reduced, minimizing the impact of perspective interference on the distortion parameters. Then, through fine-tuning the distortion parameters, anti-distortion processing, and closed-loop processing of the matrix deviation, the distortion parameters are always optimized towards the direction of minimum deviation. The final target distortion parameters closely match the actual distortion characteristics of the camera module under test, ensuring the accuracy of the distortion parameter determination. The entire testing process does not require limiting the shooting environment or capturing multiple images for analysis, making the operation relatively simple and thus improving the efficiency of distortion parameter determination.

[0084] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0085] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0086] Similarly, it should be understood that, in order to simplify this disclosure and aid in understanding one or more of the various aspects of the invention, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this method of disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.

[0087] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0088] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.

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

[0090] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.

[0091] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

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

Claims

1. A method for determining distortion parameters of a camera module, characterized in that, The method includes: S1, determine the initial corner points of the chessboard image; S2, under the initial distortion parameters, perform anti-distortion processing on the initial chessboard corner points to obtain the target chessboard corner points; S3, determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, determine the homography matrix based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid. S4, determine the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points; S5, determine the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, adjust the initial distortion parameters and repeat steps S2 to S4 until the matrix deviation meets the requirements. Output the adjusted target distortion parameters. The reference chessboard corner point matrix includes all reference chessboard corner points.

2. The method as described in claim 1, characterized in that, The determination of the initial chessboard corner points of the chessboard image includes: The chessboard image is preprocessed to obtain a preprocessed image; The preprocessed image is traversed to select all gradient extreme points as candidate corner points; From the candidate corner points, a seed point is selected as the starting point, and candidate corner points that meet the distance requirements are searched step by step along the horizontal and vertical directions to obtain the target corner point; Determine whether the consistency of the target corner point meets the requirements. If so, determine the target corner point as the initial chessboard corner point.

3. The method as described in claim 1, characterized in that, The determination of the straightness deviation of the target chessboard corner points includes: For each row and column of the target chessboard corner point in the chessboard image, the least squares method is used to fit the target chessboard corner point in each row and column to obtain the corresponding first straight line and second straight line. Determine the first perpendicular distance between each target chessboard corner point in each row and the first straight line, and determine the second perpendicular distance between each target chessboard corner point in each column and the second straight line; Determine a first sum of squares for each of the first vertical distances and determine a second sum of squares for each of the second vertical distances; The first sum of squares and the second sum of squares are determined as the straightness deviation.

4. The method as described in claim 1, characterized in that, If the straightness deviation does not meet the preset requirements, the method further includes: With the goal of reducing the straightness deviation, the initial distortion parameters are iteratively optimized until the iteration conditions are met, and the required initial distortion parameters are output. Under the required initial distortion parameters, the initial chessboard corner points are re-distorted to obtain the target chessboard corner points.

5. The method as described in claim 1, characterized in that, The determination of the homography matrix based on the corner points of the full square matrix includes: Obtain the actual coordinates of each target chessboard corner point in the Cartesian coordinate system and the theoretical coordinates of each target chessboard corner point in the world coordinate system; The actual coordinates are converted into first homogeneous coordinates, and the theoretical coordinates are converted into second homogeneous coordinates. The homography matrix is ​​determined based on the first homogeneous coordinates, the second homogeneous coordinates, and the scale factor.

6. The method as described in claim 1, characterized in that, The step of determining the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points includes: Multiply the actual coordinates of the target chessboard corner point in the Cartesian coordinate system with the homography matrix to obtain the third homogeneous coordinates of the target chessboard corner point; The third homogeneous coordinates are converted into actual coordinates in the world plane coordinate system, and the reference chessboard corner points are determined based on the actual coordinates in the world plane coordinate system.

7. The method as described in claim 1, characterized in that, The determination of the square deviation of the reference chessboard corner point square matrix includes: Determine the Euclidean distance between the actual coordinates and the corresponding theoretical coordinates of each reference chessboard corner point in the reference chessboard corner point matrix; The average value of all Euclidean distances is determined as the matrix deviation of the reference chessboard corner point matrix.

8. A device for determining distortion parameters of a camera module, characterized in that, The device includes: The first determining unit is used to execute S1, determine the initial chessboard corner points of the chessboard image, and perform anti-distortion processing on the initial chessboard corner points under preset initial distortion parameters to obtain the target chessboard corner points. The second determining unit is used to execute S2 to determine the straightness deviation of the corner points of the target chessboard grid. If the straightness deviation meets the preset requirements, the homography matrix is ​​determined based on the corner points of the full square matrix. The corner points of the full square matrix are the corner point matrix determined based on the corner points of the target chessboard grid. The third determining unit is used to execute S3, which determines the reference chessboard corner points after homography transformation based on the homography matrix and the target chessboard corner points. The fourth determining unit is used to execute S5 to determine the matrix deviation of the reference chessboard corner point matrix. If the matrix deviation does not meet the preset requirements, the initial distortion parameters are adjusted. Steps S2 to S4 are executed repeatedly until the matrix deviation meets the requirements, and the adjusted target distortion parameters are output.

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

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1-7.