A method, device, medium and equipment for automatically detecting camera distortion
By fixing the focal length in the camera and obtaining the coordinate difference between image feature points and the center point, distortion can be automatically detected, solving the problems of cumbersome testing and uncertain parameters in the existing technology, and improving the accuracy and adaptability of distortion coefficients.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2026-03-20
AI Technical Summary
Existing technologies for camera distortion correction involve cumbersome testing and uncertain parameters, resulting in low efficiency and an inability to adapt to changes in the operating environment and the effects of vibration during transportation.
By fixing a camera at the focal length to be tested, the scene image is acquired and the calibration point is determined. Feature points are identified, angle values are recorded, a coordinate system is constructed, distortion coefficients are calculated, and distortion is automatically detected using the coordinate difference between the image feature points and the center point.
It enables automatic distortion detection after camera installation, improving the accuracy of distortion coefficients and adapting to the detection needs of multiple scenarios.
Smart Images

Figure CN116258766B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of image processing, and particularly relate to a camera distortion automatic detection method and device, medium and equipment. BACKGROUND
[0002] With the development of science and technology, in the aspect of security monitoring, cameras are widely used. Most of the cameras support zooming and can accurately control the rotation of horizontal and vertical motors, so that the position of the monitoring area changes.
[0003] In a camera imaging system, the camera needs to support image distortion correction. The current mainstream method of distortion correction is to align the camera to a grid chart during production, and to obtain distortion values and set distortion correction coefficients according to the imaging of the grid chart in the picture.
[0004] Currently, for the existing technical solutions for obtaining distortion values and setting distortion correction coefficients, the same size grid chart is photographed at different focal lengths. When the grid chart is imaged in the picture, different shooting distances need to be adjusted, and the test work is tedious and the test scene is single. In addition, due to the influence of factors such as changes in the use environment and vibration during transportation, the camera distortion parameters often change, resulting in that the parameters calibrated during production change after actual installation and use, and the distortion data changes, which leads to low efficiency and uncertain parameters. SUMMARY
[0005] Embodiments of the present application provide a camera distortion automatic detection method, device, medium and equipment, which can measure the image distortion by the coordinate difference between different image feature points and center points.
[0006] In a first aspect, the embodiments of the present application provide a camera distortion automatic detection method, which comprises:
[0007] fixing the camera at a focal length to be detected, obtaining a scene image, and determining a calibration point of the image according to a preset rule; wherein the theoretical angle coordinates of the calibration point are known;
[0008] identifying the calibration point in the scene image that can be matched to a feature point as a target calibration point;
[0009] obtaining the angle value of the original position of the center position of the scene image, and controlling the camera to rotate so that the center position moves from the original position to the position of each target calibration point, and recording the angle value of the position of each target calibration point;
[0010] constructing a coordinate system with the original position as the origin of the coordinate system, and determining the actual angle coordinates of the position of each target calibration point according to the difference between the angle value of the position of each target calibration point and the angle value of the original position;
[0011] According to the actual angle coordinates of the positions of the target calibration points in the focal section to be detected and the theoretical angle coordinates of the target calibration points, the distortion coefficients of the target calibration points are determined.
[0012] In a second aspect, the embodiments of the present application provide an automatic detection device for camera distortion, which comprises:
[0013] An image acquisition module is configured to fix the camera at a focal section to be detected, acquire a scene image, and determine calibration points of the image according to a preset rule, wherein the theoretical angle coordinates of the calibration points are known.
[0014] An image recognition module is configured to recognize the calibration points in the scene image that can be matched to the feature points as target calibration points.
[0015] An angle acquisition module is configured to acquire an angle value of an original position of a center position of the scene image, and control the camera to rotate so that the center position moves from the original position to the positions of the target calibration points, and record the angle values of the positions of the target calibration points.
[0016] A coordinate establishment module is configured to establish a coordinate system with the original position as an origin of the coordinate system, and determine the actual angle coordinates of the positions of the target calibration points according to the difference between the angle values of the positions of the target calibration points and the angle value of the original position.
[0017] A coefficient determination module is configured to determine the distortion coefficients of the target calibration points according to the actual angle coordinates of the positions of the target calibration points in the focal section to be detected and the theoretical angle coordinates of the target calibration points.
[0018] In a third aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the automatic detection method for camera distortion according to the embodiments of the present application.
[0019] In a fourth aspect, the embodiments of the present application provide an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable by the processor, and the processor implements the automatic detection method for camera distortion according to the embodiments of the present application when executing the computer program.
[0020] The technical scheme provided by the embodiment of the application comprises the following steps: fixing a camera on a to-be-detected focal section, determining calibration points of an image according to a preset rule; identifying calibration points that can be matched to feature points in a scene image as target calibration points, recording angle values of positions of the target calibration points; constructing a coordinate system with an original position as an original point of the coordinate system, determining actual angle coordinates of positions of the target calibration points; and determining distortion coefficients of the target calibration points according to the actual angle coordinates of positions of the target calibration points in the to-be-detected focal section and theoretical angle coordinates of the target calibration points. The technical scheme can automatically detect distortion by using coordinate differences between different image feature points and theoretical angle coordinates after the camera is installed, and can realize detection of multiple scenes by pre-determining target calibration points and adjusting different detection focal sections, thereby improving accuracy of the distortion coefficients. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 is a flowchart of a camera distortion automatic detection method provided by the embodiment one of the application;
[0022] Figure 2 is a segmented image of an image picture provided by the embodiment one of the application;
[0023] Figure 3 is a new coordinate system construction diagram provided by the embodiment one of the application;
[0024] Figure 4 is a distortion measurement method diagram provided by the embodiment one of the application;
[0025] Figure 5 is a flowchart of another camera distortion automatic detection method provided by the embodiment two of the application;
[0026] Figure 6 is a structural block diagram of a camera distortion automatic detection device provided by the embodiment three of the application;
[0027] Figure 7 is a structural schematic diagram of an electronic device provided by the embodiment five of the application. DETAILED DESCRIPTION
[0028] The application will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the application, but not to limit the application. In addition, it should be noted that, for the convenience of description, only parts related to the application are shown in the drawings, but not all structures.
[0029] Before any examples are described in further detail, it should be noted that some examples are described as processes or methods that can be depicted as a flow diagram or flow chart. Although a variety of processes can be described as processes or methods in a flow diagram, it should be understood that any sequence of processes can be performed in any order. Further, some processes can be performed simultaneously, in parallel, or concurrently. A process can be an algorithm or a routine. Processes can also be stored as instructions in a computer-readable medium. Processes can also be implemented as computer programs, code or instructions that can be executed by a computer or computer processor.
[0030] Embodiment One
[0031] Figure 1 is a flowchart of the camera distortion automatic detection method provided by Embodiment One of the present application. The present embodiment can be applicable to the case of performing measurement and correction in the actual monitoring scene of the camera. The method can be performed by the camera distortion automatic detection device provided by the present application. The device can be implemented by software and / or hardware, and can be integrated into an electronic device.
[0032] As shown in Figure 1 , the camera distortion automatic detection method provided by Embodiment One of the present application includes the following steps:
[0033] S110, fix the camera at a to-be-detected focal segment, acquire a scene image, and determine a calibration point of the image according to a preset rule.
[0034] The pixel coordinates of the calibration point are known, and thus the theoretical angle coordinates thereof are also known and can be converted according to the pixel coordinates. The calibration point specifically refers to a pixel point in the image. The pixel coordinates of the pixel point are calculated and determined according to the horizontal and vertical distances of the image picture and the size of the segmented small square.
[0035] The camera refers to a device that converts an optical image signal into an electrical signal for storage or transmission. The camera refers to a camera with a pan-tilt head. The pan-tilt head can carry the camera to rotate in the horizontal and vertical directions by the motor. The camera mounted on the pan-tilt head can be used to take pictures from multiple angles. The focal segment can be a segmented lens, i.e., a segmented range of the focal length of the lens. For example, it can be ultra-wide-angle, wide-angle, and standard, or it can be mid-focus, long-focus, and super-long-focus, etc. The present embodiment does not limit this. The to-be-detected focal segment refers to a lens segment that has not been detected. For example, when the lens focal length is divided into standard, mid-focus, and long-focus, after the standard and mid-focus are detected, the long-focus is referred to as the to-be-detected focal segment.
[0036] The scene image is an image facing a certain space and contains multiple visual elements; the preset rule refers to selecting a scene in a real scene for image acquisition, and dividing the image frame into N*M rectangular small squares, N is the horizontal arrangement number of the rectangular small squares, M is the vertical arrangement number of the rectangular small squares, the center of the frame is taken as the pixel coordinate origin (0, 0), and the intersection of the horizontal and vertical of the rectangular small squares is the calibration point of the image.
[0037] Specifically, after the focal length range to be detected by the camera is determined, the camera is fixed at the focal length range to be detected, and scene images in different directions are acquired in real time by performing real scene shooting, horizontal and vertical motor rotation, and position change of the motor gear. After the scene images are acquired, the calibration points of the images and the specific pixel coordinates of the calibration points are determined according to the size of the scene images and the size range of the divided rectangular small squares, so as to obtain the theoretical angle coordinates.
[0038] Exemplarily, Figure 2 is a divided image of the image frame provided by the first embodiment of the present application, as shown, Figure 2 the image frame is divided into 16*9 square small squares, the center point O of the frame is taken as the pixel coordinate (0, 0), if the horizontal distance of the scene image is 32 cm and the vertical distance is 18 cm, the pixel coordinates of each small square point can be obtained by specific calculation, then the pixel coordinates of the point (X1, Y1) corresponding to the calculation are (-16, 9); the pixel coordinates of the point (X1, Y2) are (16, 9); the pixel coordinates of the point (X2, Y1) are (16, -9); and the pixel coordinates of the point (X2, Y2) are (-16, -9). m+1 n+1 m+1 n+1
[0039] On the basis of the above-mentioned embodiments, the scene image is acquired, and the calibration points of the image are determined according to the preset rule, including: acquiring the scene image, and determining the vertex positions of each square in the scene image as the calibration points of the image according to the preset number of squares; and determining the angle coordinates of the pixel point positions of each calibration point in the scene image according to the number of squares and the size information of the squares, so as to obtain the theoretical angle coordinates.
[0040] The calibration point refers to a pixel point in the scene image, and the pixel is the smallest unit in the image represented by a numerical sequence. Specifically, when the acquired scene image is N*M in size, the image is divided by a ratio of P:Q, and the pixel of each small square after division is (N / P)*(M / Q). After the preset number of squares is determined, the number of squares obtained is (N+1)*(M+1). After the number of square points is obtained, the pixel point positions of the vertex positions of each square point in the scene image are determined as the calibration points of the image.
[0041] The theoretical angle coordinate refers to an ideal coordinate value obtained through theoretical numerical calculation. Specifically, the coordinate origin is determined as the image picture center, and the theoretical angle coordinates of the calibration points can be calculated through the number of squares and the size information of the squares. For example, an image picture with a size of 1920*1080 is obtained, which is divided into 16:9 equal parts, and the pixel of each small square is 120*120. There are a total of 10*17=170 square points, and the pixel coordinates of the upper left corner square point, the upper right corner square point, the lower left corner square point, and the lower right corner square point are (-960, 540), (960, 540), (-960, -540), and (960, -540), respectively, with the picture center point as the coordinate origin (0, 0). The advantage of this setting is that the theoretical angle coordinates of the calibration points can be accurately calculated according to the pre-set number of squares and the size information of the squares.
[0042] S120, identifying the calibration point that can match the feature point in the scene image as the target calibration point.
[0043] The feature point refers to a real object point in the image scene corresponding to each small square point. The target calibration point refers to a calibration point that can match the feature point in the identified scene.
[0044] Specifically, each small square point corresponds to a calibration point of the scene image of the image. When the real scene monitoring scene is performed, each small square point corresponds to a real object point in the image scene, which can be extracted as an image feature point through the fast Fourier transform algorithm. After obtaining the image feature point, the calibration point matched to the image feature point is taken as the target calibration point. The image feature point is a point with a sharp change in image gray value or a point with a large curvature on the image edge.
[0045] On the basis of the above technical solution, after the calibration point that can match the feature point in the identified scene image is identified as the target calibration point, the method further includes: if there is a calibration point that cannot match the feature point in the identified scene image, determining that a scene switching event is triggered; switching the angle of the camera to obtain a captured scene switching image; identifying the matching result of the calibration point that cannot match the feature point in the scene switching image; if the matching result covers all calibration points, terminating the switching; if the matching result does not cover all calibration points, continuing the switching until the termination condition is met.
[0046] The calibration points matched with the feature points refer to, when matching, if the calibration points coincide with the feature points or fall within a certain range of the calibration points, the calibration points matched with the feature points are determined; if there is no feature point of the scene image within a certain range of the calibration points, the calibration points not matched with the feature points are determined. Specifically, when there is no feature point of the scene image within a certain range of the calibration points, the calibration points not matched with the feature points are determined, the scene switching time is determined to be triggered, and the scene is converted to re-match. Exemplarily, since the real object points as the image feature points need to have relevant details, if the target in a part of the region in the scene is too single, such as the sky region, the real object points corresponding to the grid points in the region cannot be used as the image feature points, and in this case, the scene needs to be changed to re-extract.
[0047] Specifically, when there are multiple angles of the camera, for a scene image, the scene image can be acquired through multiple angles of the camera, if there is a calibration point in the scene image of the first angle that cannot be matched with the feature point, the scene image is re-acquired through other angles except the first angle to obtain the image of the scene at other angles. The advantage of this setting is that the calibration points matched with the feature points are matched through the scene images at different angles, and the matching accuracy of the calibration points is improved.
[0048] On the basis of the above embodiment, optionally, the termination condition includes that the termination is performed when a limited switching number is reached, or the termination is performed when all the calibration points are covered.
[0049] The limited switching number refers to the set angle of the camera. Specifically, when N angles are set, the switching number is N-1.
[0050] Specifically, in the identification of the scene image, when the existing calibration points cannot be all matched with the feature points of the image, the scene is re-selected, the camera is moved to adjust the scene, and the scene is re-acquired at a different angle until all the calibration points are covered by the feature points.
[0051] Exemplarily, when there are 36 calibration points in the first scene, after the calibration points matched with the feature points in the first scene are identified as target calibration points, only 20 target calibration points are matched, at this time, the camera angle is continuously switched, the second scene is selected for matching, and 10 target calibration points are matched in addition to the 20 target calibration points matched in the first scene, the scene is continuously switched, and 6 calibration points are matched in addition to the 30 target calibration points matched in the first two scenes when the third scene is switched, and the matching result covers all the calibration points to meet the termination condition. The advantage of this setting is that the actual coordinate difference between each pixel point and the center point is obtained through the pan-tilt rotation and the image feature point matching, and efficient matching of the calibration points is realized.
[0052] S130, obtaining an angle value of the original position of the center position of the scene image, controlling the camera to rotate, moving the center position from the original position to the position of each target calibration point, and recording the angle value of the position of each target calibration point.
[0053] The angle value refers to an angle formed by the position of the camera and the original position of the center position of the scene image when the camera captures the scene image.
[0054] Specifically, when the horizontal motor and the vertical motor start to rotate, the camera holder is moved and the angle value of the center point of the camera image is recorded in real time according to the position change of the motor gear. After moving the camera holder, the center point of the camera image is matched with each image feature point of the real object point in the scene S120, and the angle value at each matching time is recorded.
[0055] S140, constructing a coordinate system with the original position as the origin of the coordinate system, and determining the actual angle coordinates of the positions of the target calibration points according to the difference between the angle value of the position of each target calibration point and the angle value of the original position.
[0056] The difference between the angle values represents the actual target distance difference; and the actual angle coordinates represent the horizontal and vertical angle values of the camera in the space.
[0057] Specifically, the coordinate system is re-established with the actual angle coordinates of the center point of the camera image as (0, 0), the coordinate difference between the angle value of the position of each target calibration point and the angle value of the original position is taken as the coordinate of each small square point, and a new coordinate system is established. When the image is divided into N*M square small squares in the real scene monitoring scene, there are (N+1)*(M+1) small square points. If the current scene has a certain number of small square points corresponding to the feature points, the corresponding small square points are rotated one by one. If the corresponding small square points cannot be covered, the scene is adjusted, another dense scene is selected for image acquisition, and the coordinates of each small square point are collected until the new coordinate system is established.
[0058] For example, the actual angle coordinates of the center point O of the image are (0, 0), the coordinate difference between the actual angle coordinates of each image feature point and the actual angle coordinates of the center point of the image is taken as the new coordinate of each small square point, Figure 3 is a diagram of establishing a new coordinate system provided by the first embodiment of the application, as shown in Figure 3As shown, taking a 1920*1080 image divided into 16:9 equal parts as an example, each small square has 120*120 pixels, for a total of 10*17=170 squares. The pixel coordinates of the top left square are (-960, 540); the top right square is (960, 540); the bottom left square is (-960, -540); and the bottom right square is (960, -540). The actual angular coordinates of the center point of the image are (170, 20), and the actual angular coordinates of the top left corner (X'1, Y'1) are (150, 30). After re-establishing the coordinate system, the coordinates of the top left corner (X'1, Y'1) are (-20, 10).
[0059] S150. Determine the distortion coefficient of each target calibration point based on the actual angular coordinates of the position of each target calibration point in the focal length to be tested and the theoretical angular coordinates of each target calibration point.
[0060] Distortion refers to the difference between the actual image height and the image height under ideal conditions. In practical applications, distortion is often expressed as a percentage and is called the distortion coefficient, as shown in formula (1).
[0061]
[0062] Where D represents the distortion coefficient, s' is the actual angular coordinate of the target calibration point, and s'0 is the theoretical angular coordinate of each target calibration point.
[0063] Specifically, Figure 4 This is a diagram of the distortion measurement method provided in Embodiment 1 of this application, as shown below. Figure 4 As shown, a distorted grid image is captured, and the final image is composed of N*M squares with fixed side lengths, all without any distortion. The solid lines represent the image as captured in the frame, divided into small squares, while the dashed lines represent the actual captured grid. With the image center point (0, 0), the theoretical angular coordinates between the center point and point B are (X...). n Y n The actual angular coordinates between the center point and B' are (X'). n Y' n ).
[0064] The actual angle value (x') of the vertices of each small square n y' n It is known that this value is the angle value obtained by matching the image feature points after the gimbal rotates. The difference between the actual angle value of each small square vertex and the actual angle value of the center point of the image is used as the actual angle coordinate of that small square, that is, the actual angle coordinate (X'). n Y' n )=(x' n y' n)-(x' 中心点 y' 中心点 ).
[0065] Pixel coordinates (x) n y n The value is a theoretical value, unaffected by distortion, and directly obtained from the pixel position of that point in the image. It is assumed that the small square at the center of the image has no distortion. That is, when n is the vertex of the small square at the very center of the image, the theoretical angular coordinate (X...) is... 中心方格顶点 Y 中心方格顶点 )=(X' 中心方格顶点 Y' 中心方格顶点 ).
[0066] Furthermore, when n represents the vertices of small squares in other locations on the screen, the points in the same coordinate system quadrant have the following theoretical coordinates (X... n Y n )={X 中心方格顶点 *(x n -x 中心方格顶点 ), Y 中心方格顶点 *(y n -y 中心方格顶点}
[0067] The distortion coefficient is the ratio of the difference between the actual and theoretical angular coordinates of each pixel at the image center to the theoretical angular coordinates. That is, the horizontal distortion coefficient of point n is (X'... n -X n ) / X n The vertical distortion coefficient at point n (Y' n -Y n ) / Y n .
[0068] The technical solution provided in this application measure image distortion by the coordinate difference between different image feature points and the center point. After the camera is installed, distortion is automatically detected. By pre-determining the target calibration point and adjusting different detection focal lengths, multiple scene detections can be achieved, thereby improving the accuracy of the distortion coefficient.
[0069] Example 2
[0070] Based on the above embodiments, this embodiment further optimizes the process of determining the actual angular coordinates of each target calibration point after the above embodiments are completed. Figure 5 This is a flowchart of another automatic camera distortion detection method provided in Embodiment 2 of the present invention.
[0071] like Figure 5 As shown, the method in this embodiment specifically includes the following steps:
[0072] S510, fix the camera at the focal length to be detected, acquire a scene image, and determine a calibration point of the image according to a preset rule.
[0073] Specifically, the camera is fixed at the focal length to be detected, a scene image is acquired, a fixed image screen segmentation grid number, such as an N*M square small grid, is set in advance, a center of a scene image screen acquired by the camera is taken as a coordinate origin (0, 0), a vertex position of each small grid is obtained, and the vertex position of each small grid is determined as a calibration point of the image.
[0074] S520, identify a calibration point that can be matched to a feature point in the scene image as a target calibration point.
[0075] Specifically, each small grid in the scene image corresponds to an actual object point in the image actual scene, a feature is extracted as an image feature point, and the image feature point and the calibration point determined according to the vertex coordinate position of the small grid can be matched and consistent, so that the calibration point of the feature point is determined as the target calibration point.
[0076] S530, acquire an angle value of an original position of a center position of the scene image, control the camera to rotate, move the center position from the original position to a position of each target calibration point, and record an angle value of the position of each target calibration point.
[0077] S540, construct a coordinate system with the original position as a coordinate system origin, and determine actual angle coordinates of the position of each target calibration point according to a difference value between the angle value of the position of each target calibration point and the angle value of the original position.
[0078] S550, acquire actual angle coordinates of each pixel point in the scene image by using an interpolation method, and determine theoretical angle coordinates of each pixel point.
[0079] The interpolation method is to use known data to predict position data, and the difference value of the scene image is to give a pixel point, and the pixel point is predicted according to information of surrounding pixel points, and the picture interpolation is used when adjusting the picture size or picture deformation, for example, linear difference value, or bilinear difference value, and the embodiment is not limited in this regard.
[0080] Specifically, the scene is adjusted by moving the holder, another dense scene is selected for image acquisition, image feature points of remaining small grid points are recalibrated, and a coordinate difference when the image center point coincides is acquired, until all coordinate of the small grid points are acquired, coordinate values of all pixel points in the image under a new coordinate system are acquired by interpolation, and theoretical angle coordinates of each pixel point are determined.
[0081] S560, determine a distortion coefficient of each pixel point in the focal length to be detected according to the actual angle coordinates of each pixel point and the theoretical angle coordinates of each pixel point.
[0082] Specifically, according to the actual angle coordinates of each pixel point and the theoretical angle coordinates of each pixel point, a coordinate difference value is calculated, and the distortion coefficient of each pixel point is measured by a ratio of a coordinate difference value of the actual angle coordinates of each pixel point to a coordinate of the image center point to a difference value of the theoretical angle coordinates of each pixel point to the coordinate of the image center point.
[0083] The technical scheme provided by the embodiment of the application obtains the actual angle coordinates of each pixel point in the scene image by using the interpolation method, and determines the theoretical angle coordinates of each pixel point; according to the actual angle coordinates of each pixel point and the theoretical angle coordinates of each pixel point, the distortion coefficient of each pixel point in the to-be-detected focal length section is determined, and the accuracy of the distortion coefficient is improved according to the determined actual angle coordinates of each pixel point and the theoretical angle coordinates of each pixel point.
[0084] On the basis of the above technical scheme, optionally, parameter information of the camera is read to determine all focal length sections supported by the camera; all focal length sections of the camera are traversed to obtain the distortion coefficient of all pixel points in each focal length section.
[0085] The parameter information includes a rotation angle, a monitoring range, a rotation speed and the like of the camera, and the embodiment is not limited in this regard. The focal length section is a division range of the focal length of the lens, and the division of the focal length section is as follows: first, a standard lens, that is, a so-called standard lens. The angle of view thereof is about 43 degrees, and at this time, the perspective of the photo is closest to the human eye. The focal length of the standard lens is different for different film formats. The standard lens for the 135 film format is about 50 mm, the 6*6 standard lens for the 120 film format has a focal length of 80 mm, and the standard lens for the 300d film format has a focal length of about 50 ÷ 1.5 = 33 mm.
[0086] Specifically, by determining all focal length sections of the camera, if the focal length sections include an ultra-wide-angle, a wide-angle, a standard, a medium focus, a medium telephoto, a telephoto and an ultra-telephoto, the steps S510-S270 are repeated for each focal length section of the camera to obtain the distortion coefficient of all pixel points in each focal length section. The advantage of this setting is that the distortion coefficient of each focal length section of the camera is obtained in all directions, and online distortion correction is performed on all pixel points under all focal length sections to improve the accuracy of image position calibration.
[0087] On the basis of the above technical scheme, optionally, the distortion coefficient is a ratio of a difference value of the actual angle coordinates of each pixel point to the theoretical angle coordinates of each pixel point to the theoretical angle coordinates. The advantage of this setting is that the distortion coefficient of different points is measured according to the ratio of the actual coordinate difference to the ideal coordinate difference, and the accuracy of the distortion coefficient is improved.
[0088] Embodiment Three
[0089] Figure 6 A structural block diagram of an automatic camera distortion detection device provided for Embodiment Three of the present application is shown in Figure 6 The automatic camera distortion detection device specifically comprises an image acquisition module 610, an image recognition module 620, an angle acquisition module 630, a coordinate establishment module 640 and a coefficient determination module 650. Among them,
[0090] The image acquisition module 610 is configured to fix the camera at a focal segment to be detected, acquire a scene image, and determine calibration points of the image according to a preset rule; wherein the theoretical angle coordinates of the calibration points are known.
[0091] The image recognition module 620 is configured to identify calibration points in the scene image that can be matched to feature points as target calibration points.
[0092] The angle acquisition module 630 is configured to acquire an angle value of an original position of a center position of the scene image, and control the camera to rotate so that the center position moves from the original position to a position of each target calibration point, and record an angle value of the position of each target calibration point.
[0093] The coordinate establishment module 640 is configured to construct a coordinate system with the original position as an origin of the coordinate system, and determine actual angle coordinates of the position of each target calibration point according to a difference between the angle value of the position of each target calibration point and the angle value of the original position.
[0094] The coefficient determination module 650 is configured to determine distortion coefficients of each target calibration point according to the actual angle coordinates of the position of each target calibration point in the focal segment to be detected and the theoretical angle coordinates of each target calibration point.
[0095] Optionally, the image acquisition module 610 comprises:
[0096] A calibration point determination unit is configured to acquire the scene image, and determine vertex positions of each square in the scene image as calibration points of the image according to a preset number of squares.
[0097] A theoretical angle coordinate determination unit is configured to determine pixel point positions of each calibration point in the scene image according to the number of squares and size information of the squares, so as to obtain the theoretical angle coordinates.
[0098] Optionally, the image recognition module 620 is specifically configured to:
[0099] If it is identified that there are calibration points in the scene image that cannot be matched to feature points, a scene switching event is determined to be triggered.
[0100] Optionally, after the actual angle coordinates of the position of each target calibration point are determined, the method further comprises:
[0101] Switching the angle of the camera to obtain a captured scene switching image.
[0102] identifying a matching result of the calibration points in the scene switching image pair that cannot be matched to the feature points;
[0103] if the matching result covers all the calibration points, terminating the switching;
[0104] if the matching result does not cover all the calibration points, continuing the switching until a termination condition is met.
[0105] Optionally, the coordinate establishing module 640 comprises:
[0106] a theoretical angle coordinate determining unit configured to obtain actual angle coordinates of each pixel point in the scene image by using an interpolation method, and determine theoretical angle coordinates of each pixel point;
[0107] a coefficient determining unit configured to determine distortion coefficients of each pixel point in the to-be-detected focal length range according to the actual angle coordinates of each pixel point and the theoretical angle coordinates of each pixel point.
[0108] Optionally, the coefficient determining unit is specifically configured to:
[0109] read parameter information of the camera to determine all focal length ranges supported by the camera;
[0110] traverse all the focal length ranges of the camera to obtain distortion coefficients of all the pixel points in each focal length range.
[0111] Optionally, the termination condition comprises: terminating when a limited number of switching times is reached, or terminating when all the calibration points are covered.
[0112] Optionally, the distortion coefficient is a ratio of a difference between the actual angle coordinates and the theoretical angle coordinates of each pixel point reaching a center position of the image to the theoretical angle coordinates.
[0113] The product can execute the construction method of the target format data request body provided in the embodiments of the application, and has the corresponding functional modules and beneficial effects of the execution method.
[0114] Embodiment Four
[0115] Embodiment Four of the application provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the automatic detection method of camera distortion provided in all the embodiments of the application:
[0116] fixing the camera at a to-be-detected focal length range, obtaining a scene image, and determining calibration points of the image according to a preset rule; wherein theoretical angle coordinates of the calibration points are known;
[0117] identifying calibration points in the scene image that can be matched to the feature points as target calibration points;
[0118] An angle value of the original position of the center position of the scene image is acquired, and the camera is controlled to rotate so that the center position moves from the original position to the position of each target calibration point, and an angle value of the position of each target calibration point is recorded;
[0119] A coordinate system is constructed with the original position as the coordinate system origin, and actual angle coordinates of the positions of the target calibration points are determined according to the difference between the angle value of the position of each target calibration point and the angle value of the original position.
[0120] According to the actual angle coordinates of the positions of the target calibration points in the to-be-detected focal length section and the theoretical angle coordinates of the target calibration points, distortion coefficients of the target calibration points are determined.
[0121] Any combination of one or more computer readable medium can be employed. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, the computer readable storage medium can be any tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0122] A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport program for use by or in connection with an instruction execution system, apparatus, or device.
[0123] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0124] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0125] Embodiment five
[0126] An electronic device is provided in the embodiment five of the present application. Figure 7 is a structural schematic diagram of an electronic device provided in the embodiment five of the present application. As shown in the figure, Figure 7 the embodiment provides an electronic device 700, which includes one or more processors 720, and a storage device 710 configured to store one or more programs, when the one or more programs are executed by the one or more processors 720, the one or more processors 720 implement the method for automatically detecting camera distortion provided in the embodiments of the present application, the method includes:
[0127] fixing the camera at a focal section to be detected, acquiring a scene image, and determining a calibration point of the image according to a preset rule; wherein a theoretical angle coordinate of the calibration point is known;
[0128] identifying the calibration point in the scene image that can be matched to the feature point as a target calibration point;
[0129] acquiring an angle value of an original position of a center position of the scene image, and controlling the camera to rotate, so that the center position moves from the original position to a position of each target calibration point, and recording an angle value of the position of each target calibration point;
[0130] constructing a coordinate system with the original position as an original point of the coordinate system, and determining an actual angle coordinate of the position of each target calibration point according to a difference between the angle value of the position of each target calibration point and the angle value of the original position;
[0131] determining a distortion coefficient of each target calibration point according to the actual angle coordinate of the position of each target calibration point in the focal section to be detected and the theoretical angle coordinate of each target calibration point.
[0132] Of course, those skilled in the art can understand that the processor 720 also implements the technical solutions of the automatic detection method of the camera distortion provided by any embodiment of the present application.
[0133] Figure 7 The electronic device 700 shown is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0134] As Figure 7 shown, the electronic device 700 includes a processor 720, a storage device 710, an input device 730, and an output device 740; the number of processors 720 in the electronic device can be one or more, Figure 7 of which the processor 720 is taken as an example; the processor 720, the storage device 710, the input device 730, and the output device 740 in the electronic device can be connected through a bus or other means, Figure 7 of which the connection through the bus 750 is taken as an example.
[0135] The storage device 710, as a kind of computer readable storage medium, can be used to store software programs, computer executable programs, and module units, such as the program instructions corresponding to the automatic detection method of the camera distortion in the embodiments of the present application.
[0136] The storage device 710 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; the data storage area can store data created according to the use of the terminal, etc. In addition, the storage device 710 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some examples, the storage device 710 can further include a memory disposed remotely with respect to the processor 720, and these remote memories can be connected through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0137] The input device 730 can be used to receive input digital, character information or voice information, and generate key signal input related to user settings and function control of the electronic device. The output device 740 can include a display screen, a speaker, and other electronic devices.
[0138] The electronic device provided by the embodiments of the present application can measure the image distortion condition through the coordinate difference between different image feature points and the center point, solve the problem of tedious and heavy workload of gimbal zoom camera distortion test, and provide a scheme of automatically detecting distortion coefficient and correction.
[0139] The camera distortion automatic detection device, medium and electronic equipment provided in the above embodiments can execute the camera distortion automatic detection method provided in any of the embodiments of the present application, and have corresponding function modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be referred to the camera distortion automatic detection method provided in any of the embodiments of the present application.
[0140] It should be noted that the above are only preferred embodiments of the present application and the technical principles applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and those skilled in the art can make various obvious changes, readjustments and substitutions without departing from the scope of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. An automatic detection method for camera distortion, characterized in that, The method includes: The camera is fixed at the focal length to be tested, the scene image is acquired, and the calibration point of the image is determined according to a preset rule; wherein, the theoretical angular coordinates of the calibration point are known. Identify the calibration points in the scene image that can match feature points as target calibration points; The angle value of the original position of the center position of the scene image is obtained, and the camera is controlled to rotate so that the center position moves from the original position to the position of each of the target calibration points, and the angle value of the position of each of the target calibration points is recorded; wherein, the angle value of the original position is the angle formed by the camera position and the original position of the center position of the scene image when the camera acquires the scene image; the angle value of the position of the target calibration point is the angle value when the center point of the camera image coincides with each image feature point of the real object point in the real scene; A coordinate system is constructed with the original position as the origin, and the actual angular coordinates of each target calibration point are determined based on the difference between the angle value of the position of each target calibration point and the angle value of the original position. The distortion coefficient of each target calibration point is determined based on the actual angular coordinates of the positions of each target calibration point in the focal length to be tested and the theoretical angular coordinates of each target calibration point. The process of acquiring scene images and determining calibration points for the images according to preset rules includes: Acquire a scene image, and determine the vertex position of each grid in the scene image as the calibration point of the image according to the preset number of grids; determine the angular coordinates of the pixel position of each calibration point in the scene image according to the number of grids and the size information of the grids, so as to obtain the theoretical angular coordinates; Determining the actual angular coordinates of each target calibration point based on the difference between the angular value of the target calibration point's position and the angular value of the original position includes: For each target calibration point, subtract the horizontal angle value of its position from the horizontal angle value of the original position to obtain the actual horizontal angle coordinates of the target calibration point; subtract the vertical angle value of its position from the vertical angle value of the original position to obtain the actual vertical angle coordinates of the target calibration point.
2. The method according to claim 1, characterized in that, After determining the actual angular coordinates of the positions of each of the target calibration points, the method further includes: The actual angular coordinates of each pixel in the scene image are obtained by interpolation, and the theoretical angular coordinates of each pixel are determined. Based on the actual angular coordinates of each pixel and the theoretical angular coordinates of each pixel, the distortion coefficient of each pixel in the focal length to be detected is determined.
3. The method according to claim 2, characterized in that, After determining the distortion coefficients of each pixel in the focal length to be detected, the method further includes: Read the parameter information of the camera to determine all focal lengths supported by the camera; By iterating through all focal lengths of the camera, the distortion coefficients of all pixels in each focal length are obtained.
4. The method according to claim 1, characterized in that, After identifying calibration points in the scene image that can be matched with feature points as target calibration points, the method further includes: If a calibration point that cannot be matched with a feature point is identified in the scene image, a scene switching event is triggered. After determining the actual angular coordinates of the positions of each of the target calibration points, the method further includes: Switch the camera angle to obtain a scene switching image; Identify the matching results of calibration points that cannot be matched with feature points in the scene switching image; If the matching result covers all calibration points, then the switching is terminated; If the matching result does not cover all calibration points, continue switching until the termination condition is met.
5. The method according to claim 4, characterized in that, The termination conditions include: termination when the limit number of switching is reached, or termination when all calibration points are covered.
6. The method according to any one of claims 1-5, characterized in that, The distortion coefficient is the ratio of the difference between the actual angular coordinates and the theoretical angular coordinates of each pixel at the center of the image to the theoretical angular coordinates.
7. An automatic detection device for camera distortion, characterized in that, The device includes: The image acquisition module is used to fix the camera at the focal length to be detected, acquire scene images, and determine the calibration points of the images according to preset rules; wherein, the theoretical angular coordinates of the calibration points are known; The image recognition module is used to identify calibration points in the scene image that can be matched with feature points as target calibration points; An angle acquisition module is used to acquire the angle value of the original position of the center position of the scene image, and control the camera to rotate so that the center position moves from the original position to the position of each of the target calibration points, and record the angle value of the position of each of the target calibration points; wherein, the angle value of the original position is the angle formed by the camera position and the original position of the center position of the scene image when the camera acquires the scene image; the angle value of the position of the target calibration point is the angle value when the center point of the camera image coincides with each image feature point of the real object point in the real scene; a coordinate establishment module is used to construct a coordinate system with the original position as the origin of the coordinate system, and determine the actual angular coordinates of the position of each of the target calibration points based on the difference between the angle value of the position of each of the target calibration points and the angle value of the original position; The coefficient determination module is used to determine the distortion coefficient of each target calibration point based on the actual angular coordinates of the position of each target calibration point in the focal length to be tested and the theoretical angular coordinates of each target calibration point. The image acquisition module includes: A calibration point determination unit is used to acquire scene images and determine the vertex positions of each grid in the scene image as calibration points according to a pre-set number of grids. A theoretical angle coordinate unit is used to determine the angle coordinates of the pixel position of each calibration point in the scene image based on the number of squares and the size information of the squares, so as to obtain the theoretical angle coordinates. The coefficient determination module is specifically used to, for each target calibration point, subtract the horizontal angle value of its position from the horizontal angle value of the original position to obtain the actual horizontal angle coordinates of the target calibration point; and subtract the vertical angle value of its position from the vertical angle value of the original position to obtain the actual vertical angle coordinates of the target calibration point.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the automatic detection method for camera distortion as described in any one of claims 1-6.
9. An electronic 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 computer program, it implements the automatic detection method for camera distortion as described in any one of claims 1-6.
Citation Information
Patent Citations
Correction method and device of image distortion, electronic equipment and storage medium
CN108932698A
Optical axis offset compensation method and device
CN110858872A