Camera calibration methods, devices, electronic equipment, and storage media
By using a checkerboard calibration board guided by QR codes in camera calibration, the initial transformation matrix is determined by the QR codes, and the coordinates are corrected according to the integer multiples of the checkerboard corner points. This solves the problem of inaccurate checkerboard corner point recognition and achieves high-precision and high-reliability camera calibration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-04-03
AI Technical Summary
In existing camera calibration methods, the identification of checkerboard corner points is inaccurate due to the influence of imaging conditions and environmental factors, resulting in inaccurate mapping between corner point pixel coordinates and world coordinates, which reduces calibration accuracy and reliability.
A checkerboard calibration board containing QR codes is used to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system. The initial world coordinates are then corrected based on the rule that the world coordinates of the checkerboard corner points are integer multiples of the size of a single checkerboard grid, thus establishing a more accurate correspondence between pixel coordinates and world coordinates.
It improves the accuracy and reliability of camera calibration, enabling high-precision world coordinate registration of checkerboard corner points under complex imaging conditions, and significantly enhances the accuracy and stability of calibration results.
Smart Images

Figure CN121353425B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to a camera calibration method, apparatus, electronic device, and storage medium. Background Technology
[0002] In camera calibration, existing checkerboard calibration methods rely on the accurate extraction of checkerboard corner points to establish the transformation relationship between the image coordinate system and the world coordinate system. However, in practice, due to imaging conditions (such as uneven illumination and changing viewing angles) and environmental factors (such as noise interference), some corner points of the checkerboard may not be accurately identified, resulting in inaccurate mapping between corner pixel coordinates and their corresponding world coordinates, thus affecting calibration accuracy. Furthermore, the initial transformation matrix calculated directly based on these corner points is susceptible to distortion and errors, reducing the reliability of the calibration results.
[0003] Therefore, how to improve the accuracy and reliability of camera calibration is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide a camera calibration method, apparatus, electronic device, and storage medium that improves the accuracy and reliability of camera calibration.
[0005] To achieve the above objectives, this application provides a camera calibration method, comprising:
[0006] Obtain the target image of the chessboard calibration board containing the QR code;
[0007] The initial transformation matrix from the pixel coordinate system to the world coordinate system is determined using the QR code in the target image;
[0008] Determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point;
[0009] Based on the rule that the world coordinates of the corner points of the chessboard are integer multiples of the size of a single chessboard square, the initial world coordinates of each chessboard corner point are corrected to obtain the corrected world coordinates of each chessboard corner point;
[0010] Camera calibration is achieved based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates.
[0011] Specifically, the QR code is a data matrix code, and the two adjacent sides of the data matrix code are L-shaped positioning boundaries composed of solid cells.
[0012] The step of determining the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image includes:
[0013] Identify the QR code in the target image and obtain the QR code information; wherein, the QR code information includes the coordinates of the checkerboard grid at the center of the QR code and the size of the individual checkerboard grid.
[0014] The pixel coordinates of the QR code in the target image are determined, the world coordinates of the QR code are determined based on the QR code information, and the initial transformation matrix from the pixel coordinate system to the world coordinate system is determined based on the correspondence between the pixel coordinates and the world coordinates of the QR code.
[0015] The step of correcting the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square to obtain the corrected world coordinates of each chessboard corner point includes:
[0016] Obtain the chessboard coordinates of each chessboard corner point, determine multiple ideal world coordinates based on the chessboard coordinates of each chessboard corner point and the size of a single chessboard, and construct an ideal coordinate point set based on each ideal world coordinate;
[0017] Based on the world coordinates of each chessboard corner point and the ideal world coordinates of each ideal coordinate point in the set of ideal coordinate points, the distance between each chessboard corner point and each ideal coordinate point in the set of ideal coordinate points is calculated, and the target ideal coordinate point corresponding to each chessboard corner point is determined; wherein, the distance between the chessboard corner point and the corresponding target ideal point is the smallest;
[0018] The ideal world coordinates of the target ideal coordinate points corresponding to the corner points of each chessboard square are used as the corrected world coordinates of each chessboard square corner point.
[0019] After determining the target ideal coordinates corresponding to the corner points of each chessboard square, the method further includes:
[0020] Determine the target distance between each chessboard corner point and its corresponding target ideal coordinate point, and eliminate chessboard corner points whose target distance is less than a preset value;
[0021] Accordingly, the camera calibration based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates includes:
[0022] Camera calibration is achieved based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points.
[0023] The preset value is a preset ratio of the size of a single chessboard square.
[0024] The camera calibration, based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the corresponding target ideal coordinate points, includes:
[0025] Based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points, the corrected transformation matrix from the pixel coordinate system to the world coordinate system and the distortion correction matrix are determined to achieve camera calibration.
[0026] To achieve the above objectives, this application provides a camera calibration device, comprising:
[0027] The acquisition module is used to acquire the target image of the checkerboard calibration board containing the QR code;
[0028] The determination module is used to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image;
[0029] The transformation module is used to determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point;
[0030] The correction module is used to correct the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square, so as to obtain the corrected world coordinates of each chessboard corner point.
[0031] The calibration module is used to calibrate the camera based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates.
[0032] To achieve the above objectives, this application provides an electronic device, comprising:
[0033] Memory, used to store computer programs;
[0034] A processor is used to implement the steps of the camera calibration method described above when executing the computer program.
[0035] To achieve the above objectives, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the camera calibration method described above.
[0036] The camera calibration method provided in this application introduces a checkerboard calibration board containing QR codes. First, it uses the content of the QR codes and their pixel positions to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system. Because QR codes have a robust coding structure, they offer high recognition accuracy and strong anti-interference capabilities, remaining stable even under partial occlusion or low contrast conditions. Therefore, the initial transformation matrix obtained based on the QR codes is more stable and accurate than methods that directly rely on checkerboard corner points. On this basis, the extracted checkerboard corner pixel coordinates are mapped to initial world coordinates using this initial transformation matrix. Since this mapping process has a relatively reliable geometric prior, the rationality of the initial world coordinates of the corner points can be guaranteed even if the image has slight distortion or noise. Subsequently, based on the prior rule that the world coordinates of checkerboard corner points in real physical space must be an integer multiple of the size of a single checkerboard grid, the initial world coordinates are corrected by finding the closest valid coordinate point that satisfies the integer multiple condition as its corrected world coordinates. This correction process effectively eliminates coordinate deviations caused by image distortion or inaccurate initial transformations, thereby establishing a more accurate correspondence between pixel coordinates and world coordinates. Therefore, the camera calibration method provided in this application, which uses QR codes to guide coordinate mapping and structural rules to correct coordinate errors, achieves high-precision registration of world coordinates at checkerboard corner points under complex imaging conditions, significantly improving the accuracy and reliability of camera calibration. This application also discloses a device verification apparatus, an electronic device, a computer-readable storage medium, and a computer program product, all of which can achieve the same technical effects.
[0037] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0038] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating a camera calibration method according to an exemplary embodiment;
[0040] Figure 2 This is a schematic diagram illustrating a target image according to an exemplary embodiment;
[0041] Figure 3 A flowchart illustrating another camera calibration method according to an exemplary embodiment;
[0042] Figure 4This is a structural diagram illustrating a camera calibration device according to an exemplary embodiment;
[0043] Figure 5 This is a structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0044] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Furthermore, in the embodiments of this application, "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0045] This application discloses a camera calibration method that improves the accuracy and reliability of camera calibration.
[0046] See Figure 1 A flowchart illustrating a camera calibration method according to an exemplary embodiment, such as... Figure 1 As shown, it includes:
[0047] S101: Obtain the target image of the checkerboard calibration board containing the QR code;
[0048] The checkerboard calibration board containing QR codes refers to a specialized calibration tool that integrates one or more QR codes onto a traditional black and white checkerboard pattern. The QR codes are embedded within the checkerboard grid or located on its edges. Preferably, the QR codes are data matrix codes, with adjacent sides forming L-shaped positioning boundaries composed of solid cells, i.e., DM codes (Data Matrix Codes). Due to their high-density encoding and strong error correction capabilities, DM codes can be stably and accurately identified under complex imaging conditions (such as uneven lighting, partial occlusion, or low-contrast environments). Furthermore, the structural characteristics of DM codes (such as the L-shaped edge-finding pattern) result in high positioning accuracy in images, thus providing a reliable reference point for the calibration process.
[0049] In practice, the calibration board is placed within the camera's field of view, and the camera's focal length and shooting angle are adjusted to ensure that the calibration board is clearly imaged without severe perspective distortion or obstruction. Then, a digital image of the calibration board is obtained by taking a picture of the calibration board in a specific orientation using the camera to be calibrated. Figure 2 As shown, the QR code occupies 4 squares.
[0050] As can be seen, this step, by introducing a QR code, provides a highly robust reference benchmark for establishing the initial mapping between the pixel coordinate system and the world coordinate system, avoiding the uncertainty caused by the traditional method's complete reliance on corner detection, and improving the reliability of the starting point of the entire calibration process.
[0051] In a preferred embodiment, after acquiring the target image of the checkerboard calibration board containing the QR code, the method further includes: performing a preprocessing operation on the target image; wherein the preprocessing operation includes any one or a combination of median filtering, mean filtering, and Gaussian filtering.
[0052] Preprocessing refers to image enhancement processes such as noise suppression and edge enhancement applied to the calibration image to improve the accuracy of subsequent feature extraction. In practice, linear or nonlinear filtering techniques can be used to smooth the original image and remove high-frequency interference introduced by uneven lighting, sensor noise, or transmission. For example, Gaussian filtering can be used first to reduce overall noise, followed by median filtering to eliminate isolated salt-and-pepper noise points, thereby improving image quality, increasing QR code recognition rate and corner location accuracy, and enhancing the stability and robustness of the entire calibration process.
[0053] S102: Determine the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image;
[0054] The initial transformation matrix is a mathematical model that describes the approximate geometric mapping relationship between the pixel coordinate system (image plane) and the world coordinate system (physical space), and is usually a 3×3 homography matrix.
[0055] In this step, the QR code in the target image is first identified and its content is parsed to obtain the spatial information it carries. Then, the pixel position of the QR code in the target image is determined, and multiple sets of corresponding point pairs are established based on its corresponding world coordinates. The initial pixel-to-world transformation matrix is then calculated accordingly. Because QR codes have strong error correction capabilities and high recognition reliability, they can be accurately read even in partially blurred or low-contrast conditions, thus serving as a reliable benchmark for establishing the initial mapping.
[0056] As can be seen, this step utilizes encoded information to achieve high-precision and interference-resistant initial mapping, significantly reducing the initial error caused by corner point misdetection in traditional methods, and laying the foundation for subsequent accurate calibration.
[0057] S103: Determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point;
[0058] Among them, the corner points of the chessboard refer to the vertices where adjacent black and white squares meet, which are characteristic points with significant changes in gray-level gradient in the image.
[0059] In this step, a corner detection algorithm is first used to extract the pixel coordinates of all identifiable corner points in the image; then, using an initial transformation matrix, these pixel coordinates are mapped to the world coordinate system in batches to obtain the initial world coordinates of each corner point.
[0060] It is evident that a rapid batch mapping from image features to physical space has been achieved, avoiding the tedious operation of point-by-point matching, improving processing efficiency, and providing a necessary foundation for subsequent coordinate correction based on structural patterns.
[0061] S104: Based on the rule that the world coordinates of the corner points of the chessboard are integer multiples of the size of a single chessboard square, the initial world coordinates of each chessboard square corner point are corrected to obtain the corrected world coordinates of each chessboard square corner point;
[0062] The rule that the size of a single chessboard square is an integer multiple refers to the ideal condition that the world coordinates of all corner points should satisfy... , (m and n are integers).
[0063] In this step, based on the initial world coordinates, the legal coordinate point in its neighborhood that best conforms to the rule is found as its corrected world coordinates. This process utilizes prior knowledge of the calibration plate's structure to effectively suppress coordinate drift caused by imaging distortion, noise, or initial transformation errors.
[0064] As can be seen, this step significantly improves the accuracy and consistency of world coordinates through structural constraints, ensuring the quality of calibration data.
[0065] As a feasible implementation method, the step of correcting the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square to obtain the corrected world coordinates of each chessboard corner point includes: obtaining the chessboard coordinates of each chessboard corner point; determining multiple ideal world coordinates based on the chessboard coordinates of each chessboard corner point and the size of a single chessboard square; constructing an ideal coordinate point set based on each ideal world coordinate; calculating the distance between each chessboard corner point and each ideal coordinate point in the set of ideal coordinate points based on the world coordinates of each chessboard corner point and the ideal world coordinates of each ideal coordinate point in the set of ideal coordinate points; determining the target ideal coordinate point corresponding to each chessboard corner point; wherein the distance between the chessboard corner point and the corresponding target ideal coordinate point is minimized; and using the ideal world coordinates of the target ideal coordinate points corresponding to each chessboard corner point as the corrected world coordinates of each chessboard corner point.
[0066] In practice, the first step is to obtain the checkerboard coordinates corresponding to each corner point, i.e., its row and column position in the checkerboard grid. Then, a set of ideal world coordinate points is generated by combining the known checkerboard size s. Next, for each initial coordinate, the Euclidean distance between it and all ideal coordinates in the point set is calculated. The ideal point with the smallest distance is selected as its matching target, and its coordinates are used as the corrected world coordinates of that corner point.
[0067] As can be seen, this implementation method utilizes structural priors for coordinate matching, which improves the automation and accuracy of the correction process and ensures the correct correspondence between corner points and world coordinates.
[0068] As a preferred embodiment, after determining the target ideal coordinate point corresponding to each chessboard corner point, the method further includes: determining the target distance between each chessboard corner point and the corresponding target ideal coordinate point, and eliminating chessboard corner points whose target distance is less than a preset value.
[0069] In practice, after coordinate matching is completed, the deviation distance between each corner point and its target ideal coordinate point is calculated. If this distance exceeds a set threshold, the corner point is considered to be potentially affected by severe distortion, occlusion, or false detection, and is therefore considered unreliable data and discarded. This operation prevents outliers from interfering with subsequent calibration processes, enhances the robustness of the calibration algorithm, avoids the negative impact of erroneous data on camera parameter solving, and improves the reliability of the final calibration results.
[0070] As one possible implementation, the preset value is a preset ratio of the size of the individual chessboard square.
[0071] In practice, the preset value is set as a fixed proportion (e.g., 10%) of the size s of a single chessboard square, meaning that when the distance between a corner point and its ideal coordinates is greater than... When the threshold value (k is a scaling factor) is reached, the value is discarded. Linking the threshold to the physical characteristics of the calibration board provides good adaptability and versatility, allowing for flexible adjustment based on different application scenarios while balancing accuracy and stability.
[0072] S105: Camera calibration is achieved based on the correspondence between the pixel coordinates of each checkerboard corner point and the corrected world coordinates.
[0073] Camera calibration refers to solving the camera's intrinsic parameters (such as focal length, principal point, and distortion coefficient) and extrinsic parameters (rotation and translation) by using the known correspondence between image points and spatial points.
[0074] In this step, the pixel coordinates of the corner points are paired with their corrected world coordinates and input into a standard calibration algorithm (such as Zhang Zhengyou's method) for optimization. The algorithm iteratively updates the camera parameters by minimizing the reprojection error until convergence. Due to the high precision and strong consistency of the input data, the reprojection error is significantly reduced, resulting in more accurate camera parameters.
[0075] As a preferred embodiment, the camera calibration based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates includes: calibrating the camera based on the correspondence between the pixel coordinates of the unremoved chessboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved chessboard corner points.
[0076] In practice, only valid corner points that pass the distance threshold test are retained, and all abnormal or unreliable points are excluded. Then, the parameters are solved based on these valid matching point pairs, which effectively avoids the interference of noise and error points on model fitting and improves the stability and accuracy of calibration results.
[0077] The camera calibration method provided in this application introduces a checkerboard calibration board containing QR codes. First, it uses the content of the QR codes and their pixel positions to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system. Because QR codes have a robust encoding structure, they offer high recognition accuracy and strong anti-interference capabilities, remaining stable even under partial occlusion or low contrast conditions. Therefore, the initial transformation matrix obtained based on the QR codes is more stable and accurate than methods that directly rely on checkerboard corner points. On this basis, the extracted checkerboard corner pixel coordinates are mapped to initial world coordinates using this initial transformation matrix. Since this mapping process has a relatively reliable geometric prior, the rationality of the initial world coordinates of the corner points can be guaranteed even if the image has slight distortion or noise. Subsequently, based on the prior rule that the world coordinates of checkerboard corner points in real physical space must be an integer multiple of the size of a single checkerboard grid, the initial world coordinates are corrected by finding the closest valid coordinate point that satisfies the integer multiple condition as its corrected world coordinates. This correction process effectively eliminates coordinate deviations caused by image distortion or inaccurate initial transformations, thereby establishing a more accurate correspondence between pixel coordinates and world coordinates. Therefore, the camera calibration method provided in this application, which uses QR codes to guide coordinate mapping and structural rules to correct coordinate errors, achieves high-precision registration of world coordinates at checkerboard corner points under complex imaging conditions, significantly improving the accuracy and reliability of camera calibration.
[0078] This application discloses a camera calibration method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0079] See Figure 3 A flowchart illustrating another camera calibration method according to an exemplary embodiment, such as... Figure 3 As shown, it includes:
[0080] S201: Obtain the target image of the checkerboard calibration board containing the QR code;
[0081] This step aims to acquire raw image data for camera calibration. In this step, the checkerboard calibration board is placed within the camera's field of view, and the shooting distance, angle, and lighting conditions are adjusted to ensure that the calibration board is clearly imaged without severe obstruction or distortion. Then, the camera acquires the target image.
[0082] S202: Identify the QR code in the target image and obtain the QR code information; wherein, the QR code information includes the coordinates of the checkerboard grid at the center of the QR code and the size of the individual checkerboard grid;
[0083] In this step, a standard QR code recognition algorithm (such as image processing-based decoding technology) is used to locate and decode the QR code in the target image, extracting its encoded content, i.e., QR code information, which includes at least two key parameters: one is the integer coordinates (x, y) of the QR code center in the checkerboard coordinate system, used to determine its relative position on the calibration board; the other is the actual physical size s of a single checkerboard grid (usually in millimeters), used to convert the grid coordinates into real-world coordinates.
[0084] As can be seen, this step pre-stores the geometric parameters of the calibration plate through encoding, avoiding errors caused by manual input or measurement, and realizing automatic reading and highly reliable transmission of calibration information.
[0085] S203: Determine the pixel coordinates of the QR code in the target image, determine the world coordinates of the QR code based on the QR code information, and determine the initial transformation matrix from the pixel coordinate system to the world coordinate system based on the correspondence between the pixel coordinates and the world coordinates of the QR code.
[0086] This step establishes the initial mapping between image coordinates and physical coordinates. First, image processing techniques (such as contour detection or corner localization) are used to determine the pixel coordinates of the four vertices of the QR code, and then the pixel coordinates of its center point are calculated. Then, based on the chessboard coordinates of the QR code and the size of a single chessboard square, calculate its corresponding world coordinates. Finally, an initial homography transformation matrix, or initial transformation matrix T, is calculated using multiple pairs of pixel coordinates and world coordinates from the QR codes. This matrix describes the approximate geometric transformation from the pixel coordinate system to the world coordinate system. The calculation formula is as follows: .
[0087] As can be seen, this step utilizes the robust recognition characteristics of QR codes to construct a reliable and interference-resistant initial transformation model, providing a foundation for subsequent batch mapping of corner coordinates.
[0088] S204: Determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point;
[0089] This step performs batch mapping from image features to physical space. In this step, a corner detection algorithm is used to extract the corrected pixel coordinates of all identifiable checkerboard corners in the target image. Then, these pixel coordinates are substituted into the initial transformation matrix to perform a coordinate transformation, obtaining the preliminary position of each corner point in the world coordinate system, i.e., the initial world coordinates. Although the coordinates may be subject to some deviation due to lens distortion or initial matrix errors, they already possess reasonable geometric priors.
[0090] As can be seen, this step enables the rapid mapping of a large number of corner coordinates, avoids the complexity of point-by-point matching, improves processing efficiency, and provides input data for subsequent coordinate correction based on structural patterns.
[0091] S205: Obtain the chessboard coordinates of each chessboard corner point, determine multiple ideal world coordinates based on the chessboard coordinates of each chessboard corner point and the size of the single chessboard, and construct an ideal coordinate point set based on each ideal world coordinate;
[0092] This step establishes a theoretical reference datum for coordinate correction. First, the checkerboard coordinates corresponding to each corner point are obtained, i.e., its row and column position within the checkerboard grid. Then, combined with the known individual checkerboard size *s*, the theoretical world coordinates of each corner point under ideal, distortion-free conditions are calculated. ,in Collect all such theoretical coordinates to form an ideal coordinate point set. This represents the standard layout of the calibration board in physical space. The ideal coordinate point set provides a structured reference framework, enabling subsequent precise correction of the actually detected corner coordinates through minimum distance matching, thereby improving data consistency.
[0093] S206: Calculate the distance between each chessboard corner point and each ideal point in the set of ideal coordinate points based on the world coordinates of each chessboard corner point and the ideal world coordinates of each ideal coordinate point in the set of ideal coordinate points; determine the target ideal coordinate point corresponding to each chessboard corner point and the target distance between each chessboard corner point and the corresponding target ideal point; wherein, the distance between the chessboard corner point and the corresponding target ideal point is the smallest;
[0094] This step completes the precise matching of corner points to their ideal positions. In this step, for each initial world coordinate... Calculate the Euclidean distance between it and all points in the ideal coordinate point set CC, select the ideal point with the smallest distance as its corresponding target matching point, and record the smallest distance as the target distance.
[0095] As can be seen, this step aligns the actual detection results with the theoretical model through the nearest neighbor matching mechanism, effectively correcting the coordinate drift caused by imaging errors and ensuring the accurate correspondence between corner points and world coordinates.
[0096] S207: Remove chessboard corner points whose target distance is less than a preset value;
[0097] This step introduces a data filtering mechanism to improve calibration quality. In this step, a distance threshold is set (e.g., ...). For corner points whose calculated target distance is greater than the threshold, they are considered to be too far from the ideal position, possibly due to false detection, occlusion or severe distortion, and are therefore considered unreliable data and are removed.
[0098] As can be seen, this step effectively filters outliers, prevents noise and erroneous data from interfering with the solution of camera parameters, and enhances the robustness of the calibration algorithm and the reliability of the final result.
[0099] S208: Based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points, determine the corrected transformation matrix from the pixel coordinate system to the world coordinate system and the distortion correction matrix to achieve camera calibration.
[0100] This step completes the final solution for the camera parameters. In this step, the pixel coordinates of the valid corner points retained in the previous steps are paired with their corresponding ideal world coordinates of the target, and then input into a standard camera calibration algorithm (such as the Zhang Zhengyou calibration method) for optimization. The algorithm iteratively calculates the corrected camera intrinsic parameters (focal length, principal point, distortion coefficients, etc.) and extrinsic parameters (rotation and translation matrices) by minimizing the reprojection error. The distortion correction matrix can be used for subsequent geometric correction of the image. Because the input data undergoes structural correction and anomaly removal, it possesses high precision and strong consistency, significantly improving the accuracy of camera calibration.
[0101] This embodiment constructs an ideal coordinate point set based on the prior rules of the checkerboard structure, and achieves accurate correction of the corner point world coordinates through minimum distance matching. Furthermore, by setting a distance threshold based on the grid size ratio to eliminate outliers with excessive deviations, the consistency of the data used for calibration is ensured. Finally, the corrected transformation matrix and distortion correction parameters are solved using the selected high-quality points, significantly improving the estimation accuracy of the camera's intrinsic and extrinsic parameters.
[0102] The following describes a camera calibration device provided in an embodiment of this application. The camera calibration device described below and the camera calibration method described above can be referred to each other.
[0103] See Figure 4 A structural diagram of a camera calibration device according to an exemplary embodiment is shown, as follows: Figure 4 As shown, it includes:
[0104] The acquisition module 100 is used to acquire the target image of the checkerboard calibration board containing the QR code;
[0105] The determination module 200 is used to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image;
[0106] The transformation module 300 is used to determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point.
[0107] The correction module 400 is used to correct the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square, so as to obtain the corrected world coordinates of each chessboard corner point.
[0108] The calibration module 500 is used to perform camera calibration based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates.
[0109] The camera calibration device provided in this application introduces a checkerboard calibration board containing a QR code. First, it uses the content of the QR code and its pixel positions to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system. Because the QR code has a robust encoding structure, it boasts high recognition accuracy and strong anti-interference capabilities, and can still be stably recognized even under partial occlusion or low contrast conditions. Therefore, the initial transformation matrix obtained based on the QR code is more stable and accurate than methods that directly rely on checkerboard corner points. On this basis, the extracted checkerboard corner pixel coordinates are mapped to initial world coordinates through this initial transformation matrix. Since this mapping process has a relatively reliable geometric prior, the rationality of the initial world coordinates of the corner points can be guaranteed even if the image has slight distortion or noise. Subsequently, based on the prior rule that the world coordinates of checkerboard corner points in real physical space must be an integer multiple of the size of a single checkerboard grid, the initial world coordinates are corrected. That is, the legal coordinate point that is closest to the initial coordinates and satisfies the integer multiple condition is found as its corrected world coordinates. This correction process effectively eliminates coordinate deviations caused by image distortion or inaccurate initial transformations, thereby establishing a more accurate correspondence between pixel coordinates and world coordinates. Therefore, the camera calibration device provided in this application, by using QR codes to guide coordinate mapping and structural rules to correct coordinate errors, achieves high-precision registration of world coordinates at checkerboard corner points under complex imaging conditions, significantly improving the accuracy and reliability of camera calibration.
[0110] Based on the above embodiments, as a preferred implementation, the QR code is specifically a data matrix code, and the two adjacent sides of the data matrix code are L-shaped positioning boundaries composed of solid cells.
[0111] Based on the above embodiments, as a preferred implementation, the determining module 200 is specifically used for: identifying a QR code in the target image and obtaining QR code information; wherein, the QR code information includes the checkerboard coordinates of the center of the QR code and the size of the individual checkerboard grid; determining the pixel coordinates of the QR code in the target image, determining the world coordinates of the QR code based on the QR code information, and determining the initial transformation matrix from the pixel coordinate system to the world coordinate system based on the correspondence between the pixel coordinates and the world coordinates of the QR code.
[0112] Based on the above embodiments, as a preferred implementation, the correction module 400 is specifically used for: obtaining the chessboard coordinates of each chessboard corner point; determining multiple ideal world coordinates based on the chessboard coordinates of each chessboard corner point and the size of the single chessboard; and constructing an ideal coordinate point set based on each ideal world coordinate; calculating the distance between each chessboard corner point and each ideal coordinate point in the set based on the world coordinates of each chessboard corner point and the ideal world coordinates of each ideal coordinate point in the set, and determining the target ideal coordinate point corresponding to each chessboard corner point; wherein the distance between the chessboard corner point and the corresponding target ideal coordinate point is the smallest; and using the ideal world coordinates of the target ideal coordinate points corresponding to each chessboard corner point as the corrected world coordinates of each chessboard corner point.
[0113] Based on the above embodiments, as a preferred embodiment, the correction module 400 is further configured to: determine the target distance between each chessboard corner point and the corresponding target ideal coordinate point, and remove chessboard corner points whose target distance is less than a preset value;
[0114] Accordingly, the calibration module 500 is specifically used to: perform camera calibration based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points.
[0115] Based on the above embodiments, as a preferred implementation, the preset value is a preset ratio of the size of the individual chessboard square.
[0116] Based on the above embodiments, as a preferred implementation, the calibration module 500 is specifically used to: determine the corrected transformation matrix from the pixel coordinate system to the world coordinate system and the distortion correction matrix based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points, so as to achieve camera calibration.
[0117] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0118] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 5 This is a structural diagram of an electronic device according to an exemplary embodiment, such as... Figure 5 As shown, the electronic device includes:
[0119] Communication interface 1 enables information exchange with other devices, such as network devices;
[0120] Processor 2 is connected to communication interface 1 to enable information exchange with other devices. When running a computer program, it executes the camera calibration method provided by one or more of the above-mentioned technical solutions. The computer program is stored in memory 3.
[0121] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 5 The general will label all buses as Bus System 4.
[0122] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0123] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or CD-ROM; magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0124] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0125] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0126] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0127] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0128] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0129] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A camera calibration method, characterized in that, include: Obtain the target image of the chessboard calibration board containing the QR code; The initial transformation matrix from the pixel coordinate system to the world coordinate system is determined using the QR code in the target image; Determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point; Based on the rule that the world coordinates of the corner points of the chessboard are integer multiples of the size of a single chessboard square, the initial world coordinates of each chessboard corner point are corrected to obtain the corrected world coordinates of each chessboard corner point; Camera calibration is achieved based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates.
2. The camera calibration method according to claim 1, characterized in that, The QR code is specifically a data matrix code, and the two adjacent sides of the data matrix code are L-shaped positioning boundaries composed of solid cells.
3. The camera calibration method according to claim 1, characterized in that, The step of determining the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image includes: Identify the QR code in the target image and obtain the QR code information; wherein, the QR code information includes the coordinates of the checkerboard grid at the center of the QR code and the size of the individual checkerboard grid. The pixel coordinates of the QR code in the target image are determined, the world coordinates of the QR code are determined based on the QR code information, and the initial transformation matrix from the pixel coordinate system to the world coordinate system is determined based on the correspondence between the pixel coordinates and the world coordinates of the QR code.
4. The camera calibration method according to claim 1, characterized in that, The process of correcting the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square to obtain the corrected world coordinates of each chessboard corner point includes: Obtain the chessboard coordinates of each chessboard corner point, determine multiple ideal world coordinates based on the chessboard coordinates of each chessboard corner point and the size of a single chessboard, and construct an ideal coordinate point set based on each ideal world coordinate; Based on the world coordinates of each chessboard corner point and the ideal world coordinates of each ideal coordinate point in the set of ideal coordinate points, the distance between each chessboard corner point and each ideal coordinate point in the set of ideal coordinate points is calculated, and the target ideal coordinate point corresponding to each chessboard corner point is determined; wherein, the distance between the chessboard corner point and the corresponding target ideal point is the smallest; The ideal world coordinates of the target ideal coordinate points corresponding to the corner points of each chessboard square are used as the corrected world coordinates of each chessboard square corner point.
5. The camera calibration method according to claim 4, characterized in that, After determining the target ideal coordinates corresponding to the corner points of each chessboard square, the process also includes: Determine the target distance between each chessboard corner point and its corresponding target ideal coordinate point, and eliminate chessboard corner points whose target distance is greater than a preset value; Accordingly, the camera calibration based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates includes: Camera calibration is achieved based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points.
6. The camera calibration method according to claim 5, characterized in that, The preset value is a preset ratio of the size of the individual chessboard square.
7. The camera calibration method according to claim 5, characterized in that, Camera calibration is achieved based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the corresponding target ideal coordinate points, including: Based on the correspondence between the pixel coordinates of the unremoved checkerboard corner points and the ideal world coordinates of the target ideal coordinate points corresponding to the unremoved checkerboard corner points, the corrected transformation matrix from the pixel coordinate system to the world coordinate system and the distortion correction matrix are determined to achieve camera calibration.
8. A camera calibration device, characterized in that, include: The acquisition module is used to acquire the target image of the checkerboard calibration board containing the QR code; The determination module is used to determine the initial transformation matrix from the pixel coordinate system to the world coordinate system using the QR code in the target image; The transformation module is used to determine the pixel coordinates of each chessboard corner point in the target image, and transform the pixel coordinates of each chessboard corner point based on the initial transformation matrix to determine the initial world coordinates of each chessboard corner point; The correction module is used to correct the initial world coordinates of each chessboard corner point according to the rule that the world coordinates of the chessboard corner points are integer multiples of the size of a single chessboard square, so as to obtain the corrected world coordinates of each chessboard corner point. The calibration module is used to calibrate the camera based on the correspondence between the pixel coordinates of each chessboard corner point and the corrected world coordinates.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the camera calibration method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the camera calibration method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Internal reference evaluation method and device, terminal and storage medium
CN116152350A
High-robustness and high-precision camera calibration board and angular point detection method
CN118674789A