Parameter calibration method, device and storage medium for image capture device
By constructing an imaging network model and using preset distribution relationships to simplify the training process, the complexity problem of attitude angle calibration of infrared cameras is solved, rapid and accurate attitude angle calibration at night and in bad weather is achieved, and driving safety is improved.
Patent Information
- Application Number
- CN202111486387.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-12-07
Smart Images

Figure CN114170323B
Abstract
Description
Technical Field
[0001] The present application relates to a parameter calibration technology for electronic devices, and in particular to a parameter calibration method, device and storage medium for an image capture device. Background Art
[0002] The calibration of the attitude angle of a monocular camera is used in the fields of drones, robots, and self-driving cars. When performing operations such as target ranging and positioning based on the image data collected by the camera, the attitude angle information of the camera is indispensable. Therefore, the calibration of the attitude angle of the camera is also a necessary operation based on the camera for environmental perception, and it places high demands on the complexity of the calibration process, the accuracy of the calibration results, and the operability of the calibration method.
[0003] At present, many calibration methods are only used for visible light cameras. In some special cases, such as at night and in bad weather such as haze, the effect of visible light cameras will be greatly reduced. Infrared cameras can overcome the above difficulties. They do not rely on light, but form images based on the temperature of the target. They are more suitable for use in scenes with poor lighting such as night. However, due to the characteristics of infrared cameras, the calibration method of visible light cameras cannot be used.
[0004] In order to realize the attitude angle calibration of the infrared camera, the Chinese invention patent application with publication number CN112241007A discloses a calibration method, which collects the point cloud data of the laser radar and the image data of the camera in the same scene, matches the edge points, fits the ground plane equation based on the point cloud data of the laser radar, takes the flatness of the ground as the optimization target, and uses the gradient descent method to solve the optimal solution of the roll angle and pitch angle of the laser radar relative to the carrier as the optimization parameters, and then obtains the attitude angle of the camera according to the edge point matching results. This method requires the use of the point cloud data of the laser radar for calculation, involves multi-sensor fusion and matching, and the process is relatively complicated. In addition, the Chinese invention patent application with publication number CN109685858A also discloses an online calibration method for the attitude angle of the camera. During the driving process of the vehicle, the lane line of the road is detected, and the vanishing point position is calculated using the random gradient descent algorithm. According to the vanishing point position and the main point position of the camera internal parameter, the pitch angle of the camera is calculated. The vanishing point position can only be used to calculate the two attitude angles of the camera, the pitch angle and the yaw angle, but the roll angle of the camera cannot be calculated, and the complete attitude parameters cannot be obtained. Summary of the invention
[0005] In order to solve the existing technical problems, the present application provides a parameter calibration method, device and storage medium for an image capture device that is simple to operate and easy to implement.
[0006] A parameter calibration method for an image capturing device, comprising:
[0007] Acquire an imaging network model of the image capturing device by modeling an imaging process of the image capturing device;
[0008] Acquire the first coordinate of the input point set located on the target object in a preset distribution relationship in the world coordinate system to obtain the input point set data;
[0009] Based on the preset distribution relationship of the input point set in the world coordinate system, determine the constraints of the output point set of the imaging network model on the sample image, and construct the loss function of the imaging network model according to the constraints, wherein the sample image is an image containing the target object captured by the image capture device;
[0010] The input point set data is input into the imaging network model, and the imaging network model is trained according to the loss function and the pixel information of the target object in the sample image, until the training is completed when the loss function converges, and the parameters of the image capture device are determined according to the parameters of the trained imaging network model.
[0011] A parameter calibration device for an image capturing device, comprising a memory and a processor;
[0012] When the processor runs the computer program instructions stored in the memory, the processor executes the steps of the parameter calibration method.
[0013] A computer-readable storage medium storing computer program instructions;
[0014] When the computer program instructions are executed by a processor, the steps of the parameter calibration method are implemented.
[0015] As can be seen from the above, in the parameter calibration method of the image capture device provided in the present application, by obtaining the network imaging model of the image capture device, and taking the first coordinate of the input point set located on the target object in a preset distribution relationship in the world coordinate system as the input data of the imaging network model, and determining the constraint relationship that the output point set of the imaging network model needs to satisfy based on the preset distribution relationship of the input point set, so as to construct the loss function of the imaging network model according to the constraint relationship, the computational amount of the imaging network model during the training process is effectively reduced, and the entire parameter calibration process is simple and easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0017] Figure 1A schematic diagram of a flow chart of a parameter calibration method for an image capture device provided in accordance with some embodiments of the present application;
[0018] Figure 2 A schematic diagram of a pixel coordinate system corresponding to a network imaging model in a parameter calibration method for an image capture device provided in some embodiments of the present application;
[0019] Figure 3 A schematic diagram of an image coordinate system corresponding to a network imaging model in a parameter calibration method for an image capture device provided in some embodiments of the present application;
[0020] Figure 4 A schematic diagram of a camera coordinate system corresponding to a network imaging model in a parameter calibration method for an image capture device provided in some embodiments of the present application;
[0021] Figure 5 A schematic diagram of a camera coordinate system corresponding to a network imaging model in a parameter calibration method for an image capture device provided in some embodiments of the present application;
[0022] Figure 6 A schematic diagram of a calibration effect of a parameter calibration method for an image capture device provided in some embodiments of the present application;
[0023] Figure 7 A schematic diagram of the structure of a parameter labeling device of an image capturing device provided according to some embodiments of the present application;
[0024] Figure 8 A schematic diagram of the structure of a parameter calibration device for an image capture device provided in accordance with some embodiments of the present application;
[0025] Fig. 9 A schematic diagram of the structure of a vehicle-mounted infrared night vision system for determining parameters using the parameter calibration method for an image capture device provided in some embodiments of the present application. DETAILED DESCRIPTION
[0026] The technical solution of the present application is further elaborated in detail below in conjunction with the accompanying drawings and specific embodiments of the specification.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the implementation of the present application. The term "and / or" used herein includes any and all combinations of one or more related listed items. In the description of the present application, unless otherwise stated, the meaning of "multiple" is two or more.
[0028] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0029] Figure 1 The present invention provides a method for calibrating parameters of an image capture device according to some embodiments of the present invention. The method includes S02, S04, S06 and S08. Figure 7 The parameter calibration device shown or Figure 8 The parameter calibration equipment shown is implemented.
[0030] S02: Acquire an imaging network model of the image capturing device.
[0031] S02 can be Figure 7 The first acquisition module 11 in the parameter calibration device shown is implemented or composed of Figure 8 The memory 21 in the memory stores the first acquisition computer program, which is then implemented by the processor 22 when executing the first acquisition calculation program. The imaging network model is a model obtained by modeling the imaging process of the image capture device, which includes establishing a pixel coordinate system, an image coordinate system, a camera coordinate system and a world coordinate system, and determining the conversion relationship between each coordinate system. Based on the imaging process of the image capture device, the input of the imaging network model is the world coordinate of the point in the world coordinate system, and the output is the coordinate corresponding to the point in the pixel coordinate system. The world coordinate of the input point is converted to the camera coordinate, then converted to the image coordinate, and finally converted to the pixel coordinate in the imaging network model.
[0032] like Figure 2 As shown in the figure, a schematic diagram of the pixel coordinate system corresponding to the imaging network model is shown. The pixel coordinate system is a direct coordinate system uv established with the upper left corner of the image (the image captured by the image capture device) as the origin and with pixels as the unit. The horizontal coordinate u and the vertical coordinate v of the pixel are the column number and the row number in the image array, respectively. The pixel value is used to describe the position of the target on the image. The pixel value refers to the coordinate (u, v) obtained by taking the upper left corner pixel point as the origin (0,0), along the width direction as the u direction, and the height direction as the v direction, with each pixel point as a unit.
[0033] Pixel coordinates are the positions of pixels in an image. They only represent the number of columns and rows of pixels. The positions of pixels in an image are not expressed in physical units. Therefore, we also need to establish an image coordinate system xy expressed in physical units (such as millimeters). Figure 3 As shown in Figure 1, it is a schematic diagram of the image coordinate system corresponding to the imaging network model. The image coordinate system is used to represent the physical position of the target on the photosensitive device. The origin of the pixel coordinate system is translated to the principal point of the image, that is, the intersection of the lens optical axis of the image capture device and the photosensitive device, which is defined as the origin of the image coordinate system (0,0). The x-axis of the image coordinate system is parallel to the u-axis of the pixel coordinate system and has the same direction, while the y-axis is parallel to the v-axis and has the same direction.
[0034] Further Figure 4 As shown, it is a schematic diagram of the camera coordinate system corresponding to the imaging network model. The camera coordinate system takes the optical axis of the lens of the image capture device as the Zc axis, the center of the lens as the origin Oc, the horizontal axis Xc of the camera coordinate system is parallel to the x-axis of the image coordinate system and has the same direction, and the vertical axis Yc of the camera coordinate system is parallel to the y-axis of the image coordinate system and has the same direction. The distance between the origin Oc of the camera coordinate system and the origin o of the image coordinate system is equal to the focal length F of the image capture device.
[0035] The world coordinate system describes the position of the target in the real world, and the three axes Xw, Yw, and Zw of the world coordinate system are not parallel to the coordinate axes of any other coordinate system, and there will be a certain translation and angle. Therefore, the world coordinate system is one of the information that needs to be determined in the process of building an imaging network model. The world coordinate system determined according to an embodiment of the present application is as follows: Figure 5 As shown, it will be described in detail later. The transformation process from the world coordinate system to the camera coordinate system is divided into rotation and translation. Rotation refers to the rotation angle around the three axes of the coordinate axis. Among them, the rotation angle around the Xw axis is the pitch angle, the rotation angle around the Yw axis is the yaw angle, and the rotation angle around the Zw axis is the roll angle. Translation is the translation of the origin Oc along these three axes. In some embodiments of the present application, the image capture device is an infrared image capture device, such as an infrared camera, and in other embodiments, the image capture device may also be a visible light image capture device.
[0036] S04: Acquire the first coordinate of the input point set that is located on the target object in a preset distribution relationship in the world coordinate system to obtain input point set data.
[0037] S04 can be Figure 7 The second acquisition module 12 in the parameter calibration device shown is implemented or composed of Figure 8The memory 21 in the image capture device stores the second acquisition computer program, which is then implemented by the processor 22 when executing the second acquisition calculation program. The input of the imaging network model is the world coordinate in the world coordinate system, and its output is the pixel coordinate in the corresponding pixel coordinate system. The pixel position calculated by the imaging network model is compared with the pixel position corresponding to the real image. If the calculated pixel position is closer to the real pixel position, it means that the parameters of the imaging network model are closer to the actual parameters, then the attitude angle of the image capture device can be calculated: pitch, yaw and roll. However, if all the pixels on the image are to be matched one by one, not only the amount of calculation is huge, but also it is not easy to operate and implement, and it does not meet the convenience requirements of the calibration process. Therefore, in this application, the input data of the imaging network model is designed, that is, the first coordinate of the input point set located on the target object in the world coordinate system with a preset distribution relationship is selected as the input point set data, so as to serve as the input data of the imaging network model, so as to follow up and determine the constraint relationship of the output point set of the imaging network model according to the preset distribution relationship of the input point set, thereby designing a loss function that simplifies the training calculation amount. It should be noted that the target object refers to an object within the shooting angle of the image capture device, and the position of the object in the world coordinates is a straight line or curve that can be represented by a function, such as the object is a parallel line, a cross line, and a hyperbola within the shooting angle of view. For a vehicle-mounted image capture device, the target object may refer to an edge line, a lane line, or other marking line that can be represented by a function on the road surface on which the vehicle is traveling. The preset distribution relationship refers to the position relationship between the position of the fitting line of the input point set in the world coordinates and the target object as a determined position relationship, such as the fitting line and the target object are in a parallel setting relationship with a preset spacing or the fitting line and the target object are in an overlapping setting relationship. For example, in some embodiments, when the target object is a parallel line (such as a lane line), the preset distribution relationship refers to the input point set being distributed along the parallel line or along a line that is parallel to the parallel line at a preset spacing. In order to simplify the algorithm complexity in the parameter calibration method, in some embodiments, the target object is selected as a parallel line, and the preset distribution relationship is that the input point set is distributed along the parallel line in the world coordinate system.
[0038] In addition, the input point set can be a series of virtual points generated based on the position information of the target object in the world coordinate system (the position information can be represented by a function), or it can be calibration points calibrated on the parallel lines, and the calibration points are real points in the world coordinate system.
[0039] S06: Determine the constraints of the output point set of the imaging network model on the sample image containing the target object captured by the image capturing device based on the preset distribution relationship of the input point set in the world coordinate system, and construct the loss function of the imaging network model according to the constraints.
[0040] S06 can be Figure 7 The loss function construction module 13 in the parameter calibration device shown in FIG. Figure 8 The memory 21 in the memory stores the loss function construction computer program, which is then implemented by the processor 22 when executing the loss function construction calculation program. Since the input point set has a preset distribution relationship on the target object in the world coordinate system, the result after the imaging network model training optimization should be that the output point set has a certain distribution relationship on the target object in the sample image, and the certain distribution relationship is determined by the preset distribution relationship. Among them, the sample image is an image containing the target object captured by the image capture device. Therefore, the constraints of the output point set can be determined according to the preset distribution relationship of the input points, and the loss function can be constructed according to the constraints, so that the trained output point set has a distribution relationship on the target object in the sample image that is consistent with the above-mentioned preset distribution relationship. Based on the loss function constructed based on the constraint relationship, in the process of training the imaging network model, there is no need to make a one-to-one correspondence between the output point set and all the pixel points on the sample image, which effectively reduces the amount of calculation.
[0041] S08: Input the input point set data into the imaging network model, and train the imaging network model according to the loss function and the pixel information of the target object in the sample image, until the training is completed when the loss function converges, and determine the parameters of the image capture device according to the parameters of the trained imaging network model.
[0042] S08 can be Figure 7 The training module 14 in the parameter calibration device shown is implemented or composed of Figure 8 The memory 21 in the memory stores the model training computer program, which is then implemented by the processor 22 when executing the model training computer program.
[0043] The process of training the imaging network model is the process of updating and optimizing the parameters of the imaging network model. Therefore, after the training is completed, the parameters of the imaging network model have been determined, and the parameters of the image capture device have also been determined, thereby realizing the parameter calibration of the image capture device.
[0044] During the above training process, the pixel information of the target object in the sample image is obtained to determine the true value pixel information of the input point set on the sample image based on the pixel information. Therefore, the loss function calculates the loss value based on the pixel information and the value of the output point set until the loss value converges, indicating that the loss function converges and the training is stopped.
[0045] The parameters of the image capture device include internal parameters and external parameters. Generally, the internal parameters are fixed at the factory. In practical applications, external parameter calibration is more often performed. The internal parameters are known fixed parameters of the imaging network model, while the external parameters are parameters updated during the training of the imaging network model. Among them, the internal parameters of the image capture device are parameters related to the characteristics of the image capture device itself, such as the focal length, pixel size, position of the optical axis on the photosensitive element, and distortion coefficient of the image capture device. The external parameters of the image capture device are parameters in the world coordinate system, such as the position and rotation direction of the image capture device, which include a rotation matrix and a translation matrix. The translation matrix can be obtained by the positional relationship between the image capture device and the origin of the determined world coordinate system. Therefore, in the parameter calibration method of the image capture device provided in the present application, it is mainly used to calibrate the rotation angle parameters in the external parameters of the image capture device, that is, the attitude angle parameters of the image capture device. Therefore, in some embodiments, the internal parameters and the translation matrix in the imaging network model are set as fixed parameters, and during the training process, the rotation angle parameters are updated to determine the attitude angle of the image capture device.
[0046] As can be seen from the above, in the parameter calibration method of the image capture device provided in the present application, by acquiring the imaging network model of the image capture device, and taking the first coordinate of the input point set located on the target object in a preset distribution relationship in the world coordinate system as the input data of the imaging network model, and determining the constraint relationship that the output point set of the imaging network model needs to satisfy based on the preset distribution relationship of the input point set, so as to construct the loss function of the imaging network model according to the constraint relationship, the computational amount of the imaging network model during the training process is effectively reduced, and the entire parameter calibration process is simple and easy to implement.
[0047] In some embodiments, S02 specifically includes S021, S022, and S023, which are as follows:
[0048] S021: Acquire a first position of the image capturing device in the world coordinate system.
[0049] After the world coordinate system is determined, the first position of the image capture device in the world coordinate system can be obtained by obtaining the distance information from the projection of the three axes of the image capture device in the world coordinate system to the origin of the world coordinate system. It should be noted that the first position here is represented by the coordinate value of the image capture device in the world coordinate system. After the first position of the image capture device in the world coordinate system is determined, the translation matrix t can also be determined. The translation matrix t is expressed as follows:
[0050] [tx ty tz]
[0051] S022: Acquire the internal parameters of the image capture device.
[0052] The purpose of obtaining the internal parameters of the image capture device is to obtain the internal parameters of the image capture device: lens focal length F, pixel size dx×dy, position of the optical axis on the photosensitive element (i.e., principal point coordinates), and distortion coefficient. In some embodiments, the internal parameter matrix M and the distortion matrix K are calculated by the Zhang Zhengyou calibration method to obtain the internal parameters of the image capture device. The internal parameter matrix M and the distortion matrix K are expressed as follows:
[0053]
[0054] K=[k1 k2 k3 k4 k5]
[0055] Where fx = F / dx, fy = F / dy are the normalized focal lengths in the x-direction and y-direction respectively, cx and cy are the principal point coordinates of the image capture device, that is, the position of the optical axis on the photosensitive element. k1, k2, k3 are radial distortion coefficients, and k4 and k5 are tangential distortion coefficients.
[0056] S023: Model the imaging process of the image capturing device according to the first position of the image capturing device in the world coordinate system, the internal parameters, the first transformation relationship between the world coordinate system and the camera coordinate system, the second transformation relationship between the camera coordinate system and the image coordinate system, and the third transformation relationship between the image coordinate system and the pixel coordinate system to obtain an imaging network model.
[0057] Specifically, the imaging of the image capture device can be regarded as a point in the world coordinate system, which is projected to the pixel coordinate system after the transformation of the coordinate system. Assuming there is a point (Xw, Yw, Yw) in the world coordinate system, it is first transformed to the camera coordinate system to obtain the mapping point (Xc, Yc, Zc) in the camera coordinate system. The transformation process from the world coordinate system to the camera coordinate system is divided into rotation and translation. The rotation is to rotate around the three axes of the coordinate axis to obtain three rotation angles, which are the attitude angles of the image capture device. Among them, the rotation around the x-axis is the pitch angle, the rotation around the y-axis is the yaw angle, and the rotation around the z-axis is the roll angle. The translation is the translation amount t of the origin along the three axes. Then the above first conversion relationship is:
[0058]
[0059] Among them, in the first conversion relationship, R is called the rotation matrix, t is called the translation matrix, and the rotation matrix represents the relationship between the pitch angle, yaw angle, and roll angle around the three axes Xw, Yw, and Zw during the transformation from the camera coordinate system to the world coordinate system. The rotation matrix R is expressed as follows:
[0060]
[0061] Among them, C is the cosine function and S is the sin function.
[0062] Next, the camera coordinate system (Xc, Yc, Zc) is transformed into the image coordinate system (x, y, 1). According to the principle of lens imaging, the second transformation relationship is as follows:
[0063]
[0064] In actual situations, due to manufacturing errors in the lens of the image capture device, distortion will be introduced during the lens imaging process. The distortion is divided into radial distortion and tangential distortion. Radial distortion is because the light is bent more strongly at the edge of the lens than at the center of the lens, so the image will be more distorted the closer it is to the edge. Tangential distortion is caused by the fact that the lens itself is not parallel to the imaging plane during assembly. Therefore, in some embodiments, it is also necessary to construct a conversion relationship between the mapping point (x, y, 1) of the theoretical image coordinate system and the actual mapping point (x`, y`, 1), and the conversion relationship is as follows:
[0065] x`=x*(1+k1*r 2 +k2*r 4 +k3*r 6 )+2*k4*x*y+k5*(r 2 +x 2 )
[0066] y`=y*(1+k1*r 2 +k2*r 4 +k3*r 6 )+2*k5*x*y+k4*(r 2 +y 2 )
[0067]
[0068] Finally, the actual mapping point (x', y', 1) in the image coordinate system is transformed to the mapping point (u, v, 1) in the pixel coordinate system. Assuming that the origin of the image coordinate system is (u0, v0) in the pixel coordinate system, and the size of each pixel of the photoreceptor is dx×dy, the third conversion relationship is as follows:
[0069]
[0070] It can be seen from the acquisition process of the above-mentioned imaging network model that the internal parameters in the network imaging model have been determined and the translation matrix has also been determined. Therefore, in the subsequent training process of the imaging network model, the parameter that needs to be updated and optimized is the rotation matrix R. After the training is completed, the rotation matrix R can be determined, and the attitude angle parameters of the image capture device are also determined.
[0071] In order to further reduce the computational complexity of the network imaging model during the training process, in some embodiments, the target object in S04 is set as a pair of parallel lines. For example, for a vehicle-mounted image capture device, the pair of parallel lines may be lane lines on the road on which the vehicle is traveling. Therefore, S04 further includes S041 and S042.
[0072] S041: Determine a second position of a preset pair of parallel lines in the world coordinate system.
[0073] The second position here refers to the positions of the first straight line and the second straight line in the pair of parallel lines in the world coordinate system.
[0074] S042: Generate first coordinates of an input point set distributed along two straight lines of a pair of parallel lines in a world coordinate system according to the second position to obtain input point set data.
[0075] After the positions of a pair of parallel lines in the world coordinate system are determined, multiple virtual points Pl and Pr can be generated based on their position information. These virtual points Pl and Pr are respectively distributed along the first straight line and the second straight line of a pair of parallel lines. These virtual point sets are used as the input point sets of the imaging network model, and their first coordinates in the world coordinate system are used as the input point set data of the network imaging model.
[0076] Furthermore, S041 includes S0411 and S0412, which are as follows:
[0077] S041: Obtain a first distance between a pair of parallel lines in the world coordinate system.
[0078] S042: Determine the second position of the pair of parallel lines in the world coordinate system based on the first distance, the first preset relationship between the pair of parallel lines and the origin of the world coordinate system, and the second preset relationship between the pair of parallel lines and each coordinate axis of the world coordinate system.
[0079] In some embodiments, for the convenience of calculation, the relationship between the above-mentioned pair of parallel lines and the origin of the world coordinate system is set so that the origin of the coordinate system is set on the midline between the first straight line and the second straight line of the pair of parallel lines, and the pair of parallel lines are set parallel to the Zw axis of the world coordinate system, and the parallel lines are located in the plane where the Zx axis and the Zw axis of the world coordinate system are located. After determining the above-mentioned relationship, the positions of the first straight line and the second straight line in a pair of parallel lines can be determined according to the above-mentioned first distance, and the coordinates of the points on them can be determined according to the positions of the two straight lines, so that these virtual point sets can be generated.
[0080] In some embodiments, S06 includes: obtaining a third position of a pair of parallel lines in a sample image, where the sample image is an image captured by an image capturing device and contains the pair of parallel lines, and using the third position as a distribution constraint on the output point set of the imaging network model on the sample image.
[0081] Specifically, the sample image can be displayed by image display software, and then corresponding points can be selected at the positions of a pair of parallel lines in the displayed sample image, and the pixel coordinates of the corresponding points can be displayed, and the third position can be determined according to the pixel coordinates of the corresponding points. The sample image can also be directly input into an image recognition model, and the positions of a pair of parallel lines in the sample image can be identified by the image recognition model to obtain the third position.
[0082] In some embodiments, in order to further improve the optimization effect of the imaging network model, in addition to constraining the distribution of the output point set of the imaging network model, it is also necessary to constrain its distance, then S06 further includes: obtaining a second distance between a pair of parallel lines in the sample image, and using the second distance as a distance constraint between the first output point and the second output point in the output point set on the sample image. The distance between the first input point corresponding to the first output point and the second input point corresponding to the second output point in the world coordinate system is the first distance between the pair of parallel lines in the world coordinate system.
[0083] After determining the constraints of the output point set, it is necessary to determine the loss function of the imaging network model according to the corresponding constraints. S06 further includes: constructing a distribution loss function according to the distribution constraints, constructing a distance loss function according to the distance constraints, and then weighting the distribution loss function and the distance loss function to obtain the loss function of the imaging network model.
[0084] In some embodiments, the step of obtaining the third position of the pair of parallel lines in the sample image specifically includes: obtaining at least two first pixel coordinates on the first straight line of a pair of parallel lines in the captured image, and obtaining at least two second pixel coordinates on the second straight line of a pair of parallel lines in the sample image; determining the first straight line position of the first straight line in the sample image according to the at least two first pixel coordinates, and determining the second straight line position of the second straight line in the sample image according to the at least two second pixel coordinates. Then using the third position as the distribution constraint of the output point set in the pixel coordinate system specifically includes: using the first straight line position as the distribution constraint of the first group of output point sets corresponding to the first group of input point sets distributed along the first straight line in the pixel coordinate system, and using the second straight line position as the distribution constraint of the second group of output point sets corresponding to the second group of input point sets distributed along the second straight line in the pixel coordinate system. The first input point mentioned above is a point in the first group of input point sets here, and the second input point mentioned above is a corresponding point in the second group of input point sets here.
[0085] Specifically, two first pixel point coordinates (lx1, ly1) and (lx2, ly2) are obtained on the first straight line of a pair of parallel lines in the sample image, and the first straight line position Ll of the first straight line in the sample image can be determined by these two points. Similarly, two second pixel point coordinates (rx1, ry1) and (rx2, ry2) are obtained on the second straight line of a pair of parallel lines in the sample image, and the second straight line position Lr of the second straight line in the sample image can be determined by these two points. After the imaging network model is trained by the constructed loss function, each output point set should be distributed along the corresponding first straight line position Ll and second straight line position Lr. It should be noted here that when determining the first straight line position and the second straight line position, the number of rows of pixels occupied by a pair of parallel lines in the sample image can be further obtained to determine the endpoints of the first straight line position and the second straight line position.
[0086] Further, in some embodiments, constructing a distribution loss function according to the distribution constraint includes: performing straight line fitting on each point IP1 in the first output point set and each point IPr in the second output point set to obtain a first distribution position Ll_pre and a second distribution position Lr_pre; constructing an average distance function from each point on the first straight line position Ll to the first distribution position Ll_pre as the first distribution loss function loss L , and construct an average distance function from each point on the second straight line position Lr to the first distribution position Lr_pre to serve as the second distribution loss function loss R ; Then the first distribution loss function loss L And the second distribution loss function loss R Superposition is performed to obtain the above distribution loss function.
[0087] Further, constructing a distance loss function according to the distance constraint includes: calculating the Euclidean distance d between the first output point IPl1 (xl, yl) and the corresponding second output point IPr2 (xr, yr) in the pixel coordinate system xy ; Reconstruct the above second distance d p and the Euclidean distance d xy The difference function of is used as the distance loss function.
[0088] Specifically, the first distribution loss function is:
[0089]
[0090] The second distribution loss function is:
[0091]
[0092] The above distance loss function is:
[0093]
[0094] Among them, the loss R is the representation of the second distribution loss function, y0 is the row number corresponding to the coordinates of each pixel point on the first straight line position and the second straight line position, L1 is the function representation corresponding to the first straight line position, and D L represents the distance between the pixel point corresponding to y0 and the first distribution position, and D R represents the distance between the pixel point corresponding to y0 and the second distribution position, N is a natural number greater than zero, and d p is the second distance, the d xy represents the Euclidean distance between the first output point and the second output point.
[0095] Combining the above losses, the loss function loss of the imaging network model constructed in S04 is expressed as follows:
[0096]
[0097] Among them, in the above loss function loss, λ is a hyperparameter.
[0098] S08: Input the input point set data into the imaging network model, and train the imaging network model according to the loss function and the pixel information of the target object in the sample image, until the training is completed when the loss function converges, and determine the parameters of the image capture device according to the parameters of the trained imaging network model.
[0099] In some embodiments, S08 further includes:
[0100] S081: inputting the input point set data into the imaging network model for forward transmission to obtain output point set data;
[0101] S082: Input the output point set data and the pixel information of the target object in the sample image into the loss function to calculate the loss, and perform reverse transmission.
[0102] The pixel information may be obtained, but is not limited to, by performing feature recognition on the sample image.
[0103] S083: During the reverse transmission process, the parameters of the imaging network model are updated based on a stochastic gradient descent algorithm until the loss function converges and the training is stopped.
[0104] S084: Determine the parameters of the image capturing device according to the trained parameters of the imaging network model.
[0105] In addition, in order to more intuitively see the effect of the parameter calibration method provided by the present application, in some embodiments, the parameter calibration method provided by the present application further includes fusing the output point set of the imaging network model with the sample image to obtain the sample image carrying the output point set. Figure 6 As shown, the output point set (small white triangles) are distributed along a pair of parallel lines (lane lines) in the sample image. Specifically, the output point set of the imaging network model and the sample image can be input into the fusion model, so that the fusion model can be used to calibrate the position on the sample image corresponding to the output point set of the imaging network model to obtain the sample image carrying the output point set.
[0106] In some embodiments, the present application also provides a parameter calibration device for an image capture device, specifically, Figure 7 As shown, it includes the first acquisition module 11, the second acquisition module 12, the loss function construction module 13 and the training module 14 described above.
[0107] In addition, in some embodiments, the present application also provides a parameter calibration device for an image capture device, specifically, Figure 8 As shown, it includes a memory 21 and a processor 22, wherein the processor 22 executes the steps of the parameter calibration method provided in any embodiment of the present application when running the computer program instructions stored in the memory 21.
[0108] In addition, in some embodiments, the present application also provides a computer-readable storage medium, which stores computer program instructions. When the computer program instructions are executed by a processor, the steps of the parameter calibration method provided in any embodiment of the present application are implemented.
[0109] Fig. 9 The invention illustrates a vehicle-mounted infrared night vision system that uses the parameter calibration method provided by the present application to update parameters, which includes a vehicle-mounted infrared camera and an ECU (Electronic Control Unit) processing unit. The ECU processing unit is provided with an intelligent algorithm module, which updates parameters according to the parameter calibration method provided by the present application to realize functions such as display of infrared images collected by the vehicle-mounted infrared camera, target recognition, target tracking, and target ranging. In addition, the vehicle-mounted infrared night vision system further includes a vehicle CAN bus, a vehicle power supply system, and a vehicle display screen connected to the ECU processing unit. In addition, the ECU processing unit further includes a display module, a storage module, a control module, and a sensor module.
[0110] In order to further clearly describe the parameter calibration method of the image capture device provided by the present application, the present application also provides an embodiment, which is as follows:
[0111] In this embodiment, the image capturing device is a vehicle-mounted image capturing device, and the pair of parallel lines are two lane lines on the road surface on which the vehicle is traveling. In addition, in this embodiment, in order to further simplify the parameter calibration algorithm, the world coordinate system is determined as follows: Figure 5 As shown, the origin of the world coordinate system is the intersection of the middle line of the two lane lines (a pair of parallel lines) and the front plane of the carrier (vehicle) (the front of the vehicle in the driving direction), and the Xw axis is parallel to the horizontal direction of the carrier (the plane where the carrier is located), that is, the Xw axis and the Zw axis are in the same plane as the road surface; the Yw axis is perpendicular to the road surface, the direction of the Xw axis is to the right, the direction of the Yw axis is upward, and the Zw direction is parallel to the lane line and forward.
[0112] The imaging network model obtained in this embodiment is an imaging network model built based on pytorch. The imaging network model can calculate the input point set and output the pixel position of the point set on the image. The pixel position calculated by the network is compared with the pixel position of the real image. If the calculated pixel position is closer to the real pixel position, it means that the parameters of the network are closer to the actual parameters, then the required attitude angles can be calculated: pitch, yaw and roll. However, if all the pixels on the image are to be matched one by one, not only the amount of calculation is huge and it is not easy to operate and implement, it does not meet the convenience requirements of the calibration process. Therefore, in some embodiments, the data preparation process required for the imaging network model is as follows:
[0113] (1) Prepare a pair of parallel lines (lane lines) in the real world. Generally, lane lines can be used to measure the distance L between the two parallel lines.
[0114] (2) Install and fix the image capture device on the carrier, and park the carrier parallel to the parallel lines. Measure the distances lx and rx from the front ends of the carrier to the two parallel lines. Measure the installation height Yt from the center of the image capture device lens to the ground, and the horizontal distance Xt from the center of the image capture device lens to the middle of the carrier.
[0115] (3) An image capturing device is used to capture an image of the pair of parallel lines at the installation position as a sample image, and then two pixel points are obtained on each straight line of the pair of parallel lines on the sample image, and the pixel coordinates of the four points are obtained: (lx1, ly1), (lx2, ly2), (rx1, ry1), and (rx2, ry2).
[0116] (4) Use Zhang Zhengyou calibration method to obtain the internal parameters of the image capture device.
[0117] When constructing an imaging network model, it is necessary to obtain the data obtained in (1), (2), (3), and (4) above, and then generate a series of virtual points Pl and Pr in the world coordinate system according to the parallel line spacing L. These points are distributed along two parallel lines in the world coordinate system, Pl along the line on the left, and Pr along the line on the right. The coordinates of the points are (±L / 2,0,Dis), where Dis is an arbitrary distance, the sign before L in Pl is -, and the sign before L in Pr is +. And according to the relevant ranging data of the image capture device, the first position of the image capture device in the world coordinate system is obtained to determine the position of the translation matrix. According to the translation matrix and the internal parameters, the conversion relationship of each coordinate system is combined and the imaging network model with the rotation angle as the training update parameter can be constructed.
[0118] To update the parameters of the network, it is necessary to compare the output of the network with the true value, calculate the loss, and reverse the loss, derive each parameter that needs to be updated, and then update the parameters of the model based on the stochastic gradient descent method. In this application, the output of the network is some points, but it is not easy to obtain the true values corresponding to these points, so the loss cannot be calculated directly based on the point set. Because these virtual point sets are distributed along parallel lines when they are selected, they should also be distributed along parallel lines after being calculated by the imaging network model, and the position of parallel lines on the image is easy to obtain. You only need to obtain two points on the parallel lines, such as the points on the left parallel line (the first straight line mentioned above): (lx1, ly1), (lx2, ly2), and you can find the linear equation LI (the position of the first straight line mentioned above) of the left parallel line on the image:
[0119] y=k1*x+b1
[0120] in:
[0121] k1=(ly2-ly1) / (lx2-lx1)b1=ly2-k1*lx2
[0122] Similarly, the linear equation Lr (the position of the second straight line mentioned above) of the right parallel line on the image can also be obtained based on the two points (rx1, ry1) and (rx2, ry2) on the right parallel line (the second straight line mentioned above):
[0123] y=kr*x+br
[0124] Therefore, as long as the point sets lpI and lpr output by the network are distributed along the two straight lines L1 and Lr respectively, a loss function can be established to calculate the loss.
[0125] In order to ensure the integrity of the point set distribution, first use the least squares method to fit the left point set lpl and the right point set lpr to get the straight line LI_pre (the first distribution position) and Lr_pre (the second distribution position). For the parallel lines on the left, the formula of the loss function lossL is:
[0126]
[0127] Where height is the height of the sample image, loss L The function indicates that N rows are randomly selected from the lower half of the sample image (the lower half is where the parallel lines are located. We can also use intelligent algorithms to identify the locations of parallel lines from the image and randomly select N rows where the parallel lines are located). The coordinates y0 of these rows are brought into the line LI to calculate the corresponding x0 and obtain the point (x0, y0). L Indicates the distance from the calculated point (x0, y0) to LI_pre (the distance from the point on L1 to L1pre is the smallest). Similarly, the same method is used to calculate the loss function loss for the parallel lines on the right. R :
[0128]
[0129] In addition to the point set distribution constraints, there are also point set distance constraints that can be used. When generating virtual point sets Pl and Pr, for the same Dis, the corresponding points on the left parallel line (-L / 2,0,Dis) and the points on the right parallel line (L / 2,0,Dis) are generated respectively. The distance between these two points in the world coordinate system is the distance L of the parallel lines. After transformation to the pixel coordinate system, the distance between the two points d p for:
[0130]
[0131] When the two points (-L / 2,0,Dis) and (L / 2,0,Dis) in the virtual point set are calculated by the network, the virtual pixels (xl, yl) and (xr, yr) on the image are obtained. The loss of the point set distance is d It is expressed as:
[0132]
[0133] Among them, d xy Represents the Euclidean distance between virtual pixel points (xl, yl) and (xr, yr).
[0134] Combining the above losses, we can obtain the final loss function loss of the imaging network model:
[0135]
[0136] According to the parameter calibration method of the image capture device provided in this application, after the imaging network model is processed 500 times, the output point set is very consistent with the lane line of the sample image. The specific effect is as follows: Figure 6 shown.
[0137] In summary, the parameter calibration method of the image capture device provided in this application can achieve the following effects in different embodiments:
[0138] 1. It can calibrate the external parameters of the image capture device to increase driving safety at night and in bad weather.
[0139] 2. This application builds an imaging network model based on pytorch, which can observe the training effect and evaluate the calibration effect.
[0140] 3. The calibration method designed in this application is simple to operate and can obtain complete attitude information without the help of other instruments.
[0141] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A parameter calibration method for an image capture device, characterized in that: include: Acquire an imaging network model of the image capturing device by modeling an imaging process of the image capturing device; The method of obtaining an imaging network model of the image capturing device by modeling the imaging process of the image capturing device includes: obtaining a first position of the image capturing device in a world coordinate system; obtaining an internal parameter of the image capturing device; and modeling the imaging process of the image capturing device according to the first position, the internal parameter, a first conversion relationship between the world coordinate system and the camera coordinate system, a second conversion relationship between the camera coordinate system and the image coordinate system, and a third conversion relationship between the image coordinate system and the pixel coordinate system to obtain the imaging network model. Acquire the first coordinate of the input point set located on the target object in a preset distribution relationship in the world coordinate system to obtain the input point set data; Based on the preset distribution relationship of the input point set in the world coordinate system, determine the constraints of the output point set of the imaging network model on the sample image, and construct the loss function of the imaging network model according to the constraints, wherein the sample image is an image containing the target object captured by the image capture device; The input point set data is input into the imaging network model, and the imaging network model is trained according to the loss function and the pixel information of the target object in the sample image, until the training is completed when the loss function converges, and the parameters of the image capture device are determined according to the parameters of the trained imaging network model.
2. The parameter calibration method according to claim 1, characterized in that: The step of acquiring first coordinates of an input point set located on the target object in a preset distribution relationship in a world coordinate system to obtain an input point set data set includes: Determining a second position of a preset pair of parallel lines in the world coordinate system; According to the second position, first coordinates of an input point set distributed along two straight lines of the pair of parallel lines in the world coordinate system are generated to obtain input point set data.
3. The parameter calibration method according to claim 2, characterized in that: The step of determining a second position of a preset pair of parallel lines in the world coordinate system includes: Acquire a first distance between the pair of parallel lines in the world coordinate system; The second position of the pair of parallel lines in the world coordinate system is determined according to the first distance, the first preset relationship between the pair of parallel lines and the origin of the world coordinate system, and the second preset relationship between the pair of parallel lines and each coordinate axis of the world coordinate system.
4. The parameter calibration method according to claim 3, characterized in that: The determining, based on the preset distribution relationship of the input point set in the world coordinate system, the constraint of the output point set of the imaging network model on the sample image comprises: Acquire a third position of the pair of parallel lines in the sample image, where the sample image is an image captured by the image capturing device and containing the pair of parallel lines; The third position is used as a distribution constraint of the output point set on the sample image.
5. The parameter calibration method according to claim 4, characterized in that: The determining of the constraints of the output point set of the imaging network model on the sample image containing the target object acquired by the image capturing device based on the preset distribution relationship of the input point set in the world coordinate system also includes: Acquire a second distance between the pair of parallel lines in the sample image; The second distance is used as a distance constraint between a first output point and a second output point in the output point set on the sample image, and a distance between a first input point corresponding to the first output point and a second input point corresponding to the second output point in the world coordinate system is the first distance.
6. The parameter calibration method according to claim 5, characterized in that: The loss function of the imaging network model is constructed according to the constraint, comprising: constructing a distribution loss function according to the distribution constraint; constructing a distance loss function according to the distance constraint; The distribution loss function and the distance loss function are weighted to obtain the loss function of the imaging network model.
7. The parameter calibration method according to claim 6, characterized in that: Obtaining a third position of the pair of parallel lines in the sample image includes: Acquire coordinates of at least two first pixel points on a first straight line of the pair of parallel lines in the sample image, and acquire coordinates of at least two second pixel points on a second straight line of the pair of parallel lines in the sample image; A first straight line position of the first straight line in the sample image is determined according to at least two first pixel point coordinates, and a second straight line position of the second straight line in the sample image is determined according to at least two second pixel point coordinates.
8. The parameter calibration method according to claim 7, characterized in that: The using the third position as a distribution constraint of the output point set on the sample image comprises: The first straight line position is used as a distribution constraint in the pixel coordinate system for a first set of output points corresponding to a first set of input points distributed along the first straight line, and the second straight line position is used as a distribution constraint in the pixel coordinate system for a second set of output points corresponding to a second set of input points distributed along the second straight line; The first input point is a point in the first set of input points, and the second input point is a corresponding point in the second set of input points.
9. The parameter calibration method according to claim 8, characterized in that: Constructing a distribution loss function according to the distribution constraint includes: Perform straight line fitting on each point in the first output point set and each point in the second output point set to obtain a first distribution position and a second distribution position; Constructing an average distance function from each point on the first straight line position to the first distribution position as a first distribution loss function, and constructing an average distance function from each point on the second straight line position to the second distribution position as a second distribution loss function; superimposing the first distribution loss function and the second distribution loss function to obtain the distribution loss function; and / or, Constructing the distance loss function according to the distance constraint includes: Calculate the Euclidean distance between the first output point and the corresponding second output point in the pixel coordinate system; A difference function between the second distance and the Euclidean distance is constructed to serve as the distance loss function.
10. The parameter calibration method according to claim 1, wherein the input point set data is input into the imaging network model, and the imaging network model is trained according to the loss function and the pixel information of the target object in the sample image, until the training is completed when the loss function converges, and the parameters of the image capture device are determined according to the parameters of the trained imaging network model, comprising: Inputting the input point set data into the imaging network model for forward transmission to output the output point set data corresponding to the output point set; Calculate the loss of the output point set data and the pixel information of the target object in the sample image according to the loss function, and perform reverse transmission; During the reverse transmission process, the parameters of the imaging network model are updated based on a stochastic gradient descent algorithm until the training is stopped when the loss function converges; The parameters of the image capturing device are determined according to the trained parameters of the imaging network model.
11. A parameter calibration device for an image capturing device, characterized in that: including memory and processor; When the processor runs the computer program instructions stored in the memory, it executes the steps of the parameter calibration method described in any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: The computer readable storage medium stores computer program instructions; When the computer program instructions are executed by a processor, the steps of the parameter calibration method described in any one of claims 1 to 10 are implemented.
