CN114708164B - Method for correcting image large and small head distortion caused by object inclination in machine vision measurement - Google Patents
Method for correcting image large and small head distortion caused by object inclination in machine vision measurement Download PDFInfo
- Publication number
- CN114708164B CN114708164B CN202210366766.6A CN202210366766A CN114708164B CN 114708164 B CN114708164 B CN 114708164B CN 202210366766 A CN202210366766 A CN 202210366766A CN 114708164 B CN114708164 B CN 114708164B
- Authority
- CN
- China
- Prior art keywords
- image
- calibration
- camera
- point
- images
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000005259 measurement Methods 0.000 title claims abstract description 45
- 238000000034 method Methods 0.000 title claims abstract description 41
- 238000012937 correction Methods 0.000 claims abstract description 42
- 239000011159 matrix material Substances 0.000 claims abstract description 17
- 238000012216 screening Methods 0.000 claims abstract description 17
- 238000004519 manufacturing process Methods 0.000 claims abstract description 11
- 230000009977 dual effect Effects 0.000 claims description 26
- 238000003384 imaging method Methods 0.000 claims description 10
- 230000001502 supplementing effect Effects 0.000 claims description 7
- 230000000007 visual effect Effects 0.000 claims description 7
- 238000004364 calculation method Methods 0.000 claims description 5
- 238000010586 diagram Methods 0.000 claims description 4
- DMSMPAJRVJJAGA-UHFFFAOYSA-N benzo[d]isothiazol-3-one Chemical compound C1=CC=C2C(=O)NSC2=C1 DMSMPAJRVJJAGA-UHFFFAOYSA-N 0.000 claims description 3
- 238000005516 engineering process Methods 0.000 abstract description 4
- 230000006870 function Effects 0.000 description 20
- 230000000694 effects Effects 0.000 description 7
- 238000005457 optimization Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 5
- 238000003491 array Methods 0.000 description 3
- 230000035945 sensitivity Effects 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000000691 measurement method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000005693 optoelectronics Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/80—Geometric correction
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/80—Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Length Measuring Devices By Optical Means (AREA)
Abstract
The invention relates to a machine vision measurement technology, and particularly discloses a method for correcting image large and small head distortion caused by object inclination in machine vision measurement. The method comprises the following steps: step 1, building a work table and manufacturing a calibration plate; step 2, collecting black and white checkerboard calibration images; step 3, screening the checkerboard calibration images; step 4, calculating internal and external parameters of the camera; step 5, collecting the circular dot matrix calibration plate image and calculating the coordinates of the circular dots; step 6, dividing the circular lattice calibration plate into a far camera part and a near camera part; step 7, calculating the inclined axis of the object; step 8, deducing a correction point expression of the projection point of the far and near camera; step 9, calculating the inclination angle of the object; and step 10, correcting the large and small head images. The distortion parameters can be solved quickly and accurately, and then the distortion of the large head and the small head can be corrected, so that the vision measurement precision can be improved.
Description
1. Field of the invention
The invention relates to a machine vision measurement technology, in particular to a method for correcting distortion of a large head and a small head of an image caused by object inclination in machine vision measurement.
2. Background of the invention
The machine vision measurement technology opens up a new way for solving the problems of automation, flexibility and on-line measurement. The method is a non-contact measurement method integrating technologies such as optoelectronics, computer graphics, information processing and the like, and has the advantages of flexibility, economy, convenience in computer analysis and processing of measurement results and the like. The disadvantages of visual measurement are also evident: the image shot by the camera is not an ideal image under a perspective model, and an optical distortion error exists between the actual imaging of the object point on the imaging medium of the camera and the ideal image. Thus, radial distortion, tangential distortion and thin prism distortion (camera distortion for short) exist; the study and correction of the image distortion achieve good study and correction effects. In video measurement, the distortion of the big head and the small head of an image (called as big head and small head distortion) caused by the nonparallel of a shooting object and a camera (called as object inclination for short) also exists, and the distortion is very common.
For various distortions in machine video measurement, generally ignoring large and small head distortion, singly processing the camera distortion by using a Zhang Yong calibration algorithm (the algorithm assumes that an object is parallel to a camera and the large and small head distortion does not exist); or combining the camera distortion and the large and small head distortion to establish a model, and solving four camera distortion parameters and three large and small head distortion parameters by using a Levenberg-Marquardt optimization algorithm. The disadvantages of this method are: neglecting the distortion of the large and small heads is a defect per se; (2) The combined processing parameters are more, and the search time and space cost is higher; (3) The Levenberg-Marquardt optimization algorithm has stronger sensitivity to the initial value, and distortion parameters are easy to be locally optimal solutions. These disadvantages greatly weaken the reliability of distortion parameters and the correction effect is not good, thereby seriously affecting the measurement accuracy.
Because of the universality of the large and small head distortion of vision measurement and the difficult acquirement of the correction parameters, the method which is convenient to use, high in the reliability of the correction parameters and good in correction effect has important significance.
3. Summary of the invention
The invention aims to provide a method for correcting the distortion of the big and small heads of an image caused by the inclination of an object in machine vision measurement, which is used for quickly and accurately solving distortion parameters and then correcting the distortion of the big and small heads, thereby increasing the precision of vision measurement.
The invention is realized by the following technical scheme: the method for correcting the image large and small head distortion caused by the object inclination in the machine vision measurement comprises the following steps: step 1: building a visual measurement working table and a calibration plate, building the measurement working table according to the size of a visual measurement object, and manufacturing a black-white chessboard calibration plate and a circular dot matrix calibration plate after building is completed; step 2: collecting checkerboard calibration images, and collecting calibration images at different positions in the field of view of the camera; and step 3: screening the checkerboard calibration images, screening the checkerboard calibration images in an OpenCV open source calibration program, and supplementing the screened calibration images; and 4, step 4: calculating the internal parameters of the camera, and calculating the internal parameters of the camera by using the screened checkerboard calibration images; and 5: collecting circular dot matrix calibration plate images and calculating coordinates of circular points; step 6: dividing the circular dot matrix calibration plate into a far camera part and a near camera part, and dividing a circular dot matrix calibration graph according to the distance from the dual projection circular point to the central point; and 7: calculating a tilt axis of the object; and 8: deducing a correction point expression of a projection point of the far and near camera; and step 9: calculating the inclination angle of the object; step 10: and correcting the large and small head images. It should be noted that, for various distortions in the machine video measurement, the camera distortion is generally handled separately by a Zhang Yong calibration algorithm (the algorithm assumes that the object is parallel to the camera and there is no distortion of the big head and the small head); or combining the camera distortion and the large and small head distortion to establish a model, and solving four camera distortion parameters and three large and small head distortion parameters by using a Levenberg-Marquardt optimization algorithm. The disadvantages of this method are: (1) The theoretical basis of the distortion of the large head and the small head is not sufficient by using a Zhang Yong calibration algorithm; (2) The combined processing parameters are more, and the search time and space cost is higher; (3) The Levenberg-Marquardt optimization algorithm has strong sensitivity to the initial value, and distortion parameters are easy to be locally optimal solutions. These disadvantages greatly weaken the reliability of distortion parameters and the correction effect is not good, thereby seriously affecting the measurement accuracy.
In view of the above problems, the applicant proposes a method for correcting the distortion of the large and small heads of an image caused by the inclination of an object in the machine vision measurement. Solving the correction parameters of the distorted images of the big and small heads is a brand new method, and the internal parameters of the camera and the distorted correction parameters of the big and small heads are solved step by step: and solving the internal parameters of the camera by applying a Zhang Zhen you camera calibration method, and applying the internal parameters to the solving of the distortion correction parameters of the big and small heads. The image is divided into a near camera projection part and a far camera projection part according to the tilt axis of the object, and the boundary is solved using the position coordinates of the dividing point. And establishing a parameter equation of the inclination angle of the object according to the perspective projection principle and the equal distance between the corrected point of the dual projection point and the principal point, and determining the inclination angle of the object by applying an angle when the absolute value of the distance difference between the corrected point of the dual projection point and the principal point reaches the minimum. The time and space complexity of the correction parameter solution is very low, and the correction effect of the distorted image is improved, so that the precision of vision measurement is improved.
Further, step 2 specifically includes: collecting at least 3 images of black and white chessboard lattice calibration plates at different positions on a work table, placing a circular lattice calibration plate on the work table, aligning the central point of the circular lattice calibration plate to the center of a camera, leveling the point array calibration plate, and collecting circular lattice calibration images. The step 3 specifically comprises: and screening and supplementing images, namely screening the images of the black and white checkerboard calibration board according to a calibration algorithm, wherein the screening condition is that an angle point diagram appears, and if the number of the images meeting the condition is less than 16, the calibration board needs to be supplemented. When the image is supplemented, the light intensity and the inclination direction of the calibration point can be adjusted. It should be noted that the calibration plate is manufactured by: (1) manufacturing a Zhangyingyou camera calibration plate: 9 × 10 square black and white alternated calibration plates with side length of 10 cm; (2) The method comprises the steps of manufacturing a round dot array calibration plate which is 1.5 meters long and 1 meter wide, is engraved with 19 rows and 25 columns of 475 circular dot arrays with the radius of 1 millimeter and the interval between two vertically and horizontally adjacent dots of 5 centimeters, and the specification of the round dot array calibration plate may change according to the distance between a work table and a camera, so that the dot arrays are required to be ensured to be paved in the field of vision of the camera as much as possible.
Further, step 4 specifically includes: inputting the checkerboard calibration image into the open source function by using the open source function calibration camera, and outputting the checkerboard calibration image as the principal point coordinate (u) of the camera 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes. It should be noted that the open source function calibration camera of the OpenCV string friend calibration algorithm is called by using the C + + language in VS 2013. Inputting the image of the black and white chessboard grid calibration plate into an open source function, and calculating the principal point coordinate (u) of the camera 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes.
Further, step 7 specifically includes: determining boundary points of projection points of two near-far cameras in each line according to different types of points in each line, fitting the sample points by using the midpoints of the boundary points as sample points by using a least square method to obtain the slope of the inclined axis of the camera on the imaging medium planeWherein (u) i ,v i ) Representing the coordinates of the middle points of two demarcation points per line, n represents the number of lines of the circular lattice calibration plate, the over-principal point (u) 0 ,v 0 ) The equation for the tilt axis of (c) is: v = ku + v 0 -ku 0 . The distances from the two dual points to the central point are unequal, the point with the large distance is a far camera projection point, and the point with the large distance is a near camera projection point. All the far camera projection points and the near camera projection points constitute a far camera part and a near camera part, respectively, and their boundary lines are the inclined axes of the object. And determining the boundary point of the two far and near camera projection points of each line according to the different types of the points in each line, taking the center point as a sample point, and fitting the sample point by using a least square method to obtain the slope k of the inclined axis of the object on the XY plane.
Further, step 9 specifically includes: solving for expressionsFirst derivative function equationThe value of theta can be obtained; due to the fact that N The individual derivative functions cannot be simply summed and are difficult to directly solve; and searching the root of the derivative function equation by using a dichotomy method when the given iteration number or the absolute value of the difference of the derivative values of two adjacent times is smaller than a given threshold value so as to obtain the inclination angle of the object. For tilt angles, the object tilt axis divides the image into two parts, a near camera projection and a far camera projection; according to the perspective projection principle, a near camera projection point in dual projection points is corrected to an imaging medium, then a far camera projection point is also corrected to the imaging medium, and the distances between the two points and a main point are equal theoretically. In practice not all correction points fulfill this condition. In order to obtain the inclination angle, the inclination angle of the object is determined by the angle at which the absolute value of the differences between the correction points of all the dual projection points and the principal point is minimized. After the iteration times are given, solving a derivative function equation by a dichotomy to obtain the object inclination angle theta.
Further, step 10 specifically includes: using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) The focal length f, the actual distances alpha and beta between the pixels on the X axis and the Y axis, the inclined axis k of the object in the XY plane, the inclined angle theta of the object in the Z axis direction and other parameters, and reversely solving the correction point for each pixel point in the large and small head images; in finding the object tilt axis l: after v = ku + b and the inclination angle theta, dividing the distorted image into near-camera projection parts by the inclination axis π1 Sum-distance camera projection part pi 2 (ii) a Taking the distorted image point A 0 (u 0 ,v 0 ) Obtaining the distance r from the ideal point A (u, v) to the center of the image; if A is 0 (u 0 ,v 0 )∈π 1 Then, thenIf A is 0 (u 0 ,v 0 )∈π 2 Then, thenIf A is 0 (u 0 ,v 0 )∈l,r=r 0 Rotating the image clockwise by an atan (k) angle around the center of the image so that the tilt axis coincides with U; byAnd relation ofFinding the coordinates of the ideal point asIf A is 0 (u 0 ,v 0 ) E.g., l, then u = u 0 V =0; whereinRotating atan (k) the ideal point counterclockwise around the image center yields the ideal image.
Compared with the prior art, the invention has the following advantages and beneficial effects:
1. the invention mainly corrects the big and small head images in the video measurement, has fewer and definite calculation parameters and has smaller time and space complexity; and when the shooting environment is not changed, the inclination correction parameters do not need to be repeatedly calculated. The time cost for correcting the image is reduced by 95 percent;
2. the method is based on the industrial machine vision measurement, calibrates the internal and external parameters of the camera and the tilt parameters of the object, searches the edge and corner points of the object by a Canny operator, and calculates the actual size of the object. After the inclination correction, the length difference between the upper side and the lower side of the rectangle is changed from the original 11.88 pixels to the corrected 6.1333 pixels, and the phenomenon of large and small heads of the image is obviously corrected;
3. taking the correction of the dot matrix calibration board image as an example, the absolute value of the distance difference is statistically analyzed, the average value of the absolute values of the distance differences from the dual projection points to the dot matrix center is 1.79761 pixels, and the variance is 2.02377; the corrected average value is 0.31558 pixel, the variance is 0.0693318, the corrected difference is shortened to 17.6% of the difference before correction, and the variance is very small, further explaining that the distance difference after correction is kept less than 0.35 pixel, the distortion parameter can be rapidly and accurately solved, and then the distortion of the large head and the small head is corrected, so that the vision measurement precision is increased;
4. the distortion degree of the distorted image before the object tilt correction is 2.5638 pixels, and the distortion degree of the ideal image is 0.3754 pixels.
4. Description of the drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention. In the drawings:
FIG. 1 is a flow chart of the system of the present invention.
5. Detailed description of the preferred embodiments
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to examples and accompanying drawings, and the exemplary embodiments and descriptions thereof are only used for explaining the present invention and are not meant to limit the present invention. It should be noted that the present invention is in practical development and use.
The embodiment is as follows:
as shown in FIG. 1, the method for correcting the image capitalization and capitalization distortion caused by the object inclination in the machine vision measurement comprises the following steps:
step 1: building a visual measurement working table and manufacturing a calibration plate, building the measurement working table according to the size of a visual measurement object, and manufacturing a black-white chessboard calibration plate and a circular dot matrix calibration plate after building is completed; step 2: collecting checkerboard calibration images, and collecting calibration images at different positions in the field of view of the camera; and step 3: screening a chessboard pattern calibration image, screening the chessboard pattern calibration image in an OpenCV open source calibration program, and supplementing the screened calibration image; and 4, step 4: calculating the internal parameters of the camera, and calculating the internal parameters of the camera by using the screened checkerboard calibration images; and 5: collecting circular dot matrix calibration plate images and calculating coordinates of circular points; step 6: dividing the circular lattice calibration plate into a far camera part and a near camera part, and dividing the circular lattice calibration image according to the distance from the dual projection circular point to the central point; and 7: calculating a tilt axis of the object; and 8: deducing distance and distanceA correction point expression of a camera projection point; and step 9: calculating the inclination angle of the object; step 10: and correcting the large and small head images. The step 2 specifically comprises the following steps: collecting at least 3 images of black and white chessboard calibration plates at different positions on a work table, placing a circular dot matrix calibration plate on the work table, aligning the center point of the circular dot matrix calibration plate to the center of a camera, leveling the dot matrix calibration plate, and collecting circular dot matrix calibration images. The step 3 specifically comprises the following steps: and screening and supplementing images, namely screening the images of the black and white checkerboard calibration board according to a calibration algorithm, wherein the screening condition is that an angle point diagram appears, and if the number of the images meeting the condition is less than 16, the calibration board needs to be supplemented. When the image is supplemented, the light intensity and the inclination direction of the calibration point can be adjusted. The step 4 specifically comprises the following steps: inputting the checkerboard calibration image into the open source function by using the open source function calibration camera, and outputting the checkerboard calibration image as the principal point coordinate (u) of the camera 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes. The step 7 specifically comprises the following steps: determining the demarcation points of the projection points of the two far and near cameras in each line according to different types of the points in each line, fitting the sample points by using the midpoints of the demarcation points as sample points and using a least square method to obtain the slope of the inclined axis of the camera on the imaging medium planeWherein (u) i ,v i ) Representing the coordinates of the middle points of two demarcation points per line, n represents the number of lines of the circular lattice calibration plate, the over-principal point (u) 0 ,v 0 ) The equation for the tilt axis of (c) is: v = ku + v 0 -ku 0 . Step 8, specifically comprising: using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) Focal length f, actual distances alpha and beta between pixels on an X axis and a Y axis, an inclined axis k of an object in an XY plane, an inclined angle theta of the object in a Z axis direction and other parameters; setting dual projection point B on distorted image 2 (v 1 ,u 1 ) And D 2 (v 2 ,u 2 ) Distances to the center of the distorted image are r 1 And r 2 ,β 1 And beta 2 The angle, beta, formed by the two projection lines and the image plane 1 =∠OB 2 D 2 ,β 2 =∠OD 2 B 2 ,η 1 And η 2 Are respectively r 1 And r 2 On the ideal image; angle, η, formed by the orthographic projection and the distorted image 1 =∠B 3 O 2 B 2 ,η 2 =∠D 3 O 2 D 2 (ii) a Let | O 2 B 3 |=r l1 ,|O 2 D 3 L = rl2, r is obtained by perspective projection principle and triangle geometry relation l1 And r l2 The following relationship is satisfied:a point array image having N pairs of even proxels; assuming that the inclination angle of the object is θ, θ is calculated so as to satisfy:wherein r is li1 And r li2 Respectively representing the distance of the ideal dual proxels to the center of the image,(i =1, 2.., N, j =1, 2). The step 9 specifically comprises: first derivative function equation for solving expressionThe value of theta can be obtained; because N derivative functions can not be simply summed, the direct solution is difficult; and searching the root of the derivative function equation by using a dichotomy method when the given iteration number or the absolute value of the difference of the derivative values of two adjacent times is smaller than a given threshold value so as to obtain the inclination angle of the object. The step 10 specifically comprises: using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) The focal length f, the actual distances alpha and beta between the pixels on the X axis and the Y axis, the inclined axis k of the object in the XY plane, the inclined angle theta of the object in the Z axis direction and other parameters, and reversely solving the correction point for each pixel point in the large and small head images; in finding the object tilt axis l: after v = ku + b and the inclination angle theta, dividing the distorted image into near-camera projection parts pi by using the inclination axis 1 Sum-distance camera projection part pi 2 (ii) a Taking a distorted image point A 0 (u 0 ,v 0 ) The corresponding ideal image point A (u, v) obtains the idealThe distance r of point a (u, v) to the center of the image; if A is 0 (u 0 ,v 0 )∈π 1 Then, thenIf A is 0 (u 0 ,v 0 )∈π 2 Then, thenIf A is 0 (u 0 ,v 0 )∈l,r=r 0 . Rotating the image clockwise around the image center by an atan (k) angle such that the tilt axis coincides with U; byAnd relational expressionFinding the coordinates of the ideal point as If A is 0 (u 0 ,v 0 ) E.g., l, then u = u 0 V =0; wherein Rotating the ideal point atan (k) counterclockwise around the image center yields the ideal image.
It should be noted that, for various distortions in the machine video measurement, the distortion of the large and small heads is generally ignored, and the distortion of the camera is separately processed by using a Zhang Yongyou calibration algorithm (the algorithm assumes that the object is parallel to the camera, and the distortion of the large and small heads does not exist); or combining the camera distortion and the large and small head distortion to establish a model, and solving four camera distortion parameters and three large and small head distortion parameters by using a Levenberg-Marquardt optimization algorithm. The disadvantages of this method are: neglecting the distortion of the large and small heads is a defect per se; (2) The combined processing parameters are more, and the search time and space cost is higher; (3) The Levenberg-Marquardt optimization algorithm has stronger sensitivity to the initial value, and distortion parameters are easy to be locally optimal solutions. These disadvantages greatly weaken the reliability of distortion parameters and the correction effect is not good, thereby seriously affecting the measurement accuracy. In view of the above problems, the applicant proposes a method for correcting the distortion of the large and small heads of an image caused by the inclination of an object in the machine vision measurement. Solving the correction parameters of the large and small head distortion images is a brand new method, and the internal parameters and the large and small head distortion correction parameters of the camera are solved step by step: and solving the internal parameters of the camera by applying a Zhang Zhen you camera calibration method, and applying the internal parameters to the solving of the distortion correction parameters of the big and small heads. The image is divided into a near camera projection part and a far camera projection part according to the tilt axis of the object, and the boundary is solved using the position coordinates of the dividing point. And establishing a parameter equation of the inclination angle of the object according to the perspective projection principle and the equal distance between the point corrected by the dual projection point and the principal point, wherein the inclination angle of the object is determined by applying the angle when the absolute value of the difference between the distances from the correction points of all the dual projection points to the principal point is the minimum. The time and space complexity of the correction parameter solution is very low, and the correction effect of the distorted image is improved, so that the precision of vision measurement is improved.
It should be further noted that the manufactured calibration plate is: (1) manufacturing a Zhangyingyou camera calibration board: 9 × 10 square black and white alternated calibration plates with side length of 10 cm; (2) The method is characterized in that a round dot array calibration plate which is 1.5 meters long and 1 meter wide and is engraved with 19 rows and 25 columns, 475 circular dots with the radius of 1 millimeter and 5 centimeters between two adjacent vertical and horizontal dots is manufactured, the specification of the round dot array calibration plate possibly changes according to the distance between a work table and a camera, and the dot array is required to be ensured to be paved in the field of view of the camera as much as possible. And calling an open source function calibration camera of a Zhang friend calibration algorithm in OpenCV by using a C + + language in VS 2013. Inputting black and white Zhangzhen scaling board image into open source function, and outputting principal point coordinate (u) of camera by calculation 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes. Determining dual projection points according to the position relation of the points in the point array, and calculating the dual projection pointsTheir distance from the center point of the array of points. The distances from the two dual points to the central point are unequal, points with large distances are far camera projection points, and points with large distances from the central point are near camera projection points. All the far camera projection points and the near camera projection points constitute a far camera part and a near camera part, respectively, and their boundary lines are the inclined axes of the object. And determining the boundary point of the two far and near camera projection points of each line according to the different types of the points in each line, taking the center point as a sample point, and fitting the sample point by using a least square method to obtain the slope k of the inclined axis of the object on the XY plane. It should also be noted that, for the tilt angle, the object tilt axis divides the image into two parts, a near camera projection and a far camera projection; according to the perspective projection principle, a near camera projection point in dual projection points is corrected to an imaging medium, then a far camera projection point is also corrected to the imaging medium, and the distances between the two points and a principal point are equal theoretically. In practice not all correction points fulfill this condition. In order to obtain the inclination angle, the inclination angle of the object is determined by the angle at which the absolute value of the differences between the correction points of all the dual projection points and the principal point is minimized. After the iteration times are given, solving a derivative function equation by a dichotomy to obtain the object inclination angle theta.
The method comprises the following steps: and (5) building a measuring work table. According to the size of an object to be measured visually, a measuring work table needs to be built, and the work table is as flat as possible; a cross bar for placing the camera is erected on the workbench. In order to reduce measurement errors, when the work table and the camera are fixed, the work table is ensured to be horizontal as much as possible, and a camera lens is parallel to the work table. And (5) manufacturing a calibration plate. (1) manufacturing a Zhangyingyou camera calibration board: 9 x 10 square black and white alternated calibration plates with side length of 10 cm; (2) A circular dot array calibration plate (the specification of the circular dot array calibration plate may be changed according to the distance between a work table and a camera) is manufactured, wherein the circular dot array calibration plate is 1.5 meters long and 1 meter wide, 19 rows and 25 columns of 475 circular dot arrays are engraved, the radius of the circular dot array calibration plate is 1 millimeter, and the distance between adjacent dots is 5 centimeters. And collecting a calibration image. (1) Collecting at least 9 black and white calibration plate images at different positions on a workbench according to the requirements of a Zhang Zhengyou calibration method; (2) And (3) placing the circular dot matrix calibration plate on a work table, aligning the central point of the dot matrix calibration plate to the center of the camera, and collecting the image of the calibration plate. And screening the calibration image. By erecting friend signsThe image of the black and white calibration plate is screened by a calibration algorithm. In the camera calibration, a calibration chart in which an angle point diagram can appear is an image satisfying the condition. And supplementing the calibration image. In order to ensure the accuracy of camera calibration, less than 9 images meeting the condition need to be complemented by 9 images, generally no more than 16 images, and the images must come from different positions in the camera view; when a calibration image is shot, the light intensity and the inclination direction of the calibration plate can be adjusted to ensure that the image can be screened during calibration. The internal parameters of the camera are calculated. Calling an open source function of a Zhang Zhengyou calibration algorithm in OpenCV by using C + + language in VS2013, inputting Zhang Zhengyou calibration plate images with black and white intervals into the function, and outputting a principal point coordinate (u) of the camera through calculation 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes. The coordinates of the circular points are calculated. Binarizing the circular lattice calibration plate image, and assigning 1 to the pixel value of a black point or assigning 0 to other pixel values; clustering points with the pixel value of 1 in the image by using a moving window clustering algorithm, and clustering into classes according to the number of the points on the dot matrix calibration plate; the arithmetic mean of the coordinates of each point in the class is then used as the coordinates of the circular index point. The image is segmented into near and far camera portions. Determining the dual points (two points which are symmetrical by the central point) on the lattice board and the dual projection points (the points of the dual points on the lattice image), and calculating the distance from the dual projection points to the central point. The distances from the dual projection points to the central point are unequal, points with large distances are far camera projection points, and points with large distances from the central point are near camera projection points. All the far camera projection points and the near camera projection points constitute a far camera part and a near camera part, respectively, and their boundary lines are the inclined axes of the object. The axis of tilt of the object in the XY plane is calculated. And determining boundary points of the projection points of the far and near cameras according to different types of the projection points of each line, taking the middle point of the two boundary points as a sample point, and fitting the sample point by using a least square method to obtain the slope k of the object tilt axis on the XY plane. And calculating correction points of the projection points of the far and near cameras. After the far camera proxel and the near camera proxel are determined, they are both corrected to the imaging medium according to the perspective projection principle. The tilt angle of the object in the Z-axis is calculated. Theoretically, the two correction points are equidistant from the principal point. In fact, not all correction points satisfy this condition because the image has other distortions. In order to find the tilt angle, the angle at which the sum of the absolute values of the differences in distances from the correction points to the principal point (a function of the tilt angle θ of the object) of all the dual projection points is minimized is the tilt angle of the object. And after the iteration times are given, solving a derivative function equation by using a dichotomy to obtain the inclination angle theta of the object. And correcting the large and small head images. Using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) The focal length f, the actual distances alpha and beta between the pixels on the X axis and the Y axis, the inclined axis k of the object in the XY plane, the inclined angle theta of the object in the Z axis direction and other parameters, and each pixel point in the large and small head images is reversely solved to obtain a correction point, so that a corrected image of the large and small head images is obtained.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Claims (5)
1. The method for correcting the distortion of the big and small heads of an image caused by the inclination of an object in machine vision measurement is characterized in that: the method comprises the following steps:
step 1: building a visual measurement working table and manufacturing a calibration plate, building the measurement working table according to the size of a visual measurement object, and manufacturing a black-white chessboard calibration plate and a circular dot matrix calibration plate after building is completed;
step 2: collecting checkerboard calibration images, and collecting calibration images at different positions in the field of view of the camera;
and 3, step 3: screening the chessboard pattern calibration images, screening the chessboard pattern calibration images in an OpenCV open source calibration program, and supplementing the screened calibration images, specifically: screening and supplementing images, screening the images of the black and white checkerboard calibration board according to a calibration algorithm, wherein the screening condition is that an angle point diagram appears, and if the number of the images meeting the condition is less than 16, the calibration board needs to be supplemented;
and 4, step 4: calculating the internal parameters of the camera, and calculating the internal parameters of the camera by using the screened checkerboard calibration images;
and 5: collecting circular dot matrix calibration plate images and calculating coordinates of circular points;
step 6: dividing the circular lattice calibration plate into a far camera part and a near camera part, and dividing the circular lattice calibration image according to the distance from the dual projection circular point to the central point;
and 7: calculating the inclined axis of the object, wherein the specific calculation process comprises the following steps: determining boundary points of projection points of two near-far cameras in each line according to different types of points in each line, fitting the sample points by using the midpoints of the boundary points as sample points by using a least square method to obtain the slope of the inclined axis of the camera on the imaging medium planeWherein (u) i ,v i ) Representing the coordinates of the middle points of two demarcation points per line, n represents the number of lines of the circular lattice calibration plate, the over-principal point (u) 0 ,v 0 ) The equation for the tilt axis of (c) is: v = ku + v 0 -ku 0 ;
And 8: deducing a correction point expression of a projection point of a far and near camera, wherein the specific deduction process is as follows: using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) The focal length f, the actual distances alpha and beta between the pixels on the X axis and the Y axis, the inclined axis k of the object in the XY plane, the inclined angle theta of the object in the Z axis direction and other parameters, and reversely solving the correction point for each pixel point in the large and small head images; setting dual projection point B on distorted image 2 (v 1 ,u 1 ) And D 2 (v 2 ,u 2 ) Distances to the center of the distorted image are r 1 And r 2 ,β 1 And beta 2 Angle, β, formed by two projection lines and the image plane 1 =∠OB 2 D 2 ,β 2 =∠OD 2 B 2 ,η 1 And η 2 Are respectively r 1 And r 2 Angle, η, between orthographic projection on the ideal image and the distorted image 1 =∠B 3 O 2 B 2 ,η 2 =∠D 3 O 2 D 2 (ii) a Let | O 2 B 3 |=r l1 ,|O 2 D 3 |=r l2 R is obtained by perspective projection principle and triangle geometry relation l1 And r l2 The following relationship is satisfied:a point array image having N pairs of even proxels; assuming that the inclination angle of the object is θ, θ is calculated so as to satisfy:
wherein r is li1 And r li2 Respectively representing the distance of the ideal dual proxel from the center of the image,
and step 9: calculating the inclination angle of the object, wherein the specific calculation process is as follows: first derivative function equation for solving expressionThe value of theta can be obtained; searching the root of a derivative function equation by using a dichotomy to obtain an object inclination angle when the given iteration number or the absolute value of the difference of the derivative values of two adjacent times is smaller than a given threshold value;
step 10: and correcting the large and small head images.
2. The method for correcting image size and head distortion caused by object tilt in machine vision measurement as claimed in claim 1, wherein: the step 2 specifically comprises the following steps: collecting at least 3 images of black and white chessboard lattice calibration plates at different positions on a work table, placing a circular lattice calibration plate on the work table, aligning the central point of the circular lattice calibration plate to the center of a camera, leveling the point array calibration plate, and collecting circular lattice calibration images.
3. The method for correcting the distortion of the large and small image heads caused by the inclination of the object in the machine vision measurement as claimed in claim 1, wherein: when the image is supplemented, the light intensity and the inclination direction of the calibration point can be adjusted.
4. The method for correcting image size and head distortion caused by object tilt in machine vision measurement as claimed in claim 1, wherein: the step 4 specifically comprises the following steps: inputting the checkerboard calibration image into the open source function by using the open source function calibration camera, and outputting the checkerboard calibration image as the principal point coordinate (u) of the camera 0 ,v 0 ) Focal length f and the actual distances alpha and beta between the pixels on the X and Y axes.
5. The method for correcting image size and head distortion caused by object tilt in machine vision measurement as claimed in claim 1, wherein: the step 10 specifically comprises: using the coordinates (u) of the principal point of the camera's intrinsic parameters 0 ,v 0 ) The focal length f, the actual distances alpha and beta between the pixels on the X axis and the Y axis, the inclined axis k of the object in the XY plane, the inclined angle theta of the object in the Z axis direction and other parameters, and reversely solving the correction point of each pixel point in the large and small head images; in finding the object tilt axis l: after v = ku + b and the inclination angle theta, dividing the distorted image into near-camera projection parts pi by using the inclination axis 1 Sum-distance camera projection part pi 2 (ii) a Taking a distorted image point A 0 (u 0 ,v 0 ) Obtaining the distance r from the ideal point A (u, v) to the center of the image; if A is 0 (u 0 ,v 0 )∈π 1 Then, thenIf A is 0 (u 0 ,v 0 )∈π 2 Then, thenIf A is 0 (u 0 ,v 0 )∈l,r=r 0 Rotating the image clockwise by an atan (k) angle around the center of the image so that the tilt axis coincides with U; byAnd relational expressionFinding the coordinates of the ideal point as If A is 0 (u 0 ,v 0 ) E.g., l, then u = u 0 V =0; whereinAnd rotating the ideal point by alpha tan (k) around the center of the image in a counterclockwise direction to obtain an ideal image.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210366766.6A CN114708164B (en) | 2022-04-08 | 2022-04-08 | Method for correcting image large and small head distortion caused by object inclination in machine vision measurement |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210366766.6A CN114708164B (en) | 2022-04-08 | 2022-04-08 | Method for correcting image large and small head distortion caused by object inclination in machine vision measurement |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114708164A CN114708164A (en) | 2022-07-05 |
CN114708164B true CN114708164B (en) | 2022-10-28 |
Family
ID=82173308
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210366766.6A Active CN114708164B (en) | 2022-04-08 | 2022-04-08 | Method for correcting image large and small head distortion caused by object inclination in machine vision measurement |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114708164B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115306165A (en) * | 2022-08-25 | 2022-11-08 | 中国建筑第二工程局有限公司 | Assembly type prefabricated part mounting system |
CN116735167B (en) * | 2023-08-16 | 2023-10-13 | 深圳市灿锐科技有限公司 | Lens multiplying power and distortion detection method |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108876749A (en) * | 2018-07-02 | 2018-11-23 | 南京汇川工业视觉技术开发有限公司 | A kind of lens distortion calibration method of robust |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6202356B2 (en) * | 2012-07-02 | 2017-09-27 | 株式会社リコー | Image processing apparatus and method, and imaging apparatus |
CN110458898B (en) * | 2019-08-15 | 2022-03-22 | 北京迈格威科技有限公司 | Camera calibration board, calibration data acquisition method, distortion correction method and device |
CN112767497A (en) * | 2021-01-25 | 2021-05-07 | 深慧视(深圳)科技有限公司 | High-robustness calibration device based on circular calibration plate and positioning method |
-
2022
- 2022-04-08 CN CN202210366766.6A patent/CN114708164B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108876749A (en) * | 2018-07-02 | 2018-11-23 | 南京汇川工业视觉技术开发有限公司 | A kind of lens distortion calibration method of robust |
Also Published As
Publication number | Publication date |
---|---|
CN114708164A (en) | 2022-07-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114708164B (en) | Method for correcting image large and small head distortion caused by object inclination in machine vision measurement | |
CN114331924B (en) | Large workpiece multi-camera vision measurement method | |
CN111369630A (en) | Method for calibrating multi-line laser radar and camera | |
CN103530880B (en) | Based on the camera marking method of projection Gaussian network pattern | |
CN106780388B (en) | Optical distortion correction method for linear array camera | |
US7019713B2 (en) | Methods and measurement engine for aligning multi-projector display systems | |
CN109029299B (en) | Dual-camera measuring device and method for butt joint corner of cabin pin hole | |
CN112669393A (en) | Laser radar and camera combined calibration method | |
CN112802123B (en) | Binocular linear array camera static calibration method based on stripe virtual target | |
CN107339935B (en) | Target space intersection measuring method for full-view scanning measuring system | |
CN108716890A (en) | A kind of high-precision size detecting method based on machine vision | |
CN110455198B (en) | Rectangular spline shaft key width and diameter measuring method based on line structure light vision | |
WO2021017352A1 (en) | Laser radar-camera joint calibration target and joint calibration method | |
CN113610929B (en) | Combined calibration method of camera and multi-line laser | |
CN112132891A (en) | Method for enlarging calibration space | |
CN112037284A (en) | Checkerboard grid center point detection method, camera distortion calibration method and system | |
CN112082511A (en) | Large object rapid calibration and measurement method based on rotary table | |
CN109087360A (en) | A kind of scaling method that robot camera is joined outside | |
CN114998448A (en) | Method for calibrating multi-constraint binocular fisheye camera and positioning space point | |
CN108322736B (en) | Calibration plate and calibration method for calibrating rotation angles of multiple linear array cameras around visual axis | |
CN111968182B (en) | Calibration method for nonlinear model parameters of binocular camera | |
CN112179292A (en) | Projector-based line structured light vision sensor calibration method | |
CN115289997B (en) | Binocular camera three-dimensional contour scanner and application method thereof | |
CN113592962B (en) | Batch silicon wafer identification recognition method based on machine vision | |
CN111340891B (en) | Method and system for calibrating camera by using LED screen |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |