[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

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
target
pixel coordinates
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

一种相机标定方法、装置、设备及介质A camera calibration method, device, equipment and medium

技术领域technical field

本申请涉及相机标定技术领域,尤其涉及一种相机标定方法、装置、设备及介质。The present application relates to the technical field of camera calibration, and in particular to a camera calibration method, device, equipment and medium.

背景技术Background technique

现有的相机标定方法中,所使用的标定图像中需包含有预设规则的标定图案。若在针对标定物采集标定图像的过程中,受拍摄光线的亮度以及标定物角度等因素的影响,导致所拍摄的标定图像中难免会存在不满足预设要求的标定图像。所以为了获取到合格的标定图像,针对标定物采集标定图像时,需在每一个相机位姿状态下,采集多张标定图像,然后再通过人工筛选的方式从所拍摄的多张标定图像中选择出合格的标定图像。如果不对所拍摄的标定图像进行筛选,则可能引入成像质量差的样本。因此,现有的相机标定方法中相机标定过程耗时较长,流程较繁琐,难以实现工业化流水线作业,对相机进行批量标定的难度较大。In the existing camera calibration methods, the calibration images used need to contain calibration patterns with preset rules. During the process of collecting calibration images for the calibration objects, due to the influence of factors such as the brightness of the shooting light and the angle of the calibration objects, there will inevitably be calibration images that do not meet the preset requirements in the captured calibration images. Therefore, in order to obtain qualified calibration images, when collecting calibration images for calibration objects, it is necessary to collect multiple calibration images in each camera pose state, and then select from the multiple calibration images taken by manual screening. A qualified calibration image is produced. If the calibration images taken are not screened, poorly imaged samples may be introduced. Therefore, the camera calibration process in the existing camera calibration method takes a long time, the process is cumbersome, it is difficult to realize the industrialized assembly line operation, and it is more difficult to calibrate the cameras in batches.

基于此,如何简化相机标定的流程,实现相机标定的工业化流水线作业,以提升对相机进行批量标定的简捷性,成为了亟待解决的技术问题。Based on this, how to simplify the camera calibration process, realize the industrialized assembly line operation of camera calibration, and improve the simplicity of batch calibration of cameras has become an urgent technical problem to be solved.

发明内容Contents of the invention

本说明书实施例提供的一种相机标定方法、装置、设备及介质,以解决现有技术中对相机进行标定的过程耗时较长,流程较繁琐,难以实现工业化流水线作业,对相机进行批量标定的难度较大的技术问题。The embodiment of this specification provides a camera calibration method, device, equipment, and medium to solve the problem that the process of calibrating cameras in the prior art takes a long time, the process is cumbersome, and it is difficult to realize industrialized assembly line operations, and batch calibration of cameras difficult technical problems.

为解决上述技术问题,本说明书实施例是这样实现的:In order to solve the above-mentioned technical problems, the embodiments of this specification are implemented as follows:

本说明书实施例提供的一种相机标定方法,包括,A camera calibration method provided in an embodiment of this specification includes:

获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案。The calibration image collected by the camera for the calibration object is acquired, and the target two-dimensional code pattern is drawn in the calibration object.

利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标。Using a two-dimensional code recognition algorithm, the calibration image is processed to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes the identified from the calibration image The first pixel coordinate of the target vertex of the target QR code pattern.

确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合。Determine the world coordinates of each target vertex in the preset world coordinate system to obtain a world coordinate set.

利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。A camera calibration algorithm is used to perform camera calibration processing according to the first set of pixel coordinates and the set of world coordinates to obtain a calibration result of the camera.

优选的,所述标定图像包括在任意两个不同位姿下针对标定物采集的第一标定图像与第二标定图像,所述标定物包含第一标定板与第二标定板,所述第一标定板与所述第二标定板中均绘制有所述目标二维码图案,所述第一标定板与所述第二标定板之间具有预设夹角。Preferably, the calibration image includes a first calibration image and a second calibration image collected for a calibration object at any two different poses, the calibration object includes a first calibration plate and a second calibration plate, and the first The target two-dimensional code pattern is drawn on both the calibration plate and the second calibration plate, and there is a preset angle between the first calibration plate and the second calibration plate.

优选地,所述利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果,包括:Preferably, the camera calibration algorithm is used to perform camera calibration processing according to the first pixel coordinate set and the world coordinate set to obtain the camera calibration result, including:

利用所述预设世界坐标系与所述预设像素坐标系之间的转换关系,确定所述世界坐标集合中的所述目标顶点的世界坐标对应的在所述预设像素坐标系下的第二像素坐标,得到第二像素坐标集合。Using the conversion relationship between the preset world coordinate system and the preset pixel coordinate system, determine the world coordinate of the target vertex in the world coordinate set corresponding to the first pixel coordinate system under the preset pixel coordinate system Two pixel coordinates to get the second set of pixel coordinates.

利用相机标定算法,根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果。Using a camera calibration algorithm, perform calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera.

优选地,所述根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果,包括:Preferably, performing calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera includes:

从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合;每个所述目标像素坐标集合中的各个像素坐标均归属于同一所述目标顶点,且所述目标像素坐标集合中包含一个所述第一像素坐标与一个所述第二像素坐标。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 belongs to the same target vertex, and The set of target pixel coordinates includes one of the first pixel coordinates and one of the second pixel coordinates.

根据各个所述目标像素坐标集合,构建最小二乘问题。According to each set of target pixel coordinates, a least squares problem is constructed.

根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果。Calibrate the camera according to the least square problem to obtain a calibration result of the camera.

优选地,所述从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合,包括:Preferably, determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set includes:

针对所述第一像素坐标集合中的任意一个所述第一像素坐标,确定所述第一像素坐标的定位信息;所述定位信息包括:所述第一像素坐标所归属的目标二维码的解码信息、所述第一像素坐标所对应的所述目标顶点在所述目标二维码中所处的位置信息以及所述第一像素坐标所归属的目标标定板,所述目标标定板为所述第一标定板或所述第二标定板。For any one of the first pixel coordinates in the first pixel coordinate set, determine the positioning information of the first pixel coordinates; the positioning information includes: the target two-dimensional code to which the first pixel coordinates belong The decoding information, the position information of the target vertex corresponding to the first pixel coordinate in the target two-dimensional code, and the target marking plate to which the first pixel coordinate belongs, the target marking plate is the The first calibration plate or the second calibration plate.

根据所述第一像素坐标的定位信息,从所述第二像素坐标集合中确定出与所述第一像素坐标相匹配的所述第二像素坐标。The second pixel coordinates matching the first pixel coordinates are determined from the second pixel coordinate set according to the positioning information of the first pixel coordinates.

根据所述第一像素坐标以及与所述第一像素坐标相匹配的所述第二像素坐标,生成一个目标像素坐标集合。A set of target pixel coordinates is generated according to the first pixel coordinates and the second pixel coordinates matching the first pixel coordinates.

优选地,所述根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果,包括:Preferably, the camera is calibrated according to the least squares problem to obtain a calibration result of the camera, including:

利用非线性优化算法对所述最小二乘问题进行迭代优化处理,得到所述最小二乘问题的计算结果。The nonlinear optimization algorithm is used to perform iterative optimization processing on the least squares problem to obtain the calculation result of the least squares problem.

判断所述最小二乘问题的计算结果是否小于等于预设阀值,得到判断结果。Judging whether the calculation result of the least squares problem is less than or equal to a preset threshold value to obtain a judgment result.

若所述判断结果表示所述最小二乘问题的计算结果小于等于预设阀值,则将与所述计算结果对应的相机参数,确定为所述相机的标定结果。If the judgment result indicates that the calculation result of the least squares problem is less than or equal to a preset threshold, then the camera parameters corresponding to the calculation result are determined as the calibration result of the camera.

优选地,所述相机的标定结果包括所述相机的相机内参标定结果及相机畸变系数标定结果。Preferably, the calibration result of the camera includes the calibration result of the camera intrinsic parameters and the calibration result of the camera distortion coefficient.

所述最小二乘问题的计算公式为: The calculation formula of the least squares problem is:

其中:argmin表示计算最小值、Ui表示所述第一像素坐标、Pi表示所述目标顶点在所述预设世界坐标系下的世界坐标、K表示所述相机的所述相机内参与所述相机畸变系数、T表示所述相机的相机外参、KTPi表示所述第二像素坐标、i表示所述目标顶点的数量。Among them: argmin represents the calculated minimum value, Ui represents the first pixel coordinates, Pi represents the world coordinates of the target vertex in the preset world coordinate system, K represents the participation of the camera in the camera Distortion coefficient, T represents the camera extrinsics of the camera, KTPi represents the second pixel coordinates, and i represents the number of target vertices.

一种相机标定装置,包括,A camera calibration device, comprising,

第一获取模块,用于获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案。The first acquisition module is configured to acquire the calibration image collected by the camera for the calibration object, and the target two-dimensional code pattern is drawn in the calibration object.

处理模块,用于利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标。A processing module, configured to use a two-dimensional code recognition algorithm to process the calibration image to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes The first pixel coordinates of the identified target vertex of the target two-dimensional code pattern.

确定模块,用于确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合。The determining module is configured to determine the world coordinates of each target vertex in the preset world coordinate system to obtain a set of world coordinates.

标定模块,用于利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。The calibration module is configured to use a camera calibration algorithm to perform camera calibration processing according to the first set of pixel coordinates and the set of world coordinates to obtain a calibration result of the camera.

一种相机标定设备,包括存储器、处理器及存储在存储器上的计算机程序,所述处理器执行所述计算机程序以实现上述方法。A camera calibration device includes a memory, a processor and a computer program stored on the memory, and the processor executes the computer program to implement the above method.

一种计算机可读存储介质,其上存储有计算机程序,该计算机序被处理器执行时以实现上述方法。A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method can be realized.

本说明书中提供的至少一个实施例能够实现以下有益效果:At least one embodiment provided in this specification can achieve the following beneficial effects:

本方案利用从标定图像中的二维码图案中检测识别到的目标顶点,在特定的标定算法下,即可完成对相机的标定处理。以使标定系统在接收到标定图像后,就可以自动完成对相机的标定,而无需人工参与筛选合格的标定图像,以简化相机标定的流程、较少相机标定的耗时、便于对相机标定实现工业化流水线作业,以提升对相机进行批量标定的简捷性。This solution uses the target vertices detected and identified from the two-dimensional code pattern in the calibration image, and under a specific calibration algorithm, the camera calibration process can be completed. So that the calibration system can automatically complete the calibration of the camera after receiving the calibration image, without manual participation in the selection of qualified calibration images, so as to simplify the process of camera calibration, reduce the time-consuming camera calibration, and facilitate the realization of camera calibration Industrialized assembly line operations to improve the simplicity of batch calibration of cameras.

附图说明Description of drawings

为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments described in this application. Those skilled in the art can also obtain other drawings based on these drawings without any creative effort.

图1为本说明书实施例提供的一种相机标定方法的流程示意图;FIG. 1 is a schematic flow diagram of a camera calibration method provided by an embodiment of this specification;

图2为本说明书实施例提供的一个二维码图案的示意图;Fig. 2 is a schematic diagram of a two-dimensional code pattern provided by the embodiment of this specification;

图3为本说明书实施例提供的一个空间位置点P在成像平面上的投影位置及观测到的像素坐标位置示意图;Fig. 3 is a schematic diagram of the projected position of a spatial position point P on the imaging plane and the observed pixel coordinate position provided by the embodiment of this specification;

图4为本说明书实施例提供的一个预设世界坐标系的示意图;Fig. 4 is a schematic diagram of a preset world coordinate system provided by the embodiment of this specification;

图5为本说明书实施例提供的第一标定板的标定图案的示意图;Fig. 5 is a schematic diagram of the calibration pattern of the first calibration plate provided by the embodiment of this specification;

图6为本说明书实施例提供的第二标定板的标定图案的示意图;Fig. 6 is a schematic diagram of the calibration pattern of the second calibration plate provided by the embodiment of this specification;

图7为本说明书实施例提供的对应于图1的一种相机标定装置的结构示意图;Fig. 7 is a schematic structural diagram of a camera calibration device corresponding to Fig. 1 provided by the embodiment of this specification;

图8为本说明书实施例提供的对应于图1的一种相机标定设备的结构示意图。FIG. 8 is a schematic structural diagram of a camera calibration device corresponding to FIG. 1 provided by the embodiment of this specification.

具体实施方式Detailed ways

为使本说明书一个或多个实施例的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本说明书一个或多个实施例的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本说明书一个或多个实施例保护的范围。In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification more clear, the following will clearly and completely describe the technical solutions of one or more embodiments of this specification in conjunction with specific embodiments of this specification and corresponding drawings . Apparently, the described embodiments are only some of the embodiments in this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of one or more embodiments in this specification.

以下结合附图,详细说明本申请各实施例提供的技术方案。The technical solutions provided by various embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.

图1为本说明书实施例提供的一种相机标定方法的流程示意图。从程序角度而言,该流程的执行主体可以为对相机进行标定的设备,或者,对相机进行标定的设备处搭载的应用程序。如图1所示,该流程可以包括以下步骤:FIG. 1 is a schematic flowchart of a camera calibration method provided by an embodiment of this specification. From a program point of view, the subject of execution of the process may be a device for calibrating the camera, or an application program carried on the device for calibrating the camera. As shown in Figure 1, the process may include the following steps:

步骤102:获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案。Step 102: Obtain a calibration image captured by the camera for the calibration object, in which the target two-dimensional code pattern is drawn.

本说明书实施例中,相机标定物可以为用于展示对相机进行标定时所需的标定图像的一种标定装置。标定物上绘制的标定图案可以由第一预设数量的二维码组成的图案,第一预设数量可以为大于等于1的任意一个自然数,第一预设数量越大,其对相机进行标定的结果准确性越高。当第一预设数量为大于1的任意一个自然数时,标定物上的二维码可以为全部相同的二维码,也可以为部分相同的二维码,或者也可以为相互之间均不相同的二维码。二维码的类型可以为tag36h11类型或者其他类型的二维码。相机标定物中各个二维码的标签不同。目标二维码图案可以为标定物上所绘制的一个或者多个二维码图案。In the embodiment of this specification, the camera calibration object may be a calibration device for displaying a calibration image required for calibrating the camera. The calibration pattern drawn on the calibration object can be a pattern composed of a first preset number of two-dimensional codes. The first preset number can be any natural number greater than or equal to 1. The larger the first preset number, the camera is calibrated The higher the accuracy of the result. 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, or partly the same two-dimensional codes, or can be different from each other. the same QR code. The type of the two-dimensional code can be tag36h11 type or other types of two-dimensional code. Each QR code in the camera calibration object is labeled differently. The target two-dimensional code pattern may be one or more two-dimensional code patterns drawn on the calibration object.

本说明书实施例中,在对相机进行标定的过程中,标定图像的数量可以为大于等于1的任意一个数值,标定图像的数量越大,其对相机进行标定的结果准确性越高。In the embodiment of this specification, in the process of calibrating the camera, the number of calibration images can be any number greater than or equal to 1. The larger the number of calibration images, the higher the accuracy of the calibration result of the camera.

步骤104:利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标。Step 104: Process the calibration image using a two-dimensional code recognition algorithm to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes The first pixel coordinates of the target vertex of the target two-dimensional code pattern.

本说明书实施例中,如图2所示,从标定图像上选择的任意一个二维码图案,该二维码图案包含有0至4四个顶点。顶点的排列序号可以根据需求设定,二维码图案所包含的顶点也可以为从二维码图案中识别出的其他顶点。利用二维码识别算法得到该二维码所包含的任一顶点在所属的标定图像中的像素坐标。二维码识别算法可以为调用opencv开源库内的extractTags函数。二维码识别算法也可以为其他用于从标定图像中得到二维码顶点处像素坐标的算法。基于同样的原理,可以得到标定图像上其他二维码图案处的顶点坐标。目标顶点的数量可以为一个或者多个,当目标顶点为一个时,目标顶点可以为针对标定物中任意一个二维码图案识别出的任意一个顶点;当目标顶点为多个时,目标顶点可以为针对标定物中任意一个或者多个二维码图案识别出的多个顶点。In the embodiment of this specification, as shown in FIG. 2 , any two-dimensional code pattern selected from the calibration image includes four vertices from 0 to 4. The sequence numbers of the vertices can be set according to requirements, and the vertices included in the two-dimensional code pattern can also be other vertices identified from the two-dimensional code pattern. Using a two-dimensional code recognition algorithm to obtain the pixel coordinates of any vertex included in the two-dimensional code in the corresponding calibration image. The QR code recognition algorithm can be to call the extractTags function in the opencv open source library. The two-dimensional code recognition algorithm may also be other algorithms for obtaining the pixel coordinates at the vertices of the two-dimensional code from the calibration image. Based on the same principle, the vertex coordinates of other two-dimensional code patterns on the calibration image can be obtained. The number of target vertices can be one or more. When there is one target vertex, the target vertex can be any vertex identified for any two-dimensional code pattern in the calibration object; when there are multiple target vertices, the target vertex can be is a plurality of vertices identified for any one or more two-dimensional code patterns in the calibration object.

步骤106:确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合。Step 106: Determine the world coordinates of each target vertex in the preset world coordinate system to obtain a world coordinate set.

本说明书实施例中,预设世界坐标系可以为以标定物的左上角为原点,X轴水平向左,Y轴水平向下,Z轴为0所构成的世界坐标系。在预设世界坐标系下,获取标定物上各个二维码图案的顶点处的世界坐标,得到世界坐标集合。需要说明的是,预设世界坐标系也可以根据其他原则进行选取,本方案对预设世界坐标系的选取不做具体限定。In the embodiment of this specification, the preset world coordinate system may be a world coordinate system composed of the upper left corner of the calibration object as the origin, the X-axis is horizontally left, the Y-axis is horizontally downward, and the Z-axis is 0. Under the preset world coordinate system, obtain the world coordinates at the vertices of each two-dimensional code pattern on the calibration object, and obtain the world coordinate set. It should be noted that the preset world coordinate system can also be selected according to other principles, and this scheme does not specifically limit the selection of the preset world coordinate system.

步骤108:利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。Step 108: Using a camera calibration algorithm, perform camera calibration processing according to the first pixel coordinate set and the world coordinate set, and obtain a calibration result of the camera.

本说明书实施例中,如图3所示,本发明中所采用的相机标定算法的原理可以为获取空间位置中的任意一点P,P1为表示点P的投影位置,P2表示针对点P所观测到的像素位置,通过调整相机的参数,使得点P的投影位置逐步靠近观测到的像素位置,当点P的投影位置与观测到的像素位置之间的距离小于预设阀值时,则停止调整相机的参数,此时得到的相机参数即为对相机进行标定后的标定结果。世界坐标集合中的任意一个世界坐标都可以作为点P的空间位置,则针对点P观测到的像素位置可以从第一像素坐标集合中获取到,根据点P的世界坐标可以生成点P的投影坐标,因此可以基于上述的原理利用第一像素坐标集合以及世界坐标集合完成针对相机的标定处理。In the embodiment of this specification, as shown in Figure 3, the principle of the camera calibration algorithm used in the present invention can be to obtain any point P in the spatial position, P1 represents the projected position of point P, and P2 represents the observed point P By adjusting the parameters of the camera, the projected position of point P is gradually approached to the observed pixel position. When the distance between the projected position of point P and the observed pixel position is less than the preset threshold, stop Adjust the camera parameters, and the camera parameters obtained at this time are the calibration results after the camera is calibrated. Any world coordinate in the world coordinate set can be used as the spatial position of point P, then the pixel position observed for point P can be obtained from the first pixel coordinate set, and the projection of point P can be generated according to the world coordinate of point P Coordinates, therefore, based on the above principles, the first pixel coordinate set and the world coordinate set can be used to complete the calibration process for the camera.

本说明书实施例中,本方案在接收到标定图像后,就可以在特定的标定算法下自动完成对相机的标定,而无需人工参与筛选合格的标定图像,以简化相机标定的流程、较少相机标定的耗时、便于对相机标定实现工业化流水线作业,以提升对相机进行批量标定的简捷性。In the embodiment of this specification, after receiving the calibration image, the solution can automatically complete the calibration of the camera under a specific calibration algorithm without manual participation in screening qualified calibration images, so as to simplify the process of camera calibration and reduce the number of cameras. Calibration is time-consuming, and it is convenient to realize industrial assembly line operation for camera calibration, so as to improve the simplicity of batch calibration for cameras.

基于图1中的方法,本说明书实施例还提供了该方法的一些具体实施方案,下面进行说明。Based on the method in FIG. 1 , the embodiment of this specification also provides some specific implementations of the method, which will be described below.

所述标定图像包括在任意两个不同位姿下针对标定物采集的第一标定图像与第二标定图像,所述标定物包含第一标定板与第二标定板,所述第一标定板与所述第二标定板中均绘制有所述目标二维码图案,所述第一标定板与所述第二标定板之间具有预设夹角。The calibration image includes a first calibration image and a second calibration image collected for a calibration object at any two different poses, the calibration object includes a first calibration board and a second calibration board, and the first calibration board and The target two-dimensional code pattern is drawn on each of the second calibration boards, and there is a preset angle between the first calibration board and the second calibration board.

本说明书实施例中,相机标定物可以包含有第一标定板与第二标定板,第一标定板与第二标定板可以通过某一共用的边连接在一起,也可以不连接在一起而以预设距离分离开。第一标定板与第二标定板之间可以具有预设夹角,预设夹角可以为90度,也可以为大于0度且小于等于180度范围内的任意角度。第一标定板和第二标定板的形状均可以为正方形、长方形、圆形以及其他不规则图形中的任意一种,第一标定板与第二标定板的大小以及形状可以相同,也可以不相同。对第一标定板与第二标定板的大小及形状均不做具体限定。In the embodiment of this specification, the camera calibration object may include a first calibration plate and a second calibration plate, and the first calibration plate and the second calibration plate may be connected together through a common edge, or they may not be connected together Preset distance apart. There may be a preset angle between the first calibration plate and the second calibration plate, and the preset angle may be 90 degrees, or any angle greater 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, circle and other irregular figures, and the size and shape of the first calibration plate and the second calibration plate can be the same or different. same. The size and shape of the first calibration plate and the second calibration plate are not specifically limited.

需要说明的是,当第一标定板与第二标定板之间的夹角为90度时,预设世界坐标系可以按着图4的方式进行设置。如图4所示,以地面上与第一标定板的底边平行的直线为X坐标轴,以地面上与第二标定板的底边平行的直线为Y坐标轴,X坐标轴与Y坐标轴的交点为坐标原点O,经过坐标原点O垂直于地面向上的直线为Z坐标轴,以X坐标轴、Y坐标轴、Z坐标轴及坐标原点O组成的坐标系为预设世界坐标系。如此设置,可以便于获取到第一标定板与第二标定板上各个目标顶点的世界坐标。It should be noted that when the angle between the first calibration plate and the second calibration plate is 90 degrees, the preset world coordinate system can be set in the manner shown in FIG. 4 . As shown in Figure 4, take the straight line parallel to the bottom edge of the first calibration plate on the ground as the X coordinate axis, take the straight line parallel to the bottom edge of the second calibration plate on the ground as the Y coordinate axis, and the X coordinate axis and the Y coordinate axis The intersection point of the axes is the coordinate origin O, the straight line passing through the coordinate origin O perpendicular to the ground is the Z coordinate axis, and the coordinate system composed of the X coordinate axis, the Y coordinate axis, the Z coordinate axis and the coordinate origin O is the preset world coordinate system. With such an arrangement, it is convenient to obtain the world coordinates of each target vertex on the first calibration board and the second calibration board.

本说明书实施例中,第一标定板上可以绘制有由第二预设数量的二维码组成的图案,第二预设数量可以为大于等于1的任意一个自然数,当第二预设数量为大于1的任意一个自然数时,第一标定板上的二维码可以为全部相同的二维码,也可以为部分相同的二维码,或者也可以为相互之间均不相同的二维码,第一标定板上所包含的二维码可以按着n行n列进行排列,也可以按着其他的方式进行排列。第二标定板上所绘制的标定图案与第一标定板上绘制的标定图案一致。需要说明的是,第一标定板与第二标定上所绘制的标定图案一致是指第一标定板上的标定图案的面积形状与第二标定上的标定图案的面积形状一致,且将第一标定板中的标定图案与第二标定板中的标定图案叠加重合后,重合位置处的二维码的大小及形状一致。如图5所示,第一标定板的标定图案包含有6行6列的二维码图案,如图6所示,第二标定板的标定图案也包含有6行6列的二维码图案。In the embodiment of this specification, a pattern composed of a second preset number of two-dimensional codes can be drawn on the first calibration plate, and the second preset number can be any natural number greater than or equal to 1. When the second preset number is When any natural number is greater than 1, the two-dimensional codes on the first calibration board can be all the same two-dimensional codes, or partly the same two-dimensional codes, or can be different two-dimensional codes , the two-dimensional codes contained on the first calibration board may be arranged in n rows and n columns, or in other ways. The calibration pattern drawn on the second calibration plate is consistent with the calibration pattern drawn on the first calibration plate. It should be noted that the consistency of the calibration pattern drawn on the first calibration plate and 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 first After the calibration pattern in the calibration plate is overlapped with the calibration pattern in the second calibration plate, the size and shape of the two-dimensional code at the overlapping position are consistent. As shown in Figure 5, the calibration pattern of the first calibration board includes a two-dimensional code pattern with 6 rows and 6 columns, and as shown in Figure 6, the calibration pattern of the second calibration board also includes a two-dimensional code pattern with 6 rows and 6 columns .

本说明书实施例中,第一标定图像可以为相机在第一位姿状态下针对标定图案所拍摄的任意一张或者多张标定图像。第一位姿状态可以为相机光心与标定图案的正中心之间具有预设距离时的状态,该预设距离可以为60厘米,也可以根据实际需求选择其他的距离,第一位姿状态需将相机的镜头对准标定图案的正中心位置。第二标定图案可以为相机在第二位姿状态下针对标定图案拍摄的任意一张或者多张标定图像。第二位姿状态可以为在第一位姿状态的基础上将相机镜头旋转预设角度后的状态,该预设夹角可以为90度,也可以为其他的旋转角度。第一位姿状态与第二位姿状态为不同的相机位姿。第一标定图像与第二标定图像上均可以包含有第一标定板中的标定图案和第二标定板中的标定图案。In the embodiment of this specification, the first calibration image may be any one or more calibration images captured by the camera in the first posture state for the calibration pattern. The first pose state can be the state when there is a preset distance between the optical center of the camera and the center of the calibration pattern. The preset distance can be 60 cm, or other distances can be selected according to actual needs. The first pose state The camera lens needs to be aimed at the exact center of the calibration pattern. The second calibration pattern may be any one or more calibration images taken with respect to the calibration pattern in the second pose state of the camera. The second pose state may be a state in which the camera lens is rotated by a preset angle based on the first pose state, and the preset included angle may be 90 degrees or other rotation angles. The first pose state and the second pose state are different camera poses. Both the first calibration image and the second calibration image may contain the calibration pattern on the first calibration plate and the calibration pattern on the second calibration plate.

步骤108:所述利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果,可以包括:Step 108: Using the camera calibration algorithm to perform camera calibration processing according to the first pixel coordinate set and the world coordinate set to obtain the camera calibration result may include:

利用所述预设世界坐标系与所述预设像素坐标系之间的转换关系,确定所述世界坐标集合中的所述目标顶点的世界坐标对应的在所述预设像素坐标系下的第二像素坐标,得到第二像素坐标集合。Using the conversion relationship between the preset world coordinate system and the preset pixel coordinate system, determine the world coordinate of the target vertex in the world coordinate set corresponding to the first pixel coordinate system under the preset pixel coordinate system Two pixel coordinates to get the second set of pixel coordinates.

利用相机标定算法,根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果。Using a camera calibration algorithm, perform calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera.

本说明书实施例中,预设世界坐标系与预设像素坐标系之间的转换关系可以为In the embodiment of this specification, the conversion relationship between the preset world coordinate system and the preset pixel coordinate system can be

ZPuv=KTPW,其中:Puv表示像素坐标,PW表示世界坐标,Z表示比例系数,K表示相机内参,T表示相机外参。根据该转换关系,将世界坐标集合中的各个目标顶点的世界坐标均转换为第二像素坐标,得到第二像素坐标集合。需要说明的是,第二像素坐标可以作为目标顶点的投影位置坐标。目标顶点的第一像素坐标与第二像素坐标均位于同一个成像平面,因此,第一像素坐标与第二像素坐标均可以为在预设像素坐标系下的像素坐标。在上述相机标定算法的原理下,通过调整相机的参数,使得目标顶点的第二像素坐标与第一像素坐标之间的距离小于预设阀值时,所得到的相机参数即为对相机进行标定后的标定结果。ZP uv =KTP W , where: P uv represents pixel coordinates, P W represents world coordinates, Z represents a scale factor, K represents internal camera parameters, and T represents external camera parameters. According to the conversion relationship, the world coordinates of each target vertex in the world coordinate set are converted into the second pixel coordinates to obtain the second pixel coordinate set. It should be noted that the second pixel coordinates may be used as the projected position coordinates of the target vertex. Both the first pixel coordinates and the second pixel coordinates of the target vertex are located on the same imaging plane, therefore, both the first pixel coordinates and the second pixel coordinates may be pixel coordinates in a preset pixel coordinate system. Under the principle of the above camera calibration algorithm, by adjusting the parameters of the camera so that the distance between the second pixel coordinate and the first pixel coordinate of the target vertex is less than the preset threshold, the obtained camera parameters are the camera calibration After calibration results.

在对相机进行标定的过程中,为了提升对相机进行标定结果的准确性,需根据多个目标顶点来对相机进行标定。基于此,所述根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果,可以包括:In the process of calibrating the camera, in order to improve the accuracy of the calibration result of the camera, it is necessary to calibrate the camera according to multiple target vertices. Based on this, the performing calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera may include:

从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合;每个所述目标像素坐标集合中的各个像素坐标均归属于同一所述目标顶点,且所述目标像素坐标集合中包含一个所述第一像素坐标与一个所述第二像素坐标。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 belongs to the same target vertex, and The set of target pixel coordinates includes one of the first pixel coordinates and one of the second pixel coordinates.

根据各个所述目标像素坐标集合,构建最小二乘问题。According to each set of target pixel coordinates, a least squares problem is constructed.

根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果。Calibrate the camera according to the least square problem to obtain a calibration result of the camera.

本说明书实施例中,从第一像素坐标集合中选取出任意一个第一像素坐标x1,确定该第一像素坐标所归属的目标顶点,假设目标顶点为顶点a,则在第二像素坐标集合中确定出顶点a的第二像素坐标y1,则第一像素坐标x1与第二像素坐标y1就构成了一个目标像素坐标集合。依据上述的方式,依次确定出多个目标像素坐标集合,从所确定出的多个目标像素坐标集合中选取任意数量的目标像素坐标集合构建最小二乘问题,对所构建的最小二乘问题进行求解,当最小二乘问题的结果满足预设要求时,则对应的相机参数即为对相机进行标定后的标定结果。需要说明的是,构建最小二乘问题时针对目标像素坐标集合的数量不做具体限定,其数量越多,对相机进行标定后的标定结果的准确性越高,数量越少,对相机进行标定后的标定结果的准确性越低。In the embodiment of this specification, any first pixel coordinate x 1 is selected from the first pixel coordinate set, and the target vertex to which the first pixel coordinate belongs is determined. Assuming that the target vertex is vertex a, then in the second pixel coordinate set The second pixel coordinate y 1 of the vertex a is determined in , then the first pixel coordinate x 1 and the second pixel coordinate y 1 constitute a set of target pixel coordinates. According to the above method, a plurality of target pixel coordinate sets are sequentially determined, any number of target pixel coordinate sets are selected from the determined multiple target pixel coordinate sets to construct a least squares problem, and the constructed least squares problem is performed Solving, when the result of the least squares problem meets the preset requirements, the corresponding camera parameters are the calibration results after the camera is calibrated. It should be noted that when constructing the least squares problem, there is no specific limit on the number of target pixel coordinate sets. The more the number, the higher the accuracy of the calibration results after the camera is calibrated. The accuracy of the final calibration result is lower.

所述从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合,可以包括:The determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set may include:

针对所述第一像素坐标集合中的任意一个所述第一像素坐标,确定所述第一像素坐标的定位信息;所述定位信息包括:所述第一像素坐标所归属的目标二维码的解码信息、所述第一像素坐标所对应的所述目标顶点在所述目标二维码中所处的位置信息以及所述第一像素坐标所归属的目标标定板,所述目标标定板为所述第一标定板或所述第二标定板。For any one of the first pixel coordinates in the first pixel coordinate set, determine the positioning information of the first pixel coordinates; the positioning information includes: the target two-dimensional code to which the first pixel coordinates belong The decoding information, the position information of the target vertex corresponding to the first pixel coordinate in the target two-dimensional code, and the target marking plate to which the first pixel coordinate belongs, the target marking plate is the The first calibration plate or the second calibration plate.

根据所述第一像素坐标的定位信息,从所述第二像素坐标集合中确定出与所述第一像素坐标相匹配的所述第二像素坐标。The second pixel coordinates matching the first pixel coordinates are determined from the second pixel coordinate set according to the positioning information of the first pixel coordinates.

根据所述第一像素坐标以及与所述第一像素坐标相匹配的所述第二像素坐标,生成一个目标像素坐标集合。A set of target pixel coordinates is generated according to the first pixel coordinates and the second pixel coordinates matching the first pixel coordinates.

本说明书实施例中,在从第一像素坐标集合中选择出第一像素坐标x1,解析第一像素坐标x1的像素坐标信息,得到该第一像素坐标x1所归属的目标顶点a的位置信息,根据目标顶点a的位置信息得到目标顶点a所归属的目标二维码b的位置信息,对目标二维码b进行解析,确定目标二维码b所归属的目标标定板,目标标定板属于第一标定板或者第二标定板。然后根据目标标定板、目标二维码b的位置信息、目标顶点a的位置信息从第二像素坐标集合中确定出与之相匹配的第二像素坐标y1,第二像素坐标y1是将目标顶点a的世界坐标经世界坐标系与像素坐标系之间的转换关系转换后生成的像素坐标。在得到第一像素坐标x1与第一像素坐标y1后,根据第一像素坐标x1与第一像素坐标y1生成一个目标像素坐标集合。In the embodiment of this specification, after selecting the first pixel coordinate x 1 from the first pixel coordinate set, the pixel coordinate information of the first pixel coordinate x 1 is analyzed to obtain the target vertex a to which the first pixel coordinate x 1 belongs. Position information, according to the position information of the target vertex a, obtain the position information of the target two-dimensional code b to which the target vertex a belongs, analyze the target two-dimensional code b, determine the target calibration board to which the target two-dimensional code b belongs, and target calibration The board belongs to the first calibration board or the second calibration board. Then, 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, the second pixel coordinate y 1 matching it is determined from the second pixel coordinate set, and the second pixel coordinate y 1 is the The world coordinates of the target vertex a are transformed into pixel coordinates by the conversion relationship between the world coordinate system and the pixel coordinate system. After the first pixel coordinate x1 and the first pixel coordinate y1 are obtained, a target pixel coordinate set is generated according to the first pixel coordinate x1 and the first pixel coordinate y1 .

所述根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果,可以包括:The step of performing calibration processing on the camera according to the least squares problem to obtain a calibration result of the camera may include:

利用非线性优化算法对所述最小二乘问题进行迭代优化处理,得到所述最小二乘问题的计算结果。The nonlinear optimization algorithm is used to perform iterative optimization processing on the least squares problem to obtain the calculation result of the least squares problem.

判断所述最小二乘问题的计算结果是否小于等于预设阀值,得到判断结果。Judging whether the calculation result of the least squares problem is less than or equal to a preset threshold value to obtain a judgment result.

若所述判断结果表示所述最小二乘问题的计算结果小于等于预设阀值,则将与所述计算结果对应的相机参数,确定为所述相机的标定结果。If the judgment result indicates that the calculation result of the least squares problem is less than or equal to a preset threshold, then the camera parameters corresponding to the calculation result are determined as the calibration result of the camera.

所述相机的标定结果包括所述相机的相机内参标定结果及相机畸变系数标定结果。The calibration result of the camera includes the calibration result of the internal camera parameters and the calibration result of the camera distortion coefficient of the camera.

所述最小二乘问题的计算公式为: The calculation formula of the least squares problem is:

其中:argmin表示计算最小值、Ui表示所述第一像素坐标、Pi表示所述目标顶点在所述预设世界坐标系下的世界坐标、K表示所述相机的所述相机内参与所述相机畸变系数、T表示所述相机的相机外参、KTPi表示所述第二像素坐标、i表示所述目标顶点的数量。Among them: argmin represents the calculated minimum value, Ui represents the first pixel coordinates, Pi represents the world coordinates of the target vertex in the preset world coordinate system, K represents the participation of the camera in the camera Distortion coefficient, T represents the camera extrinsics of the camera, KTPi represents the second pixel coordinates, and i represents the number of target vertices.

本说明书实施例中,根据任意一个目标像素坐标集合,生成一个第一像素坐标与第二像素坐标的距离差,利用多个第一像素坐标与第二像素坐标的距离差,生成最小二乘问题的计算公式可以利用非线性优化算法对该最小二乘问题进行迭代优化处理。具体的迭代步骤可以为:In the embodiment of this specification, according to any set of target pixel coordinates, a distance difference between the first pixel coordinates and the second pixel coordinates is generated, and a least squares problem is generated by using multiple distance differences between the first pixel coordinates and the second pixel coordinates The calculation formula The nonlinear optimization algorithm can be used to iteratively optimize the least squares problem. The specific iterative steps can be:

步骤1:设置相机参数的初始值,开始优化处理。相机的横向焦距fx可以设置为相机的真实焦距/像元尺寸,相机的纵向焦距fy可以设置为相机的真实焦距/像元尺寸,相机的光心cx可以设置为图像的宽度/2,相机的光心cy可以设置为图像的高度/2。Step 1: Set the initial values of the camera parameters and start the optimization process. The horizontal focal length f x of the camera can be set to the real focal length/pixel size of the camera, the vertical focal length f y of the camera can be set to the real focal length/pixel size of the camera, and the optical center c x of the camera can be set to the width/2 of the image , the optical center c y of the camera can be set to the image height/2.

步骤2:调整相机参数,得出最小二乘问题的当前计算结果。对相机参数的调整可以为每次将相机参数迭代增加一个预设数值,该预设数值可以根据实际的需求设定。Step 2: Adjust the camera parameters to obtain the current calculation result of the least squares problem. The adjustment of the camera parameters can increase a preset value for each iteration of the camera parameters, and the preset value can be set according to actual needs.

步骤3:判断当前计算结果是否小于等于预设阀值,若当前计算结果大于预设阀值,则返回步骤2;若当前计算结果小于等于预设阀值,则停止迭代处理。预设阀值可以根据对相机标定结果准确性的要求进行设定。Step 3: Determine whether the current calculation result is less than or equal to the preset threshold, if the current calculation result is greater than the preset threshold, return to step 2; if the current calculation result is less than or equal to the preset threshold, stop the iterative process. The preset threshold can be set according to the requirements for the accuracy of the camera calibration results.

在对所构建的最小二乘问题进行优化迭代处理得到符合要求的计算结果后,获取此时相应的相机参数,该相机参数即为对相机进行标定后的标定结果,相机参数可以包含相机内参fx,fy,cx,cy、相机径向畸变参数k1,k2,k3、以及相机切向畸变参数p1,p2。其中,所利用的非线性优化算法可以为列文伯格—马夸尔特方法,也可以为其他能够实现对最小二乘问题进行求解的算法,本方案对该非线性优化算法不做具体限定。After optimizing and iteratively processing the constructed least squares problem to obtain the required calculation results, obtain the corresponding camera parameters at this time. The camera parameters are the calibration results after the camera is calibrated. The camera parameters can include the camera intrinsic parameter f x ,f y ,c x ,c y , camera radial distortion parameters k 1 ,k 2 ,k 3 , and camera tangential distortion parameters p 1 ,p 2 . Among them, the nonlinear optimization algorithm used can be the Levenberg-Marquardt method, or other algorithms that can solve the least squares problem. This scheme does not specifically limit the nonlinear optimization algorithm .

本说明书实施例中,通过构建最小二乘问题,可以实现多个目标顶点的观测像素坐标位置与投影位置之间的距离均满足预设要求。从而可以在多个目标顶点的观测像素坐标位置与投影位置之间的距离均满足预设要求的前提下,获取到相机的参数,以提升对相机参数进行标定的准确性。In the embodiment of this specification, by constructing the least squares problem, it can be realized that the distances between the observed pixel coordinate positions and the projected positions of multiple target vertices all meet the preset requirements. Therefore, the parameters of the camera can be obtained on the premise that the distances between the observed pixel coordinate positions and the projection positions of multiple target vertices meet the preset requirements, so as to improve the accuracy of calibration of the camera parameters.

基于同样的思路,本说明书实施例还提供了上述方法对应的装置。图7为本说明书实施例提供的对应于图1的一种相机标定装置的结构示意图。如图7所示,该装置可以包括:Based on the same idea, the embodiment of this specification also provides a device corresponding to the above method. FIG. 7 is a schematic structural diagram of a camera calibration device corresponding to FIG. 1 provided by the embodiment of this specification. As shown in Figure 7, the device may include:

获取模块702,用于获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案。The acquiring module 702 is configured to acquire a calibration image captured by the camera for the calibration object, where the target two-dimensional code pattern is drawn.

处理模块704,用于利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标。The processing module 704 is configured to use a two-dimensional code recognition algorithm to process the calibration image to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes The first pixel coordinates of the target vertex of the target two-dimensional code pattern identified in .

确定模块706,用于确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合。The determination module 706 is configured to determine the world coordinates of each target vertex in the preset world coordinate system to obtain a world coordinate set.

标定模块708,用于利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。The calibration module 708 is configured to use a camera calibration algorithm to perform camera calibration processing according to the first set of pixel coordinates and the set of world coordinates 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 at any two different poses, the calibration object includes a first calibration board and a second calibration board, and the first calibration The target two-dimensional code pattern is drawn on both the first calibration board and the second calibration board, and there is a preset angle between the first calibration board and the second calibration board.

可选的,所述标定模块708,可以包括:Optionally, the calibration module 708 may include:

第一确定单元,用于利用所述预设世界坐标系与所述预设像素坐标系之间的转换关系,确定所述世界坐标集合中的所述目标顶点的世界坐标对应的在所述预设像素坐标系下的第二像素坐标,得到第二像素坐标集合。The first determining unit is configured to use the conversion relationship between the preset world coordinate system and the preset pixel coordinate system to determine the world coordinate of the target vertex in the world coordinate set corresponding to the preset Set the second pixel coordinates in the pixel coordinate system to obtain a second set of pixel coordinates.

标定单元,用于利用相机标定算法,根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果。The calibration unit is configured to use a camera calibration algorithm to perform calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera.

可选的,所述标定单元,可以包括:Optionally, the calibration unit may include:

第一确定子单元,用于从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合;每个所述目标像素坐标集合中的各个像素坐标均归属于同一所述目标顶点,且所述目标像素坐标集合中包含一个所述第一像素坐标与一个所述第二像素坐标。The first determining subunit is 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 of the target pixel coordinate sets belongs to At the same target vertex, and the set of target pixel coordinates includes one of the first pixel coordinates and one of the second pixel coordinates.

构建子单元,用于根据各个所述目标像素坐标集合,构建最小二乘问题。A subunit is constructed, configured to construct a least squares problem according to each set of target pixel coordinates.

标定子单元,用于根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果。The calibration subunit is configured to perform 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 the 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 first pixel coordinates The decoding information of the target two-dimensional code, the position information of the target vertex corresponding to the first pixel coordinate in the target two-dimensional code, and the target calibration plate to which the first pixel coordinate belongs , the target calibration plate is the first calibration plate or the second calibration plate.

第一确定子单元具体用于根据所述第一像素坐标的定位信息,从所述第二像素坐标集合中确定出与所述第一像素坐标相匹配的所述第二像素坐标。The first determination subunit is specifically configured to determine the second pixel coordinates matching the first pixel coordinates from the second pixel coordinate set according to the positioning information of the first pixel coordinates.

第一确定子单元具体用于根据所述第一像素坐标以及与所述第一像素坐标相匹配的所述第二像素坐标,生成一个目标像素坐标集合。The first determining subunit is specifically configured to generate a set of target pixel coordinates according to the first pixel coordinates and the second pixel coordinates matching the first pixel coordinates.

可选的,所述标定子单元,可以包括:Optionally, the calibration subunit may include:

标定子单元具体用于利用非线性优化算法对所述最小二乘问题进行迭代优化处理,得到所述最小二乘问题的计算结果。The calibration subunit is specifically configured to use a nonlinear optimization algorithm to iteratively optimize the least squares problem to obtain a calculation result of the least squares problem.

标定子单元具体用于判断所述最小二乘问题的计算结果是否小于等于预设阀值,得到判断结果。The calibration subunit is specifically used to judge whether the calculation result of the least squares problem is less than or equal to a preset threshold value, and obtain the judgment result.

标定子单元具体用于若所述判断结果表示所述最小二乘问题的计算结果小于等于预设阀值,则将与所述计算结果对应的相机参数,确定为所述相机的标定结果。The calibration subunit is specifically configured to determine the camera parameter corresponding to the calculation result as the calibration result of the camera if the judgment result indicates that the calculation result of the least squares problem is less than or equal to a preset threshold.

可选的,所述相机的标定结果包括所述相机的相机内参标定结果及相机畸变系数标定结果。Optionally, the calibration result of the camera includes a calibration result of internal camera parameters and a calibration result of a camera distortion coefficient of the camera.

所述最小二乘问题的计算公式为: The calculation formula of the least squares problem is:

其中:argmin表示计算最小值、Ui表示所述第一像素坐标、Pi表示所述目标顶点在所述预设世界坐标系下的世界坐标、K表示所述相机的所述相机内参与所述相机畸变系数、T表示所述相机的相机外参、KTPi表示所述第二像素坐标、i表示所述目标顶点的数量。Among them: argmin represents the calculated minimum value, Ui represents the first pixel coordinates, Pi represents the world coordinates of the target vertex in the preset world coordinate system, K represents the participation of the camera in the camera Distortion coefficient, T represents the camera extrinsics of the camera, KTPi represents the second pixel coordinates, and i represents the number of target vertices.

基于同样的思路,本说明书实施例还提供了上述方法对应的设备。Based on the same idea, the embodiment of this specification also provides a device corresponding to the above method.

图8为本说明书实施例提供的对应于图1的一种相机标定设备的结构示意图。如图8所示,设备800可以包括:FIG. 8 is a schematic structural diagram of a camera calibration device corresponding to FIG. 1 provided by the embodiment of this specification. As shown in FIG. 8, device 800 may include:

至少一个处理器810;以及,at least one processor 810; and,

与所述至少一个处理器通信连接的存储器830;其中,a memory 830 communicatively coupled to the at least one processor; wherein,

所述存储器830存储有可被所述至少一个处理器810执行的指令820,所述指令被所述至少一个处理器810执行,以使所述至少一个处理器810能够执行所述指令以实现上述方法。The memory 830 stores instructions 820 executable by the at least one processor 810, the instructions are executed by the at least one processor 810, so that the at least one processor 810 can execute the instructions to achieve the above-mentioned method.

本发明还提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时以实现上述方法。The present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method can be realized.

应当理解,本说明书一个或多个实施例所述的方法中,部分步骤的顺序可以根据实际需要调整,或者可以省略部分步骤。It should be understood that in the methods described in one or more embodiments of this specification, the order of some steps may be adjusted according to actual needs, or some steps may be omitted.

本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于图8所示的设备以及计算机可读存储介质而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and the computer-readable storage medium shown in FIG. 8 , since they are basically similar to the method embodiments, the description is relatively simple, and for relevant parts, refer to the part of the description of the method embodiments.

以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above descriptions are only examples of the present application, and are not intended to limit the present application. For those skilled in the art, various modifications and changes may occur in this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims (10)

1.一种相机标定方法,其特征在于,包括:1. A camera calibration method, characterized in that, comprising: 获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案;Obtain the calibration image collected by the camera for the calibration object, in which the target two-dimensional code pattern is drawn; 利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标;Using a two-dimensional code recognition algorithm, the calibration image is processed to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes the identified from the calibration image The first pixel coordinate of the target vertex of the target two-dimensional code pattern; 确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合;Determining the world coordinates of each target vertex in the preset world coordinate system to obtain a set of world coordinates; 利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。A camera calibration algorithm is used to perform camera calibration processing according to the first set of pixel coordinates and the set of world coordinates to obtain a calibration result of the camera. 2.如权利要求1所述的方法,其特征在于,所述标定图像包括在任意两个不同位姿下针对标定物采集的第一标定图像与第二标定图像,所述标定物包含第一标定板与第二标定板,所述第一标定板与所述第二标定板中均绘制有所述目标二维码图案,所述第一标定板与所述第二标定板之间具有预设夹角。2. The method according to claim 1, wherein the calibration image comprises a first calibration image and a second calibration image collected for a calibration object under any two different poses, and the calibration object includes the first A calibration plate and a second calibration plate, the target two-dimensional code pattern is drawn in the first calibration plate and the second calibration plate, and there is a predetermined gap between the first calibration plate and the second calibration plate. Set angle. 3.如权利要求2所述的方法,其特征在于,所述利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果,包括:3. The method according to claim 2, wherein the camera calibration algorithm is used to perform camera calibration processing according to the first pixel coordinate set and the world coordinate set to obtain a calibration result of the camera, including : 利用所述预设世界坐标系与所述预设像素坐标系之间的转换关系,确定所述世界坐标集合中的所述目标顶点的世界坐标对应的在所述预设像素坐标系下的第二像素坐标,得到第二像素坐标集合;Using the conversion relationship between the preset world coordinate system and the preset pixel coordinate system, determine the world coordinate of the target vertex in the world coordinate set corresponding to the first pixel coordinate system under the preset pixel coordinate system Two pixel coordinates to obtain the second set of pixel coordinates; 利用相机标定算法,根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果。Using a camera calibration algorithm, perform calibration processing on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera. 4.如权利要求3所述的方法,其特征在于,所述根据所述第一像素坐标集合及所述第二像素坐标集合对所述相机进行标定处理,得到所述相机的标定结果,包括:4. The method according to claim 3, wherein the calibration process is performed on the camera according to the first set of pixel coordinates and the second set of pixel coordinates to obtain a calibration result of the camera, including : 从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合;每个所述目标像素坐标集合中的各个像素坐标均归属于同一所述目标顶点,且所述目标像素坐标集合中包含一个所述第一像素坐标与一个所述第二像素坐标;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 belongs to the same target vertex, and The set of target pixel coordinates includes one of the first pixel coordinates and one of the second pixel coordinates; 根据各个所述目标像素坐标集合,构建最小二乘问题;Constructing a least squares problem according to each set of target pixel coordinates; 根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果。Calibrate the camera according to the least square problem to obtain a calibration result of the camera. 5.如权利要求4所述的方法,其特征在于,所述从所述第一像素坐标集合以及所述第二像素坐标集合中,确定出至少一个目标像素坐标集合,包括:5. The method according to claim 4, wherein the determining at least one target pixel coordinate set from the first pixel coordinate set and the second pixel coordinate set comprises: 针对所述第一像素坐标集合中的任意一个所述第一像素坐标,确定所述第一像素坐标的定位信息;所述定位信息包括:所述第一像素坐标所归属的目标二维码的解码信息、所述第一像素坐标所对应的所述目标顶点在所述目标二维码中所处的位置信息以及所述第一像素坐标所归属的目标标定板,所述目标标定板为所述第一标定板或所述第二标定板;For any one of the first pixel coordinates in the first pixel coordinate set, determine the positioning information of the first pixel coordinates; the positioning information includes: the target two-dimensional code to which the first pixel coordinates belong The decoding information, the position information of the target vertex corresponding to the first pixel coordinate in the target two-dimensional code, and the target marking plate to which the first pixel coordinate belongs, the target marking plate is the The first calibration plate or the second calibration plate; 根据所述第一像素坐标的定位信息,从所述第二像素坐标集合中确定出与所述第一像素坐标相匹配的所述第二像素坐标;determining the second pixel coordinates matching the first pixel coordinates from the second pixel coordinate set according to the positioning information of the first pixel coordinates; 根据所述第一像素坐标以及与所述第一像素坐标相匹配的所述第二像素坐标,生成一个目标像素坐标集合。A set of target pixel coordinates is generated according to the first pixel coordinates and the second pixel coordinates matching the first pixel coordinates. 6.如权利要求4所述的方法,其特征在于,所述根据所述最小二乘问题对所述相机进行标定处理,得到所述相机的标定结果,包括:6. The method according to claim 4, wherein said calibration process is performed on said camera according to said least squares problem to obtain a calibration result of said camera, comprising: 利用非线性优化算法对所述最小二乘问题进行迭代优化处理,得到所述最小二乘问题的计算结果;performing iterative optimization processing on the least squares problem by using a nonlinear optimization algorithm to obtain a calculation result of the least squares problem; 判断所述最小二乘问题的计算结果是否小于等于预设阀值,得到判断结果;Judging whether the calculation result of the least squares problem is less than or equal to a preset threshold value, and obtaining the judgment result; 若所述判断结果表示所述最小二乘问题的计算结果小于等于预设阀值,则将与所述计算结果对应的相机参数,确定为所述相机的标定结果。If the judgment result indicates that the calculation result of the least squares problem is less than or equal to a preset threshold, then the camera parameters corresponding to the calculation result are determined as the calibration result of the camera. 7.如权利要求6所述的方法,其特征在于,所述相机的标定结果包括所述相机的相机内参标定结果及相机畸变系数标定结果;7. The method according to claim 6, wherein the calibration result of the camera comprises a calibration result of the internal camera parameters and a calibration result of the camera distortion coefficient of the camera; 所述最小二乘问题的计算公式为: The calculation formula of the least squares problem is: 其中:argmin表示计算最小值、Ui表示所述第一像素坐标、Pi表示所述目标顶点在所述预设世界坐标系下的世界坐标、K表示所述相机的所述相机内参与所述相机畸变系数、T表示所述相机的相机外参、KTPi表示所述第二像素坐标、i表示所述目标顶点的数量。Among them: argmin represents the calculated minimum value, Ui represents the first pixel coordinates, Pi represents the world coordinates of the target vertex in the preset world coordinate system, K represents the participation of the camera in the camera Distortion coefficient, T represents the camera extrinsics of the camera, KTPi represents the second pixel coordinates, and i represents the number of target vertices. 8.一种相机标定装置,其特征在于,包括:8. A camera calibration device, characterized in that, comprising: 获取模块,用于获取相机针对标定物采集到的标定图像,所述标定物中绘制有目标二维码图案;An acquisition module, configured to acquire a calibration image collected by the camera for a calibration object, wherein a target two-dimensional code pattern is drawn in the calibration object; 处理模块,用于利用二维码识别算法,对所述标定图像进行处理,得到在预设像素坐标系下的第一像素坐标集合;所述第一像素坐标集合中包含从所述标定图像中识别出的所述目标二维码图案的目标顶点的第一像素坐标;A processing module, configured to use a two-dimensional code recognition algorithm to process the calibration image to obtain a first set of pixel coordinates in a preset pixel coordinate system; the first set of pixel coordinates includes The identified first pixel coordinates of the target vertex of the target two-dimensional code pattern; 确定模块,用于确定各个所述目标顶点在预设世界坐标系下的世界坐标,得到世界坐标集合;A determining module, configured to determine the world coordinates of each target vertex in the preset world coordinate system, to obtain a world coordinate set; 标定模块,用于利用相机标定算法,根据所述第一像素坐标集合以及所述世界坐标集合进行相机标定处理,得到所述相机的标定结果。The calibration module is configured to use a camera calibration algorithm to perform camera calibration processing according to the first set of pixel coordinates and the set of world coordinates to obtain a calibration result of the camera. 9.一种相机标定设备,包括存储器、处理器及存储在存储器上的计算机程序,其特征在于:所述处理器执行所述计算机程序以实现权利要求1至7中任意一项所述方法的步骤。9. A camera calibration device, 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 method described in any one of claims 1 to 7 step. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该计算机程序被处理器执行时实现权利要求1至7中任意一项所述方法的步骤。10. A computer-readable storage medium, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
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
CN109598762B (en) High-precision binocular camera calibration method
CN110197466B (en) A wide-angle fisheye image correction method
US9886759B2 (en) Method and system for three-dimensional data acquisition
CN106600648A (en) Stereo coding target for calibrating internal parameter and distortion coefficient of camera and calibration method thereof
CN110189322B (en) Flatness detection method, device, equipment, storage medium and system
CN111260731A (en) Checkerboard sub-pixel level corner point self-adaptive detection method
CN110660107A (en) Plane calibration plate, calibration data acquisition method and system
CN113920205A (en) Calibration method of non-coaxial camera
CN112132907A (en) A camera calibration method, device, electronic device and storage medium
CN108581869B (en) Camera module alignment method
CN110033407B (en) Shield tunnel surface image calibration method, splicing method and splicing system
CN1975323A (en) Method for making three-dimensional measurement of objects utilizing single digital camera to freely shoot
WO2022126870A1 (en) Three-dimensional imaging method and method based on light field camera and three-dimensional imaging measuring production line
CN113592962B (en) Batch silicon wafer identification recognition method based on machine vision
CN114998448B (en) A method for multi-constrained binocular fisheye camera calibration and spatial point positioning
CN105701776B (en) A kind of lens distortion antidote and system for automatic optics inspection
CN111815710A (en) Automatic calibration method for fisheye camera
CN107680035B (en) Parameter calibration method and device, server and readable storage medium
CN112489141B (en) Production line calibration method and device for single-board single-image strip relay lens of vehicle-mounted camera
CN110261069A (en) Detection method for optical lens
CN110035279B (en) Method and device for searching SFR test area in checkerboard test pattern
CN117576219A (en) Camera calibration equipment and calibration method for single shot image of large wide-angle fish-eye lens
CN110443856A (en) A kind of 3D structure optical mode group scaling method, storage medium, electronic equipment
CN116524041A (en) Camera calibration method, device, equipment and medium
CN116883465A (en) Multispectral plant phenotype three-dimensional imaging method, system and device

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