CN116524041A - Camera calibration method, device, equipment and medium - Google Patents

Camera calibration method, device, equipment and medium Download PDF

Info

Publication number
CN116524041A
CN116524041A CN202310423310.3A CN202310423310A CN116524041A CN 116524041 A CN116524041 A CN 116524041A CN 202310423310 A CN202310423310 A CN 202310423310A CN 116524041 A CN116524041 A CN 116524041A
Authority
CN
China
Prior art keywords
calibration
camera
pixel coordinate
target
pixel
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.)
Pending
Application number
CN202310423310.3A
Other languages
Chinese (zh)
Inventor
李倩
李庆峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Navinfo Co Ltd
Original Assignee
Navinfo Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Navinfo Co Ltd filed Critical Navinfo Co Ltd
Priority to CN202310423310.3A priority Critical patent/CN116524041A/en
Publication of CN116524041A publication Critical patent/CN116524041A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/80Analysis 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)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The embodiment of the specification discloses a camera calibration method, device, equipment and medium. Comprising the following steps: and acquiring a calibration image acquired by the camera aiming at the calibration object. Wherein, the target two-dimensional code pattern is drawn in the calibration object. And carrying out two-dimensional code identification processing on the calibration image to obtain a first pixel coordinate set aiming at each target vertex under a preset pixel coordinate system. And determining world coordinates of all target vertexes on the calibration object by using a preset world coordinate system to obtain a world coordinate set. And completing the calibration of the camera according to the first pixel coordinate set and the world coordinate set. The scheme can simplify the camera calibration flow, is convenient for realizing the camera calibration of the industrial assembly line, and can improve the simplicity of calibrating the cameras in batches.

Description

Camera calibration method, device, equipment and medium
Technical Field
The present disclosure relates to the field of camera calibration technologies, and in particular, to a method, an apparatus, a device, and a medium for calibrating a camera.
Background
In the existing camera calibration method, the used calibration image needs to contain a calibration pattern with a preset rule. If the calibration image is collected for the calibration object, the brightness of the shot light and the angle of the calibration object are affected, so that the calibration image which does not meet the preset requirement is inevitably present in the shot calibration image. Therefore, in order to acquire qualified calibration images, when the calibration images are acquired for calibration objects, a plurality of calibration images are acquired under the pose state of each camera, and then the qualified calibration images are selected from the plurality of shot calibration images in a manual screening mode. If the captured calibration images are not screened, a sample of poor imaging quality may be introduced. Therefore, in the existing camera calibration method, the camera calibration process is long in time consumption, the process is complicated, industrial assembly line operation is difficult to realize, and the difficulty of calibrating the cameras in batches is high.
Based on the method, how to simplify the camera calibration flow, realize the industrial assembly line operation of camera calibration, so as to improve the simplicity of batch calibration of cameras, and become the technical problem to be solved urgently.
Disclosure of Invention
The embodiment of the specification provides a camera calibration method, device, equipment and medium, which are used for solving the technical problems that the process of calibrating cameras in the prior art is long in time consumption, complex in flow, difficult to realize industrial assembly line operation and difficult to calibrate the cameras in batches.
In order to solve the above technical problems, the embodiments of the present specification are implemented as follows:
the embodiment of the specification provides a camera calibration method, which comprises the following steps,
and acquiring a calibration image acquired by a camera aiming at a calibration object, wherein a target two-dimensional code pattern is drawn in the calibration object.
Processing the calibration image by using a two-dimensional code recognition algorithm to obtain a first pixel coordinate set under a preset pixel coordinate system; and the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image.
And determining world coordinates of each target vertex under a preset world coordinate system to obtain a world coordinate set.
And carrying out camera calibration processing according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera.
Preferably, the calibration image comprises a first calibration image and a second calibration image which are acquired for a calibration object under any two different poses, the calibration object comprises a first calibration plate and a second calibration plate, the first calibration plate and the second calibration plate are respectively provided with the target two-dimensional code pattern, and a preset included angle is formed between the first calibration plate and the second calibration plate.
Preferably, the camera calibration processing is performed according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera, including:
and determining a second pixel coordinate corresponding to the world coordinate of the target vertex in the world coordinate set under the preset pixel coordinate system by utilizing the conversion relation between the preset world coordinate system and the preset pixel coordinate system, so as to obtain a second pixel coordinate set.
And calibrating the camera by using a camera calibration algorithm according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera.
Preferably, the calibrating the camera according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera includes:
determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set; each pixel coordinate in each target pixel coordinate set is assigned to the same target vertex, and the target pixel coordinate set comprises a first pixel coordinate and a second pixel coordinate.
And constructing a least square problem according to each target pixel coordinate set.
And calibrating the camera according to the least square problem to obtain a calibration result of the camera.
Preferably, the determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set includes:
determining positioning information of the first pixel coordinates for any one of the first pixel coordinates in the first pixel coordinate set; the positioning information includes: the target calibration device comprises decoding information of a target two-dimensional code to which the first pixel coordinate belongs, position information of a target vertex corresponding to the first pixel coordinate in the target two-dimensional code and a target calibration plate to which the first pixel coordinate belongs, wherein the target calibration plate is the first calibration plate or the second calibration plate.
And determining the second pixel coordinate matched with the first pixel coordinate from the second pixel coordinate set according to the positioning information of the first pixel coordinate.
And generating a target pixel coordinate set according to the first pixel coordinate and the second pixel coordinate matched with the first pixel coordinate.
Preferably, the calibrating the camera according to the least square problem to obtain a calibration result of the camera includes:
and carrying out iterative optimization processing on the least square problem by using a nonlinear optimization algorithm to obtain a calculation result of the least square problem.
And judging whether the calculation result of the least square problem is smaller than or equal to a preset threshold value or not to obtain a judgment result.
And if the judging result shows that the calculating result of the least square problem is smaller than or equal to a preset threshold value, determining the camera parameter corresponding to the calculating result as a calibration result of the camera.
Preferably, the calibration result of the camera comprises a camera internal parameter calibration result and a camera distortion coefficient calibration result of the camera.
The calculation formula of the least square problem is as follows:
wherein: argmin represents a calculated minimum value, ui represents the first pixel coordinate, pi represents a world coordinate of the target vertex under the preset world coordinate system, K represents the camera distortion coefficient of the camera participating in the camera of the camera, T represents a camera external parameter of the camera, KTPi represents the second pixel coordinate, and i represents the number of the target vertices.
A camera calibration apparatus includes a camera module for calibrating a camera,
the first acquisition module is used for acquiring a calibration image acquired by the camera aiming at a calibration object, and a target two-dimensional code pattern is drawn in the calibration object.
The processing module is used for processing the calibration image by utilizing a two-dimensional code recognition algorithm to obtain a first pixel coordinate set under a preset pixel coordinate system; and the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image.
The determining module is used for determining world coordinates of each target vertex under a preset world coordinate system to obtain a world coordinate set.
And the calibration module is used for carrying out camera calibration processing according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera.
A camera calibration apparatus comprising a memory, a processor and a computer program stored on the memory, the processor executing the computer program to implement the method described above.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the above method.
At least one embodiment provided in this specification enables the following benefits:
according to the scheme, the target vertex detected and identified from the two-dimensional code pattern in the calibration image is utilized, and the calibration processing of the camera can be completed under a specific calibration algorithm. Therefore, after the calibration system receives the calibration image, the calibration of the camera can be automatically completed without manually participating in screening qualified calibration images, so that the process of camera calibration is simplified, less time is consumed for camera calibration, and the industrial assembly line operation for camera calibration is conveniently realized, thereby improving the simplicity of batch calibration of cameras.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
Fig. 1 is a schematic flow chart of a camera calibration method according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of a two-dimensional code pattern according to an embodiment of the present disclosure;
fig. 3 is a schematic view of a projection position of a spatial position point P on an imaging plane and an observed pixel coordinate position according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a preset world coordinate system according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a calibration pattern of a first calibration plate according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a calibration pattern of a second calibration plate according to an embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of a camera calibration device corresponding to FIG. 1 according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a camera calibration device corresponding to fig. 1 according to an embodiment of the present disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of one or more embodiments of the present specification more clear, the technical solutions of one or more embodiments of the present specification will be clearly and completely described below in connection with specific embodiments of the present specification and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present specification. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without undue burden, are intended to be within the scope of one or more embodiments herein.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a flow chart of a camera calibration method according to an embodiment of the present disclosure. From the program perspective, the execution body of the process may be a device for calibrating the camera, or an application program installed at the device for calibrating the camera. As shown in fig. 1, the process may include the steps of:
step 102: and acquiring a calibration image acquired by a camera aiming at a calibration object, wherein a target two-dimensional code pattern is drawn in the calibration object.
In the embodiment of the present disclosure, the camera calibration object may be a calibration device for displaying a calibration image required for calibrating a camera. The calibration patterns drawn on the calibration object can be patterns formed by two-dimensional codes of a first preset number, the first preset number can be any natural number greater than or equal to 1, and the greater the first preset number is, the higher the accuracy of the result of calibrating the camera is. When the first preset number is any natural number greater than 1, the two-dimensional codes on the calibration object can be all the same two-dimensional codes, can be partial same two-dimensional codes, or can be two-dimensional codes different from each other. The type of the two-dimensional code can be tag36h11 type or other types of two-dimensional codes. The labels of the two-dimensional codes in the camera calibration object are different. The target two-dimensional code pattern may be one or more two-dimensional code patterns drawn on the calibration object.
In the embodiment of the present disclosure, in the process of calibrating the camera, the number of calibration images may be any one value greater than or equal to 1, and the greater the number of calibration images, the higher the accuracy of the result of calibrating the camera.
Step 104: processing the calibration image by using a two-dimensional code recognition algorithm to obtain a first pixel coordinate set under a preset pixel coordinate system; and the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image.
In this embodiment of the present disclosure, as shown in fig. 2, any two-dimensional code pattern selected from the calibration image includes 0 to 4 vertices. The arrangement sequence number of the vertexes can be set according to the requirement, and the vertexes included in the two-dimensional code pattern can be other vertexes identified from the two-dimensional code pattern. And obtaining pixel coordinates of any vertex contained in the two-dimensional code in the belonging calibration image by using a two-dimensional code identification algorithm. The two-dimensional code recognition algorithm can be an extratags function in a call opencv open source library. The two-dimensional code recognition algorithm can also be other algorithms for obtaining pixel coordinates at the vertex of the two-dimensional code from the calibration image. Based on the same principle, vertex coordinates of other two-dimensional code patterns on the calibration image can be obtained. The number of the target vertexes can be one or more, and when the number of the target vertexes is one, the target vertexes can be any one vertex identified for any one two-dimensional code pattern in the calibration object; when the target vertices are multiple, the target vertices can be multiple vertices identified for any one or multiple two-dimensional code patterns in the calibration object.
Step 106: and determining world coordinates of each target vertex under a preset world coordinate system to obtain a world coordinate set.
In this embodiment of the present disclosure, the preset world coordinate system may be a world coordinate system formed by taking the upper left corner of the calibration object as the origin, the X axis being horizontally leftward, the Y axis being horizontally downward, and the Z axis being 0. And acquiring world coordinates of the vertexes of each two-dimensional code pattern on the calibration object under a preset world coordinate system to obtain a world coordinate set. It should be noted that, the preset world coordinate system may also be selected according to other principles, and the selection of the preset world coordinate system is not specifically limited in this scheme.
Step 108: and carrying out camera calibration processing according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera.
In this embodiment of the present disclosure, as shown in fig. 3, the principle of the camera calibration algorithm adopted in the present disclosure may be that any point P in the acquired spatial position is a projection position representing the point P, P2 represents a pixel position observed by the point P, the projection position of the point P is gradually close to the observed pixel position by adjusting parameters of the camera, and when a distance between the projection position of the point P and the observed pixel position is smaller than a preset threshold value, the adjustment of parameters of the camera is stopped, and at this time, the obtained camera parameters are calibration results after calibrating the camera. Any one of the world coordinates in the world coordinate set can be used as the spatial position of the point P, and the pixel position observed for the point P can be obtained from the first pixel coordinate set, and the projection coordinate of the point P can be generated according to the world coordinate of the point P, so that the calibration processing for the camera can be completed by using the first pixel coordinate set and the world coordinate set based on the principle described above.
In the embodiment of the specification, after the calibration image is received, the scheme can automatically complete the calibration of the camera under a specific calibration algorithm without manually participating in screening qualified calibration images, so that the process of camera calibration is simplified, less time is consumed for camera calibration, and the method is convenient for realizing industrial pipeline operation for camera calibration, thereby improving the simplicity of batch calibration of cameras.
Based on the method in fig. 1, the examples of the present specification also provide some specific embodiments of the method, as described below.
The calibration images comprise a first calibration image and a second calibration image which are acquired for a calibration object under any two different poses, the calibration object comprises a first calibration plate and a second calibration plate, the first calibration plate and the second calibration plate are respectively provided with the target two-dimensional code pattern, and a preset included angle is formed between the first calibration plate and the second calibration plate.
In this embodiment of the present disclosure, the camera calibration object may include a first calibration plate and a second calibration plate, where the first calibration plate and the second calibration plate may be connected together by a certain common edge, or may be separated by a predetermined distance without being connected together. The first calibration plate and the second calibration plate can have a preset included angle, and the preset included angle can be 90 degrees or any angle within the range of more than 0 degrees and less than or equal to 180 degrees. The shapes of the first calibration plate and the second calibration plate can be any one of square, rectangle, round and other irregular patterns, and the sizes and the shapes of the first calibration plate and the second calibration plate can be the same or different. The size and shape of the first calibration plate and the second calibration plate are not particularly limited.
It should be noted that, when the included angle between the first calibration plate and the second calibration plate is 90 degrees, the preset world coordinate system may be set in the manner of fig. 4. As shown in fig. 4, a straight line parallel to the bottom edge of the first calibration plate on the ground is taken as an X coordinate axis, a straight line parallel to the bottom edge of the second calibration plate on the ground is taken as a Y coordinate axis, an intersection point of the X coordinate axis and the Y coordinate axis is taken as a coordinate origin O, a straight line passing through the coordinate origin O and perpendicular to the ground is taken as a Z coordinate axis, and a coordinate system consisting of the X coordinate axis, the Y coordinate axis, the Z coordinate axis and the coordinate origin O is taken as a preset world coordinate system. By the arrangement, world coordinates of all target vertexes on the first calibration plate and the second calibration plate can be conveniently obtained.
In this embodiment of the present disclosure, a pattern formed by two-dimensional codes of a second preset number may be drawn on the first calibration plate, where the second preset number may be any natural number greater than or equal to 1, and when the second preset number is any natural number greater than 1, the two-dimensional codes on the first calibration plate may be all the same two-dimensional codes, may be partially the same two-dimensional codes, or may be two-dimensional codes that are different from each other, and two-dimensional codes included on the first calibration plate may be arranged in n rows and n columns, or may be arranged in other manners. The calibration pattern drawn on the second calibration plate is identical to the calibration pattern drawn on the first calibration plate. It should be noted that the fact that the first calibration plate is consistent with the calibration pattern drawn on the second calibration means that the area shape of the calibration pattern on the first calibration plate is consistent with the area shape of the calibration pattern on the second calibration, and the two-dimensional code at the superposition position is consistent in size and shape after the calibration pattern in the first calibration plate is superposed and superposed with the calibration pattern in the second calibration plate. As shown in fig. 5, the calibration pattern of the first calibration plate includes 6 rows and 6 columns of two-dimensional code patterns, and as shown in fig. 6, the calibration pattern of the second calibration plate also includes 6 rows and 6 columns of two-dimensional code patterns.
In this embodiment of the present disclosure, the first calibration image may be any one or more calibration images captured by the camera for the calibration pattern in the first pose state. The first pose state can be a state when a preset distance exists between the optical center of the camera and the center of the calibration pattern, the preset distance can be 60 cm, other distances can be selected according to actual requirements, and the first pose state needs to align the lens of the camera to the center of the calibration pattern. The second calibration pattern may be any one or more calibration images photographed by the camera in the second pose state with respect to the calibration pattern. The second pose state may be a state in which the camera lens rotates by a preset angle based on the first pose state, and the preset angle may be 90 degrees or other rotation angles. The first pose state and the second pose state are different camera poses. The first calibration image and the second calibration image can both comprise calibration patterns in the first calibration plate and calibration patterns in the second calibration plate.
Step 108: the camera calibration algorithm is used for performing camera calibration processing according to the first pixel coordinate set and the world coordinate set to obtain a calibration result of the camera, and the method may include:
and determining a second pixel coordinate corresponding to the world coordinate of the target vertex in the world coordinate set under the preset pixel coordinate system by utilizing the conversion relation between the preset world coordinate system and the preset pixel coordinate system, so as to obtain a second pixel coordinate set.
And calibrating the camera by using a camera calibration algorithm according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera.
In the embodiment of the present disclosure, the conversion relationship between the preset world coordinate system and the preset pixel coordinate system may be
ZP uv =KTP W Wherein: p (P) uv Representing pixel coordinates, P W Representing world coordinates, Z representing a scaling factorK represents the camera intrinsic parameter, and T represents the camera extrinsic parameter. And according to the conversion relation, converting world coordinates of each target vertex in the world coordinate set into second pixel coordinates to obtain a second pixel coordinate set. It should be noted that the second pixel coordinates may be the projection position coordinates of the target vertex. The first pixel coordinate and the second pixel coordinate of the target vertex are both located in the same imaging plane, so that the first pixel coordinate and the second pixel coordinate can be pixel coordinates under a preset pixel coordinate system. Under the principle of the camera calibration algorithm, the parameters of the camera are adjusted so that when the distance between the second pixel coordinate and the first pixel coordinate of the target vertex is smaller than a preset threshold value, the obtained camera parameters are the calibration result after the camera is calibrated.
In the process of calibrating the camera, in order to improve the accuracy of the calibration result of the camera, the camera needs to be calibrated according to a plurality of target vertexes. Based on this, the calibrating the camera according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera may include:
determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set; each pixel coordinate in each target pixel coordinate set is assigned to the same target vertex, and the target pixel coordinate set comprises a first pixel coordinate and a second pixel coordinate.
And constructing a least square problem according to each target pixel coordinate set.
And calibrating the camera according to the least square problem to obtain a calibration result of the camera.
In the embodiment of the present specification, any one of the first pixel coordinates x is selected from the first pixel coordinate set 1 Determining a target vertex to which the first pixel coordinate belongs, and determining a second pixel coordinate y of the vertex a in a second pixel coordinate set if the target vertex is the vertex a 1 First pixel coordinate x 1 And second (b)Pixel coordinate y 1 A set of target pixel coordinates is formed. According to the mode, a plurality of target pixel coordinate sets are sequentially determined, a least square problem is built by selecting any number of target pixel coordinate sets from the determined target pixel coordinate sets, the built least square problem is solved, and when the result of the least square problem meets the preset requirement, the corresponding camera parameters are the calibration result after the camera is calibrated. It should be noted that, the number of the target pixel coordinate sets is not specifically limited when the least square problem is constructed, the greater the number of the target pixel coordinate sets is, the higher the accuracy of the calibration result after the calibration of the camera is, the smaller the number of the target pixel coordinate sets is, and the lower the accuracy of the calibration result after the calibration of the camera is.
The determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set may include:
determining positioning information of the first pixel coordinates for any one of the first pixel coordinates in the first pixel coordinate set; the positioning information includes: the target calibration device comprises decoding information of a target two-dimensional code to which the first pixel coordinate belongs, position information of a target vertex corresponding to the first pixel coordinate in the target two-dimensional code and a target calibration plate to which the first pixel coordinate belongs, wherein the target calibration plate is the first calibration plate or the second calibration plate.
And determining the second pixel coordinate matched with the first pixel coordinate from the second pixel coordinate set according to the positioning information of the first pixel coordinate.
And generating a target pixel coordinate set according to the first pixel coordinate and the second pixel coordinate matched with the first pixel coordinate.
In the embodiment of the present disclosure, the first pixel coordinate x is selected from the first pixel coordinate set 1 Resolving the first pixel coordinate x 1 Obtain the first pixel coordinate x 1 The position information of the belonged target vertex a is based on the target vertexThe position information of the a is used for obtaining the position information of a target two-dimensional code b to which the target vertex a belongs, analyzing the target two-dimensional code b, and determining a target calibration plate to which the target two-dimensional code b belongs, wherein the target calibration plate belongs to the first calibration plate or the second calibration plate. Then determining a second pixel coordinate y matched with the target calibration plate from the second pixel coordinate set according to the target calibration plate, the position information of the target two-dimensional code b and the position information of the target vertex a 1 Second pixel coordinate y 1 The world coordinates of the target vertex a are converted by the conversion relation between the world coordinates and the pixel coordinates. At the first pixel coordinate x 1 With the first pixel coordinate y 1 Then according to the first pixel coordinate x 1 With the first pixel coordinate y 1 A set of target pixel coordinates is generated.
The calibrating the camera according to the least square problem to obtain a calibration result of the camera may include:
and carrying out iterative optimization processing on the least square problem by using a nonlinear optimization algorithm to obtain a calculation result of the least square problem.
And judging whether the calculation result of the least square problem is smaller than or equal to a preset threshold value or not to obtain a judgment result.
And if the judging result shows that the calculating result of the least square problem is smaller than or equal to a preset threshold value, determining the camera parameter corresponding to the calculating result as a calibration result of the camera.
The calibration result of the camera comprises a camera internal parameter calibration result and a camera distortion coefficient calibration result of the camera.
The calculation formula of the least square problem is as follows:
wherein: argmin represents a calculated minimum value, ui represents the first pixel coordinate, pi represents a world coordinate of the target vertex under the preset world coordinate system, K represents the camera distortion coefficient of the camera participating in the camera of the camera, T represents a camera external parameter of the camera, KTPi represents the second pixel coordinate, and i represents the number of the target vertices.
In the embodiment of the present disclosure, according to any one target pixel coordinate set, a distance difference between a first pixel coordinate and a second pixel coordinate is generated, and a calculation formula of a least square problem is generated by using a plurality of distance differences between the first pixel coordinate and the second pixel coordinateThe least squares problem may be iteratively optimized using a nonlinear optimization algorithm. The specific iteration steps can be as follows:
step 1: and setting initial values of camera parameters, and starting optimization processing. Lateral focal length f of camera x Can be set to the real focal length/pixel size of the camera, and the longitudinal focal length f of the camera y Can be set to the real focal length/pixel size of the camera, and the optical center c of the camera x Can be set to be the width/2 of the image, the optical center c of the camera y May be set to the height/2 of the image.
Step 2: and adjusting camera parameters to obtain the current calculation result of the least square problem. The camera parameters may be adjusted by adding a preset value to each iteration of the camera parameters, where the preset value may be set according to the actual requirements.
Step 3: judging whether the current calculation result is smaller than or equal to a preset threshold value, and returning to the step 2 if the current calculation result is larger than the preset threshold value; and if the current calculation result is smaller than or equal to the preset threshold value, stopping the iterative process. The preset threshold value can be set according to the requirement on the accuracy of the camera calibration result.
After the constructed least square problem is optimized and iterated to obtain a calculation result meeting the requirement, obtaining the corresponding camera parameters at the moment, wherein the camera parameters are the calibration result after calibrating the camera, and the camera parameters can comprise the camera internal parameters f x ,f y ,c x ,c y Radial distortion parameter k of camera 1 ,k 2 ,k 3 Tangential camera distortion parameter p 1 ,p 2 . The nonlinear optimization algorithm can be a Levenberg-Marquardt method, or other algorithms capable of solving the least square problem, and the nonlinear optimization algorithm is not particularly limited by the scheme.
In the embodiment of the present disclosure, by constructing the least square problem, the distances between the observed pixel coordinate positions and the projection positions of the plurality of target vertices may all meet the preset requirement. Therefore, the parameters of the camera can be obtained on the premise that the distances between the coordinate positions of the observed pixels of the plurality of target vertexes and the projection positions meet the preset requirements, so that the accuracy of calibrating the parameters of the camera is improved.
Based on the same thought, the embodiment of the specification also provides a device corresponding to the method. Fig. 7 is a schematic structural diagram of a camera calibration device corresponding to fig. 1 according to an embodiment of the present disclosure. As shown in fig. 7, the apparatus may include:
the obtaining module 702 is configured to obtain a calibration image collected by the camera for a calibration object, where a target two-dimensional code pattern is drawn in the calibration object.
The processing module 704 is configured to process the calibration image by using a two-dimensional code recognition algorithm, so as to obtain a first pixel coordinate set under a preset pixel coordinate system; and the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image.
The determining module 706 is configured to determine world coordinates of each of the target vertices in a preset world coordinate system, to obtain a world coordinate set.
The calibration module 708 is configured to perform a camera calibration process according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm, so as to obtain a calibration result of the camera.
Optionally, the calibration image includes a first calibration image and a second calibration image collected for a calibration object under any two different poses, the calibration object includes a first calibration plate and a second calibration plate, the first calibration plate and the second calibration plate are both drawn with the target two-dimensional code pattern, and a preset included angle is formed between the first calibration plate and the second calibration plate.
Optionally, the calibration module 708 may include:
the first determining unit is configured to determine a second pixel coordinate corresponding to the world coordinate of the target vertex in the world coordinate set under the preset pixel coordinate system by using a conversion relationship between the preset world coordinate system and the preset pixel coordinate system, so as to obtain a second pixel coordinate set.
And the calibration unit is used for calibrating the camera by using a camera calibration algorithm according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera.
Optionally, the calibration unit may include:
a first determining subunit, configured to determine at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set; each pixel coordinate in each target pixel coordinate set is assigned to the same target vertex, and the target pixel coordinate set comprises a first pixel coordinate and a second pixel coordinate.
And the construction subunit is used for constructing a least square problem according to each target pixel coordinate set.
And the calibration subunit is used for carrying out calibration processing on the camera according to the least square problem to obtain a calibration result of the camera.
Optionally, the first determining subunit may include:
the first determining subunit is specifically configured to determine, for any one of the first pixel coordinates in the first pixel coordinate set, positioning information of the first pixel coordinate; the positioning information includes: the target calibration device comprises decoding information of a target two-dimensional code to which the first pixel coordinate belongs, position information of a target vertex corresponding to the first pixel coordinate in the target two-dimensional code and a target calibration plate to which the first pixel coordinate belongs, wherein the target calibration plate is the first calibration plate or the second calibration plate.
The first determining subunit is specifically configured to determine, from the second set of pixel coordinates, the second pixel coordinate that matches the first pixel coordinate according to positioning information of the first pixel coordinate.
The first determining subunit is specifically configured to generate a target pixel coordinate set according to the first pixel coordinate and the second pixel coordinate that matches the first pixel coordinate.
Optionally, the calibration subunit may include:
the standard subunit is specifically configured to perform iterative optimization processing on the least square problem by using a nonlinear optimization algorithm, so as to obtain a calculation result of the least square problem.
The standard sub-unit is specifically configured to determine whether the calculation result of the least square problem is less than or equal to a preset threshold value, so as to obtain a determination result.
The calibration subunit is specifically configured to determine, as a calibration result of the camera, a camera parameter corresponding to the calculation result if the determination result indicates that the calculation result of the least square problem is less than or equal to a preset threshold.
Optionally, the calibration result of the camera includes a camera internal parameter calibration result and a camera distortion coefficient calibration result of the camera.
The calculation formula of the least square problem is as follows:
wherein: argmin represents a calculated minimum value, ui represents the first pixel coordinate, pi represents a world coordinate of the target vertex under the preset world coordinate system, K represents the camera distortion coefficient of the camera participating in the camera of the camera, T represents a camera external parameter of the camera, KTPi represents the second pixel coordinate, and i represents the number of the target vertices.
Based on the same thought, the embodiment of the specification also provides equipment corresponding to the method.
Fig. 8 is a schematic structural diagram of a camera calibration device corresponding to fig. 1 according to an embodiment of the present disclosure. As shown in fig. 8, the device 800 may include:
at least one processor 810; the method comprises the steps of,
a memory 830 communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory 830 stores instructions 820 executable by the at least one processor 810 to enable the at least one processor 810 to execute the instructions to implement the methods described above.
The invention also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor realizes the above method.
It should be understood that, in the method described in one or more embodiments of the present disclosure, the order of some steps may be adjusted according to actual needs, or some steps may be omitted.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the apparatus and computer readable storage medium shown in fig. 8, since it is substantially similar to the method embodiment, the description is relatively simple, and reference is made to the partial description of the method embodiment for relevant points.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. A camera calibration method, comprising:
acquiring a calibration image acquired by a camera aiming at a calibration object, wherein a target two-dimensional code pattern is drawn in the calibration object;
processing the calibration image by using a two-dimensional code recognition algorithm to obtain a first pixel coordinate set under a preset pixel coordinate system; the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image;
determining world coordinates of each target vertex under a preset world coordinate system to obtain a world coordinate set;
and carrying out camera calibration processing according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera.
2. The method of claim 1, wherein the calibration image comprises a first calibration image and a second calibration image acquired for a calibration object in any two different poses, the calibration object comprises a first calibration plate and a second calibration plate, the target two-dimensional code pattern is drawn in each of the first calibration plate and the second calibration plate, and a preset included angle is formed between the first calibration plate and the second calibration plate.
3. The method of claim 2, wherein the performing, using a camera calibration algorithm, a camera calibration process according to the first set of pixel coordinates and the set of world coordinates to obtain a calibration result of the camera comprises:
determining a second pixel coordinate under the preset pixel coordinate system corresponding to the world coordinate of the target vertex in the world coordinate set by utilizing a conversion relation between the preset world coordinate system and the preset pixel coordinate system to obtain a second pixel coordinate set;
and calibrating the camera by using a camera calibration algorithm according to the first pixel coordinate set and the second pixel coordinate set to obtain a calibration result of the camera.
4. The method of claim 3, wherein the calibrating the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain the calibration result of the camera comprises:
determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set; each pixel coordinate in each target pixel coordinate set is assigned to the same target vertex, and the target pixel coordinate set comprises a first pixel coordinate and a second pixel coordinate;
constructing a least square problem according to each target pixel coordinate set;
and calibrating the camera according to the least square problem to obtain a calibration result of the camera.
5. The method of claim 4, wherein said determining at least one target set of pixel coordinates from said first set of pixel coordinates and said second set of pixel coordinates comprises:
determining positioning information of the first pixel coordinates for any one of the first pixel coordinates in the first pixel coordinate set; the positioning information includes: decoding information of a target two-dimensional code to which the first pixel coordinate belongs, position information of the target vertex corresponding to the first pixel coordinate in the target two-dimensional code, and a target calibration plate to which the first pixel coordinate belongs, wherein the target calibration plate is the first calibration plate or the second calibration plate;
determining the second pixel coordinate matched with the first pixel coordinate from the second pixel coordinate set according to the positioning information of the first pixel coordinate;
and generating a target pixel coordinate set according to the first pixel coordinate and the second pixel coordinate matched with the first pixel coordinate.
6. The method of claim 4, wherein the calibrating the camera according to the least squares problem to obtain the calibration result of the camera comprises:
carrying out iterative optimization processing on the least square problem by using a nonlinear optimization algorithm to obtain a calculation result of the least square problem;
judging whether the calculation result of the least square problem is smaller than or equal to a preset threshold value or not to obtain a judgment result;
and if the judging result shows that the calculating result of the least square problem is smaller than or equal to a preset threshold value, determining the camera parameter corresponding to the calculating result as a calibration result of the camera.
7. The method of claim 6, wherein the calibration results of the camera include a camera internal reference calibration result and a camera distortion coefficient calibration result of the camera;
the calculation formula of the least square problem is as follows:
wherein: argmin represents a calculated minimum value, ui represents the first pixel coordinate, pi represents a world coordinate of the target vertex under the preset world coordinate system, K represents the camera distortion coefficient of the camera participating in the camera of the camera, T represents a camera external parameter of the camera, KTPi represents the second pixel coordinate, and i represents the number of the target vertices.
8. A camera calibration apparatus, comprising:
the acquisition module is used for acquiring a calibration image acquired by the camera aiming at a calibration object, wherein a target two-dimensional code pattern is drawn in the calibration object;
the processing module is used for processing the calibration image by utilizing a two-dimensional code recognition algorithm to obtain a first pixel coordinate set under a preset pixel coordinate system; the first pixel coordinate set comprises first pixel coordinates of a target vertex of the target two-dimensional code pattern identified from the calibration image;
the determining module is used for determining world coordinates of each target vertex under a preset world coordinate system to obtain a world coordinate set;
and the calibration module is used for carrying out camera calibration processing according to the first pixel coordinate set and the world coordinate set by using a camera calibration algorithm to obtain a calibration result of the camera.
9. A camera calibration apparatus comprising a memory, a processor and a computer program stored on the memory, characterized in that: the processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202310423310.3A 2023-04-19 2023-04-19 Camera calibration method, device, equipment and medium Pending CN116524041A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310423310.3A CN116524041A (en) 2023-04-19 2023-04-19 Camera calibration method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310423310.3A CN116524041A (en) 2023-04-19 2023-04-19 Camera calibration method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116524041A true CN116524041A (en) 2023-08-01

Family

ID=87407558

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310423310.3A Pending CN116524041A (en) 2023-04-19 2023-04-19 Camera calibration method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116524041A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117422776A (en) * 2023-12-14 2024-01-19 西北工业大学青岛研究院 Underwater vision camera calibration device and method for non-parametric distortion model

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117422776A (en) * 2023-12-14 2024-01-19 西北工业大学青岛研究院 Underwater vision camera calibration device and method for non-parametric distortion model

Similar Documents

Publication Publication Date Title
CN107767422B (en) Fisheye lens correction method and device and portable terminal
CN111260731B (en) Self-adaptive detection method for checkerboard sub-pixel level corner points
US9420276B2 (en) Calibration of light-field camera geometry via robust fitting
CN110197466B (en) Wide-angle fisheye image correction method
TWI555379B (en) An image calibrating, composing and depth rebuilding method of a panoramic fish-eye camera and a system thereof
US9886759B2 (en) Method and system for three-dimensional data acquisition
US7780084B2 (en) 2-D barcode recognition
CN1975323A (en) Method for making three-dimensional measurement of objects utilizing single digital camera to freely shoot
CN111815710B (en) Automatic calibration method for fish-eye camera
CN109345597B (en) Camera calibration image acquisition method and device based on augmented reality
JP4270949B2 (en) Calibration chart image display device, calibration device, and calibration method
CN111915485B (en) Rapid splicing method and system for feature point sparse workpiece images
CN107356213B (en) Optical filter concentricity measuring method and terminal equipment
JP2014197243A (en) Pattern processor, pattern processing method and pattern processing program
CN109035170A (en) Adaptive wide-angle image correction method and device based on single grid chart subsection compression
WO2024011764A1 (en) Calibration parameter determination method and apparatus, hybrid calibration board, device, and medium
CN116524041A (en) Camera calibration method, device, equipment and medium
CN107680035B (en) Parameter calibration method and device, server and readable storage medium
CN114037992A (en) Instrument reading identification method and device, electronic equipment and storage medium
CN117557565B (en) Detection method and device for lithium battery pole piece
CN109255754B (en) Method and system for splicing and really displaying large-scene multi-camera images
CN114998571B (en) Image processing and color detection method based on fixed-size markers
JP4747293B2 (en) Image processing apparatus, image processing method, and program used therefor
CN116051652A (en) Parameter calibration method, electronic equipment and storage medium
CN112489141B (en) Production line calibration method and device for single-board single-image strip relay lens of vehicle-mounted camera

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