CN112102413B - An automatic calibration method for vehicle-mounted cameras based on virtual lane lines - Google Patents
An automatic calibration method for vehicle-mounted cameras based on virtual lane lines Download PDFInfo
- Publication number
- CN112102413B CN112102413B CN202010713419.7A CN202010713419A CN112102413B CN 112102413 B CN112102413 B CN 112102413B CN 202010713419 A CN202010713419 A CN 202010713419A CN 112102413 B CN112102413 B CN 112102413B
- Authority
- CN
- China
- Prior art keywords
- camera
- coordinate system
- coordinates
- formula
- matrix
- 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
- 238000000034 method Methods 0.000 title claims abstract description 38
- 239000011159 matrix material Substances 0.000 claims abstract description 59
- 230000009466 transformation Effects 0.000 claims abstract description 21
- 230000008569 process Effects 0.000 claims description 15
- PCTMTFRHKVHKIS-BMFZQQSSSA-N (1s,3r,4e,6e,8e,10e,12e,14e,16e,18s,19r,20r,21s,25r,27r,30r,31r,33s,35r,37s,38r)-3-[(2r,3s,4s,5s,6r)-4-amino-3,5-dihydroxy-6-methyloxan-2-yl]oxy-19,25,27,30,31,33,35,37-octahydroxy-18,20,21-trimethyl-23-oxo-22,39-dioxabicyclo[33.3.1]nonatriaconta-4,6,8,10 Chemical compound C1C=C2C[C@@H](OS(O)(=O)=O)CC[C@]2(C)[C@@H]2[C@@H]1[C@@H]1CC[C@H]([C@H](C)CCCC(C)C)[C@@]1(C)CC2.O[C@H]1[C@@H](N)[C@H](O)[C@@H](C)O[C@H]1O[C@H]1/C=C/C=C/C=C/C=C/C=C/C=C/C=C/[C@H](C)[C@@H](O)[C@@H](C)[C@H](C)OC(=O)C[C@H](O)C[C@H](O)CC[C@@H](O)[C@H](O)C[C@H](O)C[C@](O)(C[C@H](O)[C@H]2C(O)=O)O[C@H]2C1 PCTMTFRHKVHKIS-BMFZQQSSSA-N 0.000 claims description 3
- 238000004364 calculation method Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 6
- 230000008859 change Effects 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 5
- 238000003384 imaging method Methods 0.000 description 4
- 230000003068 static effect Effects 0.000 description 3
- 230000006872 improvement Effects 0.000 description 2
- 238000005259 measurement Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000004438 eyesight Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000012634 optical imaging Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
- 230000016776 visual perception Effects 0.000 description 1
Images
Classifications
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Closed-Circuit Television Systems (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
Description
技术领域technical field
本发明属于交通领域,具体涉及一种基于虚车道线的车载相机自动标定方法。The invention belongs to the field of traffic, and in particular relates to an automatic calibration method for a vehicle-mounted camera based on virtual lane lines.
背景技术Background technique
到目前为止,交通领域(包括车载相机和交通监控相机等)的自动标定算法依据标识物大致可以分为基于车道线等静态目标的标定算法和基于车辆行人等运动目标的标定算法。相对于基于静态目标的标定算法来说,基于运动目标的算法要复杂得多,它不仅要求画面中出现车辆或行人等目标,还需要对一个视频序列进行分析获取移动轨迹进而得到消失点,部分算法甚至对移动的方向和速度还有要求,因此这种方法更适合于静止不动的交通监控相机。对于车载相机来说,场景中可能会有大量车辆出现,但由于车辆之间复杂的相对运动,难以找到一个合适的目标进行轨迹分析,而车道线作为静止物,更适合用来作为车载相机自动标定的标识物。So far, the automatic calibration algorithms in the traffic field (including vehicle cameras and traffic monitoring cameras, etc.) can be roughly divided into calibration algorithms based on static targets such as lane lines and calibration algorithms based on moving targets such as vehicles and pedestrians according to markers. Compared with the calibration algorithm based on static targets, the algorithm based on moving targets is much more complicated. It not only requires vehicles or pedestrians to appear in the picture, but also needs to analyze a video sequence to obtain the moving trajectory and then get the vanishing point. The algorithm even has requirements on the direction and speed of movement, so this method is more suitable for stationary traffic surveillance cameras. For vehicle-mounted cameras, there may be a large number of vehicles in the scene, but due to the complex relative motion between vehicles, it is difficult to find a suitable target for trajectory analysis, and lane lines, as stationary objects, are more suitable for use as vehicle-mounted cameras. Calibrated identifiers.
在相机成像过程中,三维世界中某点转化为二维图像中的像素点,可以使用几何方法建立模型描述该过程,相机参数即几何模型中涉及到的一些参数。相机内参包括焦距、光心位置、畸变系数等;相机外参包括旋转矩阵和平移矩阵。相机标定的目的就是得到相机参数,而标定精度将直接影响自动驾驶车辆的视觉感知与定位。传统的相机标定方法需要利用标定板上的特定点来确定相机参数,因此这种方法只适用于静态条件下,一般用于标定相机内参。而车载相机在车辆行驶过程中,其外部参数可能会由于各种因素例如道路颠簸、车体振动等发生变化(相机内参不变),这时则需要对外参进行重新标定。而车道线在行车场景中普遍存在,可以利用车道线的平行性以及车道宽度已知等特征对相机外参进行自动标定。In the process of camera imaging, a point in the 3D world is transformed into a pixel in a 2D image. A geometric method can be used to build a model to describe the process. Camera parameters are some parameters involved in the geometric model. Camera internal parameters include focal length, optical center position, distortion coefficient, etc.; camera external parameters include rotation matrix and translation matrix. The purpose of camera calibration is to obtain camera parameters, and the calibration accuracy will directly affect the visual perception and positioning of autonomous vehicles. The traditional camera calibration method needs to use specific points on the calibration board to determine the camera parameters, so this method is only suitable for static conditions and is generally used to calibrate the internal parameters of the camera. While the vehicle-mounted camera is running, its external parameters may change due to various factors such as road bumps, vehicle body vibration, etc. (the internal parameters of the camera remain unchanged), and then the external parameters need to be recalibrated. Lane lines are ubiquitous in driving scenes, and the parallelism of lane lines and the known lane width can be used to automatically calibrate the camera extrinsic parameters.
发明内容Contents of the invention
本发明的目的在于针对上述现有技术的不足,提供了一种基于虚车道线的车载相机自动标定方法。The object of the present invention is to provide an automatic calibration method for a vehicle camera based on virtual lane lines to address the above-mentioned deficiencies in the prior art.
本发明采用如下技术方案来实现的:The present invention adopts following technical scheme to realize:
一种基于虚车道线的车载相机自动标定方法,包括以下步骤:A method for automatic calibration of vehicle-mounted cameras based on virtual lane lines, comprising the following steps:
1)在车辆后轴中心垂直向下与地面交点处建立世界坐标系,车辆正前方为Z轴,前进方向右侧为X轴,竖直向下为Y轴;建立相机坐标系,相机坐标系原点在世界坐标系中的坐标为(d,h,l);1) Establish a world coordinate system at the intersection of the center of the rear axle of the vehicle vertically downward and the ground. The front of the vehicle is the Z axis, the right side of the forward direction is the X axis, and the vertical downward is the Y axis; establish the camera coordinate system, the camera coordinate system The coordinates of the origin in the world coordinate system are (d, h, l);
2)用相机在车辆正前方车道中心拍摄单张照片,测量车道宽度,在世界坐标系的俯视视角下,选取两侧虚车道线所形成的矩形框作为标定图形,根据矩形性质得到矩形四个特征点与车道宽度的关系,再由正交矩阵性质和相机坐标系和世界坐标系之间的坐标变换关系得出基于相机坐标系的旋转矩阵方程;2) Use the camera to take a single photo in the center of the lane in front of the vehicle, measure the width of the lane, and select the rectangular frame formed by the virtual lane lines on both sides as the calibration figure under the top view of the world coordinate system, and obtain four rectangles according to the nature of the rectangle. The relationship between feature points and lane width, and then the rotation matrix equation based on the camera coordinate system is obtained from the orthogonal matrix properties and the coordinate transformation relationship between the camera coordinate system and the world coordinate system;
3)由车辆行驶过程中相机内参不变,利用相机内参把相机坐标转换为像素坐标,再从图像中获取四个特征点的像素坐标后,求出关于相机外参的旋转矩阵和平移矩阵的ψ、θ、φ和h四个参数。3) Since the internal parameters of the camera remain unchanged during the driving process of the vehicle, the camera coordinates are converted into pixel coordinates by using the internal parameters of the camera, and then the pixel coordinates of the four feature points are obtained from the image, and the rotation matrix and translation matrix of the external parameters of the camera are obtained. ψ, θ, φ and h four parameters.
本发明进一步的改进在于,步骤2)的具体实现方法如下:A further improvement of the present invention is that the specific implementation method of step 2) is as follows:
101)引入世界坐标系W与相机坐标系C之间的变换模型如下式101) Introduce the transformation model between the world coordinate system W and the camera coordinate system C as follows
Pc=R·Pw+T Pc =R· Pw +T
其中R表示旋转矩阵,T表示平移矩阵;Where R represents the rotation matrix and T represents the translation matrix;
由于旋转矩阵R为正交矩阵,根据正交矩阵的性质将公式改写为下式:Since the rotation matrix R is an orthogonal matrix, the formula is rewritten as the following formula according to the nature of the orthogonal matrix:
Pw=R-1Pc-R-1T=RTPc-RTTP w =R -1 P c -R -1 T=R T P c -R T T
式中,-RTT的实际意义就是相机坐标系原点在世界坐标系中的坐标;In the formula, the actual meaning of -R T T is the coordinates of the origin of the camera coordinate system in the world coordinate system;
为了便于理解和计算,这里使用rmn表示旋转矩阵R中的元素,将公式改写为矩阵形式,如下式:In order to facilitate understanding and calculation, r mn is used here to represent the elements in the rotation matrix R, and the formula is rewritten into a matrix form, as follows:
102)设矩形四个点分别为ABCD,A、C,B、D分别在同一条虚车道线上,沿Y轴分布,车道宽度为width,根据矩形的性质得到下式:102) Let the four points of the rectangle be ABCD, A, C, B, and D are respectively on the same virtual lane line, distributed along the Y axis, and the width of the lane is width. According to the nature of the rectangle, the following formula is obtained:
103)由于世界坐标是未知的,将(1)中式子代入到(2)中,这一过程将世界坐标转化为相机坐标,如下式103) Since the world coordinates are unknown, substitute (1) into (2), this process converts the world coordinates into camera coordinates, as follows
此时,方程中不再含有各点的世界坐标,只剩下各点的相机坐标,而车辆行驶过程中内参不变,在这里认为相机内参已知,因此利用相机内参再把相机坐标转换为像素坐标。At this time, the world coordinates of each point are no longer included in the equation, only the camera coordinates of each point are left, and the internal parameters of the vehicle are unchanged during driving. Here, the internal parameters of the camera are considered to be known, so the camera coordinates are transformed into pixel coordinates.
本发明进一步的改进在于,步骤3)的具体实现方法如下:A further improvement of the present invention is that the specific implementation method of step 3) is as follows:
201)引入经典像素坐标系与世界坐标系之间的变换模型,如下式:201) Introduce the transformation model between the classic pixel coordinate system and the world coordinate system, as follows:
式中,fx=f/dx;fy=f/dy,分别称为x轴与y轴的归一化焦距,dx、dy分别表示一个像素点在x、y轴方向的物理尺寸,f是相机焦距,(u0,v0)表示图像坐标系原点在像素坐标系下的坐标,R表示相机旋转矩阵,T表示相机平移矩阵;In the formula, f x =f/dx; f y =f/dy are called the normalized focal lengths of x-axis and y-axis respectively, dx and dy represent the physical size of a pixel in the direction of x-axis and y-axis respectively, and f is the focal length of the camera, (u 0 , v 0 ) represents the coordinates of the origin of the image coordinate system in the pixel coordinate system, R represents the camera rotation matrix, and T represents the camera translation matrix;
202)由世界坐标系与相机坐标系之间的转换模型结合像素坐标系与世界坐标系之间的变换模型,得出相机坐标系与像素坐标系的变换模型,如下式:202) Combining the transformation model between the world coordinate system and the camera coordinate system with the transformation model between the pixel coordinate system and the world coordinate system, the transformation model of the camera coordinate system and the pixel coordinate system is obtained, as follows:
展开可得下式:Expand to get the following formula:
式中,fx、fy、u0和v0都为已知参数;In the formula, f x , f y , u 0 and v 0 are all known parameters;
将上式代入①中最后一个方程可得下式:Substituting the above formula into the last equation in ①, the following formula can be obtained:
203)求解外参矩阵R,T;203) Solve the external parameter matrix R, T;
将公式②和③代入到公式①中消去各点的相机坐标,只剩下与像素坐标相关的参数,而像素坐标从图像中直接获取;方程简化为下式:Substitute
式中只包含ψ、θ、φ和h四个未知数,因此联立求解可得下式:The formula contains only four unknowns ψ, θ, φ and h, so the following formula can be obtained by solving simultaneously:
式中,FAC=(mC-mA)+tanφmAmC(nA-nC);GAC=sinφ(mC-mA)+cosφmAmC(nA-nC);FBD=(mD-mB)+tanφmBmD(nB-nD);GBD=sinφ(mD-mB)+cosφmBmD(nB-nD)In the formula, F AC =(m C -m A )+tanφm A m C (n A -n C ); G AC =sinφ(m C -m A )+cosφm A m C (n A -n C ); F BD =(m D -m B )+tanφm B m D (n B -n D ); G BD =sinφ(m D -m B )+cosφm B m D (n B -n D )
由此相机外参的旋转矩阵R和平移矩阵T的ψ、θ、φ和h四个参数被求解出来。From this, the four parameters of the rotation matrix R of the camera extrinsic parameters and the translation matrix T of ψ, θ, φ and h are solved.
本发明至少具有如下有益的技术效果:The present invention has at least the following beneficial technical effects:
本发明提供的一种基于虚车道线的车载相机自动标定方法,该方法根据车载相机实时获得的图像中两侧虚车道线所形成的矩形为标定物,利用常见行车场景中车道线的平行性以及已知车道宽度等特征对相机外参进行自动标定即可一次性完成相机的标定工作。由于所选取的车道线参数已知,且常见道路上均有车道线,本发明提出的标定方法能够针对车辆行驶过程中因道路颠簸、车体振动等造成的相机外参变化,实现实时的自动标定,具有操作简单,测量便捷,实时性好等优点。The present invention provides a vehicle camera automatic calibration method based on virtual lane lines. The method uses the rectangles formed by the virtual lane lines on both sides of the image obtained by the vehicle camera in real time as the calibration object, and utilizes the parallelism of lane lines in common driving scenes. And the known lane width and other characteristics can automatically calibrate the camera extrinsic parameters to complete the camera calibration work at one time. Since the parameters of the selected lane line are known, and there are lane lines on common roads, the calibration method proposed by the present invention can realize real-time automatic Calibration has the advantages of simple operation, convenient measurement and good real-time performance.
进一步,由于引入的未知变量仅有车道宽度width,而所选取虚车道矩形四个点的坐标通过相机坐标系和世界坐标系之间的转换关系,转换为相机坐标系下的坐标,所以本发明选取的标定参数少,测量便捷。由相机的内参将相机坐标系下所得的四点坐标转换到像素坐标系中,此时四点的坐标转换为能从图像中直接获取的图像中像素坐标系下的像素坐标,此时关于相机外参旋转矩阵R和平移矩阵T的ψ、θ、φ和h四个参数的方程转换为仅关于车道宽度width的方程,联立求解即可得到相机的外参。因此本发明提出的基于虚车道线的车载相机自动标定方法操作简单、所用的标定参数少,测量便捷、普适性优良、实时性好。Further, since the introduced unknown variable is only the width of the lane, and the coordinates of the four points of the selected virtual lane rectangle are transformed into coordinates in the camera coordinate system through the conversion relationship between the camera coordinate system and the world coordinate system, the present invention The selected calibration parameters are few, and the measurement is convenient. The coordinates of the four points obtained in the camera coordinate system are converted into the pixel coordinate system by the internal reference of the camera. At this time, the coordinates of the four points are converted into pixel coordinates in the pixel coordinate system of the image that can be directly obtained from the image. At this time, the camera The equations of the four parameters ψ, θ, φ, and h of the external parameter rotation matrix R and translation matrix T are converted into equations only about the width of the lane, and the external parameters of the camera can be obtained by solving them simultaneously. Therefore, the vehicle-mounted camera automatic calibration method based on virtual lane lines proposed by the present invention is simple to operate, uses few calibration parameters, is convenient to measure, has excellent universality and good real-time performance.
附图说明Description of drawings
图1为世界坐标系到相机坐标系示意图。Figure 1 is a schematic diagram from the world coordinate system to the camera coordinate system.
图2为世界坐标系中点绕X轴旋转ψ角示意图。Fig. 2 is a schematic diagram of the rotation of the center point of the world coordinate system by an angle ψ around the X axis.
图3为相机坐标系到图像坐标系示意图。Fig. 3 is a schematic diagram from the camera coordinate system to the image coordinate system.
图4为图像坐标系到像素坐标系示意图。Fig. 4 is a schematic diagram of an image coordinate system to a pixel coordinate system.
图5为车辆与相机的位置关系示意图,其中图5(a)为主视图,图5(b)为侧视图,图5(c)为俯视图。Fig. 5 is a schematic diagram of the positional relationship between the vehicle and the camera, wherein Fig. 5(a) is a front view, Fig. 5(b) is a side view, and Fig. 5(c) is a top view.
图6为两侧虚车道线所形成的矩形示意图。FIG. 6 is a schematic diagram of a rectangle formed by virtual lane lines on both sides.
图7为本发明实施例所采用的实际道路场景经Opencv标定后的图像。FIG. 7 is an image of the actual road scene used in the embodiment of the present invention after being calibrated by Opencv.
图8为经本发明方法所标定后的图像。Fig. 8 is an image calibrated by the method of the present invention.
具体实施方式detailed description
以下结合附图和实施例对本发明做出进一步的说明。The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
相机标定基础理论Camera Calibration Basic Theory
相机拍摄图像的过程是一个光学成像过程。该过程涉及到以下四个坐标系:The process of taking images by a camera is an optical imaging process. The process involves the following four coordinate systems:
像素坐标系:用(u,v)表示,以图像左上角为原点,水平向右为u轴,垂直向下为v轴,单位为像素。Pixel coordinate system: represented by (u,v), with the upper left corner of the image as the origin, the u axis horizontally to the right, and the v axis vertically downward, the unit is pixel.
图像坐标系:用(x,y)表示,原点为图像中心,水平向右为x轴。垂直向下为y轴,单位为物理单位。Image coordinate system: represented by (x, y), the origin is the center of the image, and the horizontal to the right is the x-axis. Vertically downward is the y-axis, and the unit is physical unit.
相机坐标系:用(Xc,Yc,Zc)表示,原点为镜头光心,X、Y轴分别与相面的两边平行,Z轴为镜头光轴,与像平面垂直,单位为物理单位。Camera coordinate system: represented by (X c , Y c , Z c ), the origin is the optical center of the lens, the X and Y axes are parallel to the two sides of the phase surface, and the Z axis is the optical axis of the lens, perpendicular to the image plane, and the unit is physical unit.
世界坐标系:用(Xw,Yw,Zw)表示,描述相机位置,世界坐标系的位置不固定,由人为定义,单位为物理单位。World coordinate system: represented by (X w , Y w , Z w ), which describes the position of the camera. The position of the world coordinate system is not fixed and is defined by humans, and the unit is a physical unit.
世界坐标系到相机坐标系World coordinate system to camera coordinate system
从世界坐标系到相机坐标系的变换过程属于刚体变换,即物体在变换过程中不会发生形变,只需要对坐标系进行旋转操作和平移操作。世界坐标系与相机坐标系之间的关系如图1所示,其中R表示旋转矩阵,T表示平移矩阵。The transformation process from the world coordinate system to the camera coordinate system is a rigid body transformation, that is, the object does not deform during the transformation process, and only needs to perform rotation and translation operations on the coordinate system. The relationship between the world coordinate system and the camera coordinate system is shown in Figure 1, where R represents the rotation matrix and T represents the translation matrix.
假设有一点P,在世界坐标系中的坐标为Pw(Xw,Yw,Zw),相机坐标系中的坐标为Pc(Xc,Yc,Zc),则Pc与Pw有如下关系:Suppose there is a point P, the coordinates in the world coordinate system are P w (X w , Y w , Z w ), and the coordinates in the camera coordinate system are P c (X c , Y c , Z c ), then P c and P w has the following relationship:
Pc=R·Pw+T (5-1)P c =R·P w +T (5-1)
由于相机坐标系可由世界坐标系旋转平移得到,本发明先使点P绕X轴旋转ψ角度,如图2所示:Since the camera coordinate system can be obtained by the rotation and translation of the world coordinate system, the present invention first rotates the point P around the X axis by an angle ψ, as shown in Figure 2:
根据图2中的两个坐标系的关系,可以得到世界坐标系中绕X轴旋转ψ角度的矩阵形式如公式(5-2)所示:According to the relationship between the two coordinate systems in Figure 2, the matrix form of the rotation angle ψ around the X axis in the world coordinate system can be obtained as shown in formula (5-2):
同理可得,绕Y轴旋转θ角、绕Z轴旋转φ角后的坐标变化关系如式(5-3)所示。In the same way, it can be obtained that the coordinate change relationship after rotating around the Y axis by θ angle and around Z axis by φ angle is shown in formula (5-3).
则旋转矩阵R为:Then the rotation matrix R is:
至此可以得到相机坐标系与世界坐标系的关系,由于旋转矩阵R中的元素较长,为了便于理解和表达,后文中统一用r加下标表示,如公式(5-5)所示:At this point, the relationship between the camera coordinate system and the world coordinate system can be obtained. Since the elements in the rotation matrix R are relatively long, in order to facilitate understanding and expression, they will be represented by subscripting r in the following text, as shown in formula (5-5):
相机坐标系到图像坐标系Camera coordinate system to image coordinate system
这一过程是从三维坐标系转换到二维平面坐标系的过程,两个坐标系之间为透视投影关系,并且符合三角形相似定理。两个坐标系之间的关系如图3所示,其中f是相机焦距。This process is a process of transforming from a three-dimensional coordinate system to a two-dimensional plane coordinate system. The relationship between the two coordinate systems is a perspective projection, and it conforms to the triangle similarity theorem. The relationship between the two coordinate systems is shown in Figure 3, where f is the camera focal length.
从上图中可以看出,POc是点Pc(Xc,Yc,Zc)与光心Oc之间的连线,POc与成像平面的交点即为空间点Pc(Xc,Yc,Zc)在成像平面上的投影点p(x,y),因此本发明可以得到两对相似三角形ΔABOc~ΔoCOc,ΔPBOc~ΔpCOc,通过两对相似三角形的相似关系可得到公式(5-6):It can be seen from the figure above that PO c is the connection line between point P c (X c , Y c , Z c ) and optical center O c , and the intersection point of PO c and the imaging plane is the spatial point P c (X c , Y c , Z c ) projection point p(x, y) on the imaging plane, so the present invention can obtain two pairs of similar triangles ΔABO c ~ ΔoCO c , ΔPBO c ~ ΔpCO c , through the similarity of two pairs of similar triangles The relationship can be obtained as formula (5-6):
将上式改写为矩阵形式表示如下:Rewrite the above formula into matrix form as follows:
图像坐标系到像素坐标系Image coordinate system to pixel coordinate system
这一转换过程中没有旋转变换,但两个坐标系原点位置不一致,坐标系单位大小也不一致,因此通过伸缩变换和平移变换即可实现。两个坐标系之间的关系如图4所示,(u0,v0)表示图像坐标系原点在像素坐标系下的坐标,p(x,y)即空间点Pc(Xc,Yc,Zc)在成像平面上的投影点。There is no rotation transformation in this transformation process, but the origin positions of the two coordinate systems are inconsistent, and the coordinate system unit sizes are also inconsistent, so it can be realized by scaling transformation and translation transformation. The relationship between the two coordinate systems is shown in Figure 4, (u 0 , v 0 ) represents the coordinates of the origin of the image coordinate system in the pixel coordinate system, and p(x,y) is the spatial point P c (X c ,Y c , Z c ) Projection points on the imaging plane.
因此两个坐标系之间的关系可由下式表示:Therefore, the relationship between the two coordinate systems can be expressed by the following formula:
式中dx、dy分别表示一个像素点在x、y轴方向的物理尺寸。再将上式用齐次坐标和矩阵表示如下:In the formula, dx and dy represent the physical size of a pixel in the x and y axis directions, respectively. Then express the above formula with homogeneous coordinates and matrix as follows:
至此,四个坐标系之间的矩阵关系都已得到。整理公式(5-5)、(5-7)和(5-9)最终可以得到像素坐标系与世界坐标系之间的坐标变换关系,其矩阵形式如式(5-10)所示:So far, the matrix relationships among the four coordinate systems have been obtained. After finishing the formulas (5-5), (5-7) and (5-9), the coordinate transformation relationship between the pixel coordinate system and the world coordinate system can be finally obtained, and its matrix form is shown in formula (5-10):
式中,fx=f/dx;fy=f/dy,分别称为x轴与y轴的归一化焦距。In the formula, f x =f/dx; f y =f/dy, which are respectively called the normalized focal lengths of the x-axis and the y-axis.
在式(5-10)中,第二个等号后边的第一个矩阵就是相机的内参矩阵,第二个矩阵是相机的外参矩阵。因此相机内参主要包括fx、fy、u0和v0四个参数以及畸变系数,它反映了相机坐标系与像素坐标系之间的关系;相机外参共有6个参数,分别是ψ、θ、φ和平移矩阵T中的三个元素,外参反映的是世界坐标系与相机坐标系之间的关系。In formula (5-10), the first matrix after the second equal sign is the internal reference matrix of the camera, and the second matrix is the external reference matrix of the camera. Therefore, the camera internal parameters mainly include four parameters f x , f y , u 0 and v 0 and the distortion coefficient, which reflects the relationship between the camera coordinate system and the pixel coordinate system; the camera external parameters have 6 parameters in total, namely ψ, θ, φ and the three elements in the translation matrix T, the external parameters reflect the relationship between the world coordinate system and the camera coordinate system.
基于虚车道线的车载相机自动标定方法Automatic Calibration Method of Car Camera Based on Virtual Lane Lines
如图5所示,建立世界坐标系和相机坐标系。默认的相机坐标系为沿光轴为Z轴,向右为X轴,竖直向下为Y轴。世界坐标系原点在车辆后轴中心垂直向下与地面交点,车辆正前方为Z轴,前进方向右侧为X轴,竖直向下为Y轴,相机坐标系原点在世界坐标系中的坐标为(d,h,l)。As shown in Figure 5, a world coordinate system and a camera coordinate system are established. The default camera coordinate system is the Z axis along the optical axis, the X axis to the right, and the Y axis vertically downward. The origin of the world coordinate system is at the intersection of the center of the rear axle of the vehicle vertically downward and the ground, the front of the vehicle is the Z axis, the right side of the forward direction is the X axis, and the vertical downward is the Y axis, the coordinates of the origin of the camera coordinate system in the world coordinate system is (d, h, l).
车辆行驶中随着车辆的振动相机与车辆的相对位置会发生变化,一般来说,在相机外参中三个旋转角和相机高度变化比较明显,而d、l基本不变,因此本发明提出的自动标定算法主要计算以下四个参数:ψ、θ、φ和h。假设路面平坦,且车辆前进方向与车道线方向是平行的,本发明选取两侧虚车道线所形成的矩形框作为标定图形,如图6所示:The relative position of the camera and the vehicle will change with the vibration of the vehicle while the vehicle is running. Generally speaking, the three rotation angles and the height of the camera in the external parameters of the camera change significantly, while d and l are basically unchanged. Therefore, the present invention proposes The automatic calibration algorithm mainly calculates the following four parameters: ψ, θ, φ and h. Assuming that the road surface is flat and the vehicle’s forward direction is parallel to the direction of the lane line, the present invention selects the rectangular frame formed by the virtual lane lines on both sides as the calibration figure, as shown in Figure 6:
在世界坐标系的俯视视角下,本发明认为ABCD四个点形成了一个矩形,根据矩形的性质可以得到公式(5-11):Under the top view angle of the world coordinate system, the present invention considers that the four points ABCD form a rectangle, and formula (5-11) can be obtained according to the nature of the rectangle:
式中,width表示车道宽度。In the formula, width represents the lane width.
在公式(5-1)中,由于旋转矩阵R为正交矩阵,根据正交矩阵的性质可以将公式改写为下式:In formula (5-1), since the rotation matrix R is an orthogonal matrix, the formula can be rewritten as the following formula according to the nature of the orthogonal matrix:
Pw=R-1Pc-R-1T=RTPc-RTT (5-12)P w = R -1 P c -R -1 T = R T P c -R T T (5-12)
式中,-RTT的实际意义就是相机坐标系原点在世界坐标系中的坐标。In the formula, the actual meaning of -R T T is the coordinates of the origin of the camera coordinate system in the world coordinate system.
将公式(5-12)改写为矩阵形式,如式(5-13)所示,为了便于理解和计算,这里使用rmn表示旋转矩阵R中的元素。Rewrite the formula (5-12) into a matrix form, as shown in the formula (5-13). For the convenience of understanding and calculation, r mn is used here to represent the elements in the rotation matrix R.
由于世界坐标是未知的,本发明将公式(5-13)代入到公式(5-11)中,这一过程可以将世界坐标转化为相机坐标,如式(5-14)所示。Since the world coordinates are unknown, the present invention substitutes formula (5-13) into formula (5-11), and this process can convert the world coordinates into camera coordinates, as shown in formula (5-14).
此时,方程中不再含有各点的世界坐标,只剩下各点的相机坐标。前文中已经提到过车辆行驶过程中内参不变,在这里认为相机内参已知。因此可以利用相机内参再把相机坐标转换为像素坐标。At this point, the equation no longer contains the world coordinates of each point, only the camera coordinates of each point remain. It has been mentioned above that the internal parameters of the vehicle do not change during driving, and here the internal parameters of the camera are considered to be known. Therefore, the camera internal reference can be used to convert the camera coordinates into pixel coordinates.
由公式(5-10)可知,相机坐标系与像素坐标系的关系如下式所示:From the formula (5-10), we can see that the relationship between the camera coordinate system and the pixel coordinate system is as follows:
将公式(5-15)展开可得下式:Expand the formula (5-15) to get the following formula:
式中,fx、fy、u0和v0都为已知参数,因此只需要再从图像中获取各点的像素坐标后即可计算出m、n。In the formula, f x , f y , u 0 and v 0 are all known parameters, so m and n can be calculated only after obtaining the pixel coordinates of each point from the image.
将公式(5-16)代入到公式(5-14)中最后一个方程可得:Substituting formula (5-16) into the last equation in formula (5-14) gives:
将公式(5-16)和(5-17)代入到公式(5-14)中可以消去各点的相机坐标,只剩下与像素坐标相关的参数,而像素坐标可以从图像中直接获取。方程简化为如下形式:Substituting formulas (5-16) and (5-17) into formula (5-14) can eliminate the camera coordinates of each point, leaving only parameters related to pixel coordinates, which can be obtained directly from the image. The equation simplifies to the following form:
式(5-18)中只包含ψ、θ、φ和h四个未知数,因此联立可解得:Equation (5-18) only contains four unknowns ψ, θ, φ and h, so it can be solved simultaneously:
式中,FAC=(mC-mA)+tanφmAmC(nA-nC);GAC=sinφ(mC-mA)+cosφmAmC(nA-nC);FBD=(mD-mB)+tanφmBmD(nB-nD);GBD=sinφ(mD-mB)+cosφmBmD(nB-nD)。In the formula, F AC =(m C -m A )+tanφm A m C (n A -n C ); G AC =sinφ(m C -m A )+cosφm A m C (n A -n C ); F BD =(m D -m B )+tanφm B m D (n B -n D ); G BD =sinφ(m D -m B )+cosφm B m D (n B -n D ).
图7为Opencv(一个基于BSD许可,开源发行的计算机视觉和机器学习软件库)标定的原始图片,在车辆停放好后,本发明实际测量了车道线上的8个点的世界坐标,opencv内置函数solvePnP可根据世界坐标与对应的图像坐标求得外参;图8为使用本发明的标定算法进行标定的图片,图中选取了虚车道线所形成的矩形的四个顶点。表1为一种基于虚车道线的车载相机自动标定方法(本发明)与Opencv方法在实际道路场景中的标定结果及误差对比。Fig. 7 is the original picture calibrated by Opencv (a computer vision and machine learning software library based on BSD licensing, open source distribution). After the vehicle is parked, the present invention actually measures the world coordinates of 8 points on the lane line. The function solvePnP can obtain the external parameters according to the world coordinates and the corresponding image coordinates; Fig. 8 is a picture calibrated using the calibration algorithm of the present invention, in which four vertices of a rectangle formed by virtual lane lines are selected. Table 1 is a comparison of calibration results and errors between a vehicle-mounted camera automatic calibration method based on virtual lane lines (the present invention) and the Opencv method in actual road scenes.
表1:Table 1:
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010713419.7A CN112102413B (en) | 2020-07-22 | 2020-07-22 | An automatic calibration method for vehicle-mounted cameras based on virtual lane lines |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010713419.7A CN112102413B (en) | 2020-07-22 | 2020-07-22 | An automatic calibration method for vehicle-mounted cameras based on virtual lane lines |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112102413A CN112102413A (en) | 2020-12-18 |
CN112102413B true CN112102413B (en) | 2022-12-09 |
Family
ID=73749988
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010713419.7A Active CN112102413B (en) | 2020-07-22 | 2020-07-22 | An automatic calibration method for vehicle-mounted cameras based on virtual lane lines |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112102413B (en) |
Families Citing this family (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112785653B (en) * | 2020-12-30 | 2024-06-21 | 中山联合汽车技术有限公司 | Vehicle-mounted camera attitude angle calibration method |
CN112862899B (en) | 2021-02-07 | 2023-02-28 | 黑芝麻智能科技(重庆)有限公司 | External parameter calibration method, device and system for image acquisition equipment |
CN112927303B (en) * | 2021-02-22 | 2023-01-24 | 中国重汽集团济南动力有限公司 | Lane line-based automatic driving vehicle-mounted camera pose estimation method and system |
CN112927309B (en) * | 2021-03-26 | 2024-04-09 | 苏州欧菲光科技有限公司 | Vehicle-mounted camera calibration method and device, vehicle-mounted camera and storage medium |
CN113223095B (en) * | 2021-05-25 | 2022-06-17 | 中国人民解放军63660部队 | Internal and external parameter calibration method based on known camera position |
CN113657282B (en) * | 2021-08-18 | 2025-05-02 | 苏州挚途科技有限公司 | Method, device and electronic device for extracting lane |
CN114387350A (en) * | 2021-12-03 | 2022-04-22 | 江铃汽车股份有限公司 | Vehicle-mounted camera external parameter calibration method and device, storage medium and equipment |
CN114463439B (en) * | 2022-01-18 | 2023-04-11 | 襄阳达安汽车检测中心有限公司 | Vehicle-mounted camera correction method and device based on image calibration technology |
CN114419597A (en) * | 2022-01-21 | 2022-04-29 | 深圳市艾为智能有限公司 | Method for improving 2D frame positioning accuracy based on vehicle identification |
CN114359412B (en) * | 2022-03-08 | 2022-05-27 | 盈嘉互联(北京)科技有限公司 | Automatic calibration method and system for external parameters of camera facing to building digital twins |
CN114820816A (en) * | 2022-05-07 | 2022-07-29 | 厦门瑞为信息技术有限公司 | Automatic calibration method, device, equipment and medium for height of vehicle-mounted camera |
CN115268491A (en) * | 2022-07-20 | 2022-11-01 | 山东高速建设管理集团有限公司 | A data acquisition and processing system based on Beidou + UAV grid code high-speed field |
CN115294215A (en) * | 2022-08-09 | 2022-11-04 | 东风悦享科技有限公司 | Vehicle-mounted camera external parameter calibration method based on control point and positioning information |
CN115024740B (en) * | 2022-08-11 | 2022-10-25 | 晓智未来(成都)科技有限公司 | Virtual radiation field display method for common X-ray photography |
CN115880372A (en) * | 2022-12-12 | 2023-03-31 | 武汉港迪智能技术有限公司 | Unified calibration method and system for external hub positioning camera of automatic crane |
CN117611438B (en) * | 2023-12-06 | 2024-10-11 | 浙江省交通投资集团有限公司智慧交通研究分公司 | Monocular image-based reconstruction method from 2D lane line to 3D lane line |
CN117788576B (en) * | 2023-12-18 | 2025-02-28 | 北京叠幻三维科技有限公司 | A camera spatial positioning method based on a single image |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108898638A (en) * | 2018-06-27 | 2018-11-27 | 江苏大学 | A kind of on-line automatic scaling method of vehicle-mounted camera |
CN110008893A (en) * | 2019-03-29 | 2019-07-12 | 武汉理工大学 | A method for automatic detection of vehicle running deviation based on on-board image sensor |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9981605B2 (en) * | 2014-05-16 | 2018-05-29 | GM Global Technology Operations LLC | Surround-view camera system (VPM) and vehicle dynamic |
-
2020
- 2020-07-22 CN CN202010713419.7A patent/CN112102413B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108898638A (en) * | 2018-06-27 | 2018-11-27 | 江苏大学 | A kind of on-line automatic scaling method of vehicle-mounted camera |
CN110008893A (en) * | 2019-03-29 | 2019-07-12 | 武汉理工大学 | A method for automatic detection of vehicle running deviation based on on-board image sensor |
Non-Patent Citations (3)
Title |
---|
"Automatic on-the-fly extrinsic camera calibration of onboard vehicular cameras";M.B.de Paula等;《Expert Systems with Applications》;20140331;第41卷(第4期);第1997-2007页 * |
"Research on Lane-Marking Line Based Camera Calibration";Kunfeng Wang等;《2007 IEEE International Conference on Vehicular Electronics and Safety》;20080225;全文 * |
"基于IPM和边缘图像过滤的多干扰车道线检测";吴骅跃等;《中国公路学报》;20200531;第33卷(第5期);第153-164页 * |
Also Published As
Publication number | Publication date |
---|---|
CN112102413A (en) | 2020-12-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112102413B (en) | An automatic calibration method for vehicle-mounted cameras based on virtual lane lines | |
CN110148169B (en) | Vehicle target three-dimensional information acquisition method based on PTZ (pan/tilt/zoom) pan-tilt camera | |
Scaramuzza et al. | Extrinsic self calibration of a camera and a 3D laser range finder from natural scenes | |
CN110842940A (en) | Building surveying robot multi-sensor fusion three-dimensional modeling method and system | |
CN103617606B (en) | For assisting the vehicle multi-angle panorama generation method of driving | |
US12217444B2 (en) | Method for measuring the topography of an environment | |
US20230215187A1 (en) | Target detection method based on monocular image | |
CN108765496A (en) | A kind of multiple views automobile looks around DAS (Driver Assistant System) and method | |
CN109903341A (en) | A dynamic self-calibration method for vehicle camera external parameters | |
CN110517349A (en) | A 3D Vehicle Target Detection Method Based on Monocular Vision and Geometric Constraints | |
CN108269235A (en) | A kind of vehicle-mounted based on OPENGL looks around various visual angles panorama generation method | |
CN107792179A (en) | A kind of parking guidance method based on vehicle-mounted viewing system | |
CN109087251B (en) | Vehicle-mounted panoramic image display method and system | |
WO2022078442A1 (en) | Method for 3d information acquisition based on fusion of optical scanning and smart vision | |
CN113362228A (en) | Method and system for splicing panoramic images based on improved distortion correction and mark splicing | |
CN103729837A (en) | Rapid calibration method of single road condition video camera | |
WO2022048493A1 (en) | Camera extrinsic parameter calibration method and apparatus | |
CN106570906A (en) | Rectangular pattern-based method for detecting distances under camera angle deflection condition | |
CN105374067A (en) | Three-dimensional reconstruction method based on PAL cameras and reconstruction system thereof | |
CN111862210A (en) | A method and device for target detection and positioning based on a surround-view camera | |
CN114140534A (en) | Combined calibration method for laser radar and camera | |
CN111476798A (en) | Vehicle space form recognition method and system based on contour constraint | |
KR20240022986A (en) | METHODS AND APPARATUS FOR ESTIMATION OF THE DISTANCE OF THE OBJECTS IN EUCLIDEAN SPACE USING FUSION OF CAMERA POSE INFORMATION and SCENE PRIOR INFORMATION'S AND THEREOF | |
CN104048601A (en) | Integrally-imaging image mapping method based on coordinate transformation | |
CN104268884B (en) | A kind of calibration system and method for the lane departure warning based on car networking |
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 |