A method and system for calculating optical distortion
By acquiring the expected image boundary of the actual image from the camera and constructing the internal distortion region, optical distortion is calculated using camera intrinsic parameters. This solves the problems of resource consumption and operational complexity in optical distortion detection in existing technologies, and achieves simple and efficient optical distortion detection.
Patent Information
- Application Number
- CN202311066853.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-23
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-08-23
AI Technical Summary
Existing technologies for optical distortion detection require high-precision tooling, specialized calibration targets, and highly skilled operators, resulting in high resource consumption and complex operation.
By acquiring the expected image boundary of the actual image, constructing the internal distortion region, and using camera intrinsic parameters to calculate optical distortion, optical distortion detection is performed using a simple image processing method, avoiding the use of professional calibration targets.
It achieves low-resource-consumption and simple-to-operate optical distortion detection, which can be completed simultaneously during camera intrinsic parameter calibration without the need for high-precision tooling and professional calibration targets.
Smart Images

Figure CN117036504B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of optical imaging equipment, and more particularly to a method and system for calculating optical distortion. Background Technology
[0002] With the diversification of application scenarios, camera usage solutions are also becoming more diverse. In the early stages of image processor and camera selection and matching, the distortion caused by the combination of camera and image processor is one of the important indicators in the selection guide reference specifications. This distortion is measured by optical distortion.
[0003] The aforementioned optical distortion parameters are closely related to camera placement (especially the layout of vehicle-mounted cameras) and the effectiveness of subsequent distortion correction; therefore, the measurement of optical distortion parameters in the early stages is crucial.
[0004] In existing technologies, optical distortion of cameras is mostly obtained based on the international standard ISO 17850:2015 (Photography Digital Cameras Geometric Distortion (GD) Measurements). The main process involves photographing a grid chart with a physical camera, measuring the positions of certain points in the acquired chart image using measuring tools, and then substituting these measurements into a formula for calculation. This method requires high-precision fixtures and specific calibration targets (such as specific infrared distortion detection targets), and it is essential to ensure that the camera's optical axis is perpendicular to the target surface. This process is extremely resource-intensive, requiring significant manpower, materials, and financial investment. Alternatively, the theoretical image height can be calculated based on a distortion table provided by the camera supplier, and then the optical distortion can be calculated. However, this method requires the supplier to provide the distortion table, and the operator must be familiar with its usage, demanding a high level of expertise from the operator. Summary of the Invention
[0005] The purpose of this invention is to provide an optical distortion calculation method and system, which has low resource consumption and simple operation. Optical distortion detection can be completed simultaneously during the camera intrinsic parameter calibration process, without the need for professional calibration targets and with low requirements for tooling accuracy.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] On the one hand, a method for calculating optical distortion is provided, which includes the following steps:
[0008] Acquire the actual image and the expected image of the target;
[0009] The actual image is then subjected to distortion correction processing;
[0010] The region to be distorted within the actual image after distortion removal is obtained based on the outer boundary of the actual image after distortion removal, and distortion removal is applied to the region to be distorted to obtain the distorted region.
[0011] And obtain the degree of optical distortion based on the expected image and the distorted area.
[0012] Preferably, the size of the expected image is denoted as w1*h1, where w1 is the number of pixels in the width direction and h1 is the number of pixels in the height direction, and w1 and h1 are obtained by the following formulas respectively:
[0013]
[0014] Where f is the focal length of the camera lens, α is the horizontal field of view of the camera lens, β is the vertical field of view of the camera lens, and dx and dy are the length and width of the camera pixel, respectively.
[0015] Preferably, the actual image is subjected to distortion correction processing as follows:
[0016] x′=x(1+k1r 2 +k2r 4 +k3r 6 )+2p1xy+p2(r 2 +2x 2 )
[0017] y′=y(1+k1r 2 +k2r 4 +k3r 6 )+p1(r 2 +2y 2 )+2p2xy
[0018] Where x' and y' are the x and y coordinates of a pixel in the actual image, respectively; r 2 =x 2 +y 2 x and y are the horizontal and vertical coordinates of the pixels in the actual image when no optical distortion occurs, respectively; k1, k2, and k3 are the radial distortion coefficients of the camera's intrinsic parameters, and p1 and p2 are the tangential distortion coefficients of the camera.
[0019] Preferably, the region to be distorted is a quadrilateral region formed by four sides connected in sequence, and each side of the quadrilateral is tangent to one side of the outer boundary of the actual image after distortion removal.
[0020] Preferably, the distortion processing of the region to be distorted is performed using the following formula:
[0021] x”=x c(1+k1r 2 +k2r 4 +k3r 6 )+2p1x c y c +p2(r 2 +2x c 2 )
[0022] y”=y c (1+k1r 2 +k2r 4 +k3r 6 )+2p2x c y c +p1(r 2 +2y c 2 )
[0023] Where x” and y” are the x and y coordinates of the pixel in the region to be distorted and after distortion processing, respectively; r 2 =x c 2 +y c 2 ;x c y c k1, k2, and k3 are the x and y coordinates of the pixels in the region to be distorted, respectively; k1, k2, and k3 are the radial distortion coefficients of the camera intrinsic parameters, and p1 and p2 are the tangential distortion coefficients of the camera.
[0024] Preferably, the degree of optical distortion is obtained based on the expected image and the diagonal length of the distorted region.
[0025] Preferably, obtaining the diagonal length of the distorted region includes the following steps:
[0026] Obtain the coordinates of all points on the outer boundary of the distorted region;
[0027] Obtain the coordinates q1 of the midpoint of the upper boundary and the coordinates q2 of the midpoint of the left boundary;
[0028] The corner points of the distorted 1 / 4 region are determined based on the coordinates of the points within the distorted 1 / 4 region.
[0029] Repeat the above process to determine the remaining corner points of the distorted region, and determine the length of the diagonal of the distorted region based on the coordinates of the two corner points on the diagonal.
[0030] Preferably, obtaining the corner points of the 1 / 4 distorted region includes the following steps: calculating the corresponding vector of each point q within the 1 / 4 distorted region. The point corresponding to the maximum value of the cosine of the angle θ formed is the corner point of the 1 / 4 part of the distortion region.
[0031] Preferably, the degree of optical distortion is obtained according to the following:
[0032]
[0033] Where D is the degree of optical distortion, K1 is the diagonal length of the expected image, and K2 is the diagonal length of the distorted region.
[0034] On the other hand, an optical distortion calculation system is also provided, which includes:
[0035] The expected image acquisition unit is used to acquire the size of the expected image of the target;
[0036] The distortion correction unit is used to correct distortion in the actual image of the target.
[0037] The distortion region acquisition unit is used to determine the four sides of the distortion region to be added based on the outer boundary of the actual image after distortion removal.
[0038] A distortion processing unit is used to perform distortion processing on the region to be distorted in order to obtain a distorted region.
[0039] An optical distortion acquisition unit is used to acquire the degree of optical distortion based on the expected image and the distorted region.
[0040] In summary, the present invention has the following advantages compared with the prior art:
[0041] This invention first obtains the boundary of the expected image without optical distortion from the actual image, then constructs the internal distortion region, and then obtains the degree of optical distortion by the change in the length of the diagonal of the expected image and the boundary of the distortion region. This method has low resource consumption and simple operation. Optical distortion detection can be completed simultaneously during the camera intrinsic parameter calibration process. It does not require the use of professional calibration targets and has low requirements for tooling accuracy. Attached Figure Description
[0042] Figure 1 This is a flowchart of the optical distortion calculation method in this invention.
[0043] Figure 2 This is a schematic diagram illustrating the positional relationship between the actual image, the desired image, and the distorted region in this invention.
[0044] Figure 3 This is a schematic diagram showing the positional relationship between the actual image and the distorted region in this invention.
[0045] Figure 4 This is a schematic diagram showing the positional relationship between the desired image and the diagonal of the distorted region in this invention.
[0046] Figure 5 This is a schematic diagram of the optical distortion calculation system in this invention. Detailed Implementation
[0047] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0048] Example 1
[0049] like Figure 1 As shown, this embodiment provides a method for calculating optical distortion based on camera intrinsic parameter calibration results, which includes the following steps:
[0050] S1. Obtain the camera's intrinsic parameter calibration parameters; In this embodiment, the camera includes an infrared camera, and the intrinsic parameter calibration parameters include the camera's intrinsic parameter matrix and distortion vector;
[0051] In this embodiment, the intrinsic parameter matrix and the distortion vector are obtained through formulas (1)-(2), respectively:
[0052]
[0053] distcoff=[k1 k2 p1 p2 k3] (2)
[0054] Where K is the intrinsic parameter matrix, f is the focal length of the camera lens, and f x The range of values is Furthermore, the value range of Δx is [0.5%, 3%] (particularly preferred to be 3%), f y The range of values is Furthermore, the value range of Δy is [0.5%, 3%] (particularly preferred to be 3%), c x c y dx and dy are the x and y coordinates of the principal point, respectively; discoff is the distortion vector; k1, k2, and k3 are radial distortion coefficients, and p1 and p2 are tangential distortion coefficients; dx and dy are the length and width of the camera pixel, respectively.
[0055] Furthermore, the radial distortion coefficients k1, k2, and k3 are determined by the optical distortion and TV distortion of the camera lens and need to be obtained through camera calibration. Taking a lens with a focal length of f = 9.1mm and a field of view of 45*37 as an example, the value range of k1 is -0.27 to -0.32, the value range of k2 is 0.05 to 0.12, and the value range of k3 is -0.01 to 0.01. The tangential distortion coefficients p1 and p2 are determined by whether the lens is parallel to the sensor surface, and the default value of p1 and p2 is set to 0.
[0056] It should be noted that the above-mentioned technical solutions for obtaining the camera's intrinsic parameter matrix and distortion vector through the above formulas (1)-(2) are all feasible methods, and any other technical solutions that can obtain the intrinsic parameter matrix and distortion vector are within the protection scope of this application.
[0057] S2, Obtain the actual image P1 of the target through the camera (e.g., ... Figure 2 As shown), the actual image P1 has an outer boundary L1, and the target can include targets of various shapes. The shape of the target is related to the lens resolution. For example, when the camera lens resolution is 640×512 and 512×512, the target shape can be a rectangle and a square, respectively. At the same time, it should be noted that due to the optical distortion of the camera, each pixel in the actual image P1 will also undergo different degrees of optical distortion.
[0058] The size (i.e. resolution) of the actual image P1 is denoted as w*h, where w is the number of pixels in the width direction and h is the number of pixels in the height direction.
[0059] S3. Obtain the size of the expected image P2 of the target and determine the outer boundary of the expected image P2; the size of the expected image P2 refers to the size of the target image that the camera can obtain without any optical distortion.
[0060] Specifically, the size of the expected image P2 is denoted as w1*h1, where w1 is the number of pixels in the width direction, h1 is the number of pixels in the height direction, and w1≥w, h1≥h;
[0061] Furthermore, w1 and h1 are obtained respectively through formulas (3)-(4):
[0062]
[0063] Where f is the focal length of the camera lens, α is the horizontal field of view of the camera lens, and β is the vertical field of view of the camera lens;
[0064] Determining the outer boundary of the expected image P2 involves the following steps:
[0065] Determine the center point of the actual image P1
[0066] Center point of actual image P1 Centered on the target image P2, draw the outer boundary L2 of the target image P2 according to the size w1*h1, meaning that the actual image P1 and the target image P2 have a common center point.
[0067] S4, such as Figure 3 As shown, the actual image P1 is subjected to distortion correction processing, and the outer boundary L1' of the actual image P1' after distortion correction processing is determined.
[0068] Specifically, in this embodiment, each pixel in the actual image P1 is subjected to distortion correction using formula (5) to obtain the coordinates of each pixel when no optical distortion occurs:
[0069] x′=x(1+k1r 2 +k2r 4 +k3r 6 )+2p1xy+p2(r 2 +2x 2 )
[0070] y′=y(1+k1r 2 +k2r 4 +k3r 6 )+p1(r 2 +2y 2 )+2p2xy(5)
[0071] Where x' and y' are the x and y coordinates of the pixel in the actual image P1 (i.e., the pixel that has undergone optical distortion), respectively, and both can be known through analysis of the actual image P1; r 2 =x 2 +y 2 x and y are the x and y coordinates of the pixels in the actual image P1 when no optical distortion occurs, respectively.
[0072] Furthermore, the distortion-free actual image P1' is obtained by using the coordinates (x, y) of each pixel in the actual image P1 when no optical distortion occurs. Figure 3 The white portion in the image), and the actual image P1' after distortion removal has an outer boundary L1';
[0073] It should be noted that the distortion removal process is the process of obtaining x and y through known x' and y'. However, as shown in the above formula (5), formula (5) is a nonlinear equation and cannot be directly solved by x' and y' to obtain x and y. Therefore, in this embodiment, it can be solved by iterative method. When the error between the x value of two adjacent steps and the y value of two adjacent steps meets the preset condition (such as less than or equal to 0.001) through iterative calculation, the iteration stops. At this time, the x and y values can be obtained. This iterative algorithm is the prior art and will not be described in detail. Alternatively, the x and y values can also be obtained by calculating the undistortPoints() correction function in OpenCV.
[0074] S5. Obtain the distortion region C to be distorted within the actual image P1' after distortion removal, and perform distortion removal processing on the distortion region C.
[0075] In this embodiment, the region C to be distorted is a quadrilateral region formed by four sides connected sequentially. The quadrilateral is a square or rectangle, and each side of the quadrilateral is tangent to one side of the outer boundary L1' of the actual image P1' after distortion removal. The center point of the region C to be distorted is also...
[0076] Furthermore, in this embodiment, the distortion processing of the region C to be distorted is performed according to formula (6):
[0077] x”=x c (1+k1r 2 +k2r 4 +k3r 6 )+2p1x c y c +p2(r 2 +2x c 2 )
[0078] y”=y c (1+k1r 2 +k2r 4 +k3r 6 )+2p2x c y c +p1(r 2 +2y c 2 (6)
[0079] Where x” and y” are the x and y coordinates of the pixel in the region C to be distorted, respectively, after distortion processing; r 2 =x c 2 +y c 2;x c y c These are the x and y coordinates of the pixel in the region C to be distorted, respectively, and both can be known through the analysis of the region C to be distorted.
[0080] It should be noted that the distortion processing described herein is achieved by using known x... c y c The process of obtaining x” and y”;
[0081] Therefore, the distortion processing described above can be used to obtain, for example, Figure 2 The distorted region C' shown has an outer boundary C1, and the center point of the distorted region C' is also... Meanwhile, in this embodiment, the actual image P1, the expected image P2, the actual image P1' after distortion correction, and the distortion region C' are all axisymmetric figures.
[0082] S6. Obtain the diagonal length K1 of the outer boundary L2 of the expected image P2, and obtain the diagonal length K2 of the outer boundary C1 of the distorted region C':
[0083] The diagonal length K1 of the outer boundary L2 of the expected image P2 is obtained according to formula (7):
[0084]
[0085] like Figure 2 As shown, obtaining the diagonal length K2 of the outer boundary C1 of the distorted region C' includes the following steps:
[0086] The coordinates of all points on the outer boundary C1 of the distorted region C' can be obtained using functions such as findContours() in OpenCV.
[0087] Obtain the coordinates q1 of the midpoint of the upper boundary C11' and q2 of the midpoint of the left boundary C2';
[0088] Determine the corner point O1 of the distorted region C' (i.e., part Q1) based on the coordinates of the points within that 1 / 4 portion. Specifically, the x-coordinate of each point within the distorted region C' is less than the x-coordinate of q1, and the y-coordinate is less than the y-coordinate of q2. The corresponding vector for each point q within the distorted region C' is then calculated. The cosine value (cosθ) of the angle θ formed is the point O1 of the 1 / 4 part of the distortion region C' when the cosine value is the largest (i.e., θ is the smallest).
[0089] Repeat the above process to determine the remaining corner points of the distorted region C', and determine the length K2 of the diagonal of the distorted region C' based on the coordinates of the two corner points on the diagonal (such as corner point O1 of the upper left 1 / 4 of the distorted region C' and corner point O2 of the lower right 1 / 4 of the distorted region C').
[0090] And S7, obtain the degree of optical distortion based on the diagonal length K1 of the outer boundary L2 of the expected image P2 and the diagonal length K2 of the outer boundary C1 of the distorted region C';
[0091] Specifically, in this embodiment, the degree of optical distortion is obtained according to formula (8):
[0092]
[0093] Where D represents the degree of optical distortion.
[0094] Because the actual image P1 has optical distortion, its resolution is inconsistent with that of the expected image P2. Therefore, the degree of optical distortion cannot be directly calculated using the diagonal of the actual image P1. Thus, in this embodiment, the boundary of the expected image P2 without optical distortion is first obtained from the actual image P1. Then, an internal distortion region (i.e., distortion region C') is constructed. The degree of optical distortion is then obtained by measuring the change in the length of the diagonal of the expected image P2 and the boundary of the distortion region. This avoids the errors that occur when directly using the diagonal of the actual image P1 to obtain the degree of optical distortion. This process consumes few resources, is simple to operate, and can be completed simultaneously during camera intrinsic parameter calibration. It does not require a professional calibration target and has low requirements for tooling accuracy. For example, it does not require ensuring that the camera optical axis is perpendicular to the distortion detection target surface, nor does it require referring to existing technologies such as ISO 17850 for optical distortion detection.
[0095] Example 2:
[0096] This embodiment provides an optical distortion calculation system based on camera intrinsic parameter calibration results, which can implement the optical distortion calculation method described in Embodiment 1, such as... Figure 5 As shown, the optical distortion calculation system includes:
[0097] The expected image acquisition unit 1 is used to acquire the size of the expected image P2 of the target and determine the outer boundary of the expected image P2;
[0098] The distortion correction processing unit 2 is used to perform distortion correction processing on the actual image P1 of the target to obtain the outer boundary L1' of the actual image P1' after distortion correction processing. The process is the same as step S3.
[0099] The distortion region acquisition unit 3 is used to determine the four sides of the distortion region C to be distorted based on the outer boundary L1' of the actual image P1' after distortion removal, and connect the four sides in sequence to obtain the distortion region C to be distorted.
[0100] The distortion processing unit 4 is used to perform distortion processing on the region C to be distorted to obtain the distorted region C'. The process is the same as step S4.
[0101] Optical distortion acquisition unit 5 is used to acquire the degree of optical distortion based on the diagonal length K1 of the outer boundary L2 of the expected image P2 and the diagonal length K2 of the outer boundary C1 of the distorted region C'. The process of acquiring the diagonal length is the same as step S5, and the process of acquiring the degree of optical distortion is the same as step S6.
[0102] And an intrinsic parameter calibration parameter acquisition unit 6, which is used to acquire the camera's intrinsic parameter calibration parameters.
[0103] In summary, this application first obtains the boundary of the expected image without optical distortion from the actual image, then constructs the internal distortion region, and then obtains the degree of optical distortion by changing the length of the diagonal of the expected image and the boundary of the distortion region. This avoids the error caused when directly using the diagonal of the actual image to obtain the degree of optical distortion. This process has low resource consumption, is simple to operate, and can be completed simultaneously during the camera intrinsic parameter calibration process. It does not require the use of professional calibration targets and has low requirements for tooling accuracy.
[0104] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method of optical distortion calculation, characterized by, The method comprises the following steps: acquiring an actual image and an expected image of a target; performing de-distortion processing on the actual image; acquiring a to-be-distorted region in the de-distortion-processed actual image according to an outer boundary of the de-distortion-processed actual image, and performing distortion processing on the to-be-distorted region to obtain a distorted region; the to-be-distorted region is a quadrilateral region formed by four edges connected in sequence, and each edge of the quadrilateral corresponds to a tangent edge of the outer boundary of the de-distortion-processed actual image; and acquiring an optical distortion degree according to the expected image and a diagonal length of the distorted region.
2. The optical distortion calculation method of claim 1, wherein, The size of the expected image is denoted as w1*h1, wherein w1 is the number of pixel points in the width direction, h1 is the number of pixel points in the height direction, and w1 and h1 are obtained by the following formulas respectively: wherein f is the focal length of a camera lens, a is the horizontal field of view angle of the camera lens, b is the vertical field of view angle of the camera lens, dx and dy are the length and width of a camera pixel respectively.
3. The optical distortion calculation method of claim 1, wherein, The de-distortion processing on the actual image is performed by the following formula: x' = x (1 + k1r 2 + k2r 4 + k3r 6 ) + 2p1xy + p2(r 2 + 2x 2 ) y' = y (1 + k1r 2 + k2r 4 + k3r 6 ) + p1(r 2 + 2y 2 ) + 2p2xy wherein x', y' are horizontal and vertical coordinates of the pixel in the actual image; r 2 = x 2 +y 2 ; x, y are horizontal and vertical coordinates of the pixel in the actual image without optical distortion; k1, k2, k3 are radial distortion coefficients of the camera intrinsic parameters; p1, p2 are tangential distortion coefficients of the camera.
4. The optical distortion calculation method of claim 1, wherein, The distortion processing on the to-be-distorted region is performed by the following formula: x" = x c (1 + k1r 2 +k2r 4 +k3r 6 )+2p1x c y c +p2(r 2 +2x c 2 ) y" = y c (1 + k1r 2 +k2r 4 +k3r 6 )+2p2x c y c +p1(r 2 +2y c 2 ) Where x” and y” are the x and y coordinates of the pixel in the region to be distorted and after distortion processing, respectively; r 2 =x c 2 +y c 2 ;x c y c k1, k2, and k3 are the x and y coordinates of the pixels in the region to be distorted, respectively; k1, k2, and k3 are the radial distortion coefficients of the camera intrinsic parameters, and p1 and p2 are the tangential distortion coefficients of the camera.
5. The optical distortion calculation method of claim 1, wherein, The acquisition of the diagonal length of the distorted region comprises the following steps: acquiring the coordinates of all points on the outer boundary of the distorted region; acquiring the coordinates of the midpoint q1 of the upper boundary and the coordinates of the midpoint q2 of the left boundary; determining the corner point of the 1 / 4 part of the distorted region according to the coordinates of the points in the 1 / 4 part of the distorted region; repeating the above process to determine the remaining corner points of the distorted region, and determining the length of the diagonal of the distorted region according to the coordinates of the two corner points on the diagonal.
6. The optical distortion calculation method of claim 5, wherein, The steps for obtaining the corner point of the 1 / 4 partial distortion region include: calculating the corresponding vector of each point q in the 1 / 4 partial distortion region The cosine value of the angle θ is obtained, and the corresponding point when the cosine value is maximum is the corner point of the 1 / 4 partial distortion region.
7. The optical distortion calculation method of claim 1, wherein, The optical distortion degree is acquired according to the following formula: wherein D is the optical distortion degree, K1 is the diagonal length of the expected image, and K2 is the diagonal length of the distorted region.
8. An optical distortion calculation system for implementing the method of any one of claims 1 to 7, characterized by The method comprises the following steps: an expected image acquisition unit for acquiring the size of the expected image of the target; a de-distortion processing unit for performing de-distortion processing on the actual image of the target; a to-be-distorted region acquisition unit for determining the four edges of the to-be-distorted region according to the outer boundary of the de-distortion-processed actual image; a distortion processing unit for performing distortion processing on the to-be-distorted region to obtain a distorted region; an optical distortion acquisition unit for acquiring an optical distortion degree according to the expected image and the distorted region.
Citation Information
Patent Citations
Gesture recognition method and apparatus, and electronic device
CN106934351A
Optical distortion correction method and device, terminal equipment and storage medium
CN110874135A