相机校准(OpenCV 2.3)-如何使用失真参数? [英] Camera calibration (OpenCV 2.3) - how to use the distortion parameters?

查看:314
本文介绍了相机校准(OpenCV 2.3)-如何使用失真参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组带有一些附加标记的刚体图像.我在这些标记之一中定义了一个以原点为坐标的坐标系,我想获得该坐标系与在相机原点处定义的坐标系之间的旋转和平移.

I have a set of images of a rigid body with some attached markers. I defined a coordinate system with origin in one of these markers and I want to get the rotation and translation between this coordinate system and the one defined at the camera's origin.

我尝试POSIT一段时间(遵循),直到没有得到可接受的结果,直到我意识到我有首先校准相机.基于,并使用通过校准体获取的一些图像,我获得了相机固有矩阵和失真参数.我还遇到了严重的(?)重新投影错误1.276.

I tried for some time POSIT (following this) without ever getting acceptable results, until I realized that I had to calibrate the camera in first place. Based on this and using some images acquired with a calibration body, I got the camera intrinsics matrix and the distortion parameters. I also got a bad (?) re-projection error of 1.276.

  1. 重投影误差是否过高?我该如何改善? (我使用了更多图像,但值却略有下降).
  2. 我可以在POSIT中使用失真参数吗?怎么样?

谢谢.

看来,减少重投影错误(从〜1.3更改为〜0.7)的唯一方法是将XML配置文件中的以下参数设置为"0":

It seems that the only way to get a decrease in the reprojection error (it changed from ~1.3 to ~0.7) is by setting to '0' the following parameters in the XML configuration file:

<Calibrate_FixAspectRatio> 0 </Calibrate_FixAspectRatio>
<Calibrate_AssumeZeroTangentialDistortion> 0 </Calibrate_AssumeZeroTangentialDistortion>
<Calibrate_FixPrincipalPointAtTheCenter> 0 </Calibrate_FixPrincipalPointAtTheCenter>

使用更多图像不会改变错误,我仍然不确定这个新错误是否可以接受.

Using more images doesn't change the error and I'm still not sure if this new error is acceptable or not.

我在POSIT中使用了校准输出的值(即焦距和光学中心),但是结果与我使用预校准值时得到的结果非常相似.我之所以没有使用失真参数,是因为我不知道如何在POSIT中处理这些参数(它们能否在结果上有所作为?).

I used the values that the calibration gave as output (namely the focal length and the optical centre) in POSIT but the results were very similar to the ones I got when I was using pre-calibration values. I didn't use the distortion parameters because I don't know how to handle them in POSIT (could they make a difference in the results?).

我在校准后得到的相机矩阵:

The camera matrix I got after the calibration:

<Camera_Matrix type_id="opencv-matrix">
<rows>3</rows>
<cols>3</cols>
<dt>d</dt>
<data>
2.0613885351075501e+003 0. 2.2865517805186334e+002 0.
2.2546461307897816e+003 2.5261706201677623e+002 0. 0. 1.
</data>
</Camera_Matrix>

以及我在POSIT中使用它的方式:

and the way I used it in POSIT:

#define FOCAL_LENGTH 2158.0175
#define FOCAL_LENGTH_X 2061.389 
#define FOCAL_LENGTH_Y 2254.646
#define cX 203.655
#define cY 205.117

我计算了新的中心坐标与用于校准图像的中心坐标之间的差,然后将该差应用于我正在处理POSIT的图像的中心坐标.

I calculated the difference between the new centre coordinates and the one for the calibration images and then applied that difference on the centre coordinates of the images on which I'm working with POSIT.

我在两个不同的图像上使用POSIT,理论上我应该在模型和相机坐标系之间获得0(第一个)旋转和10(第二个)旋转的角度.在获得每个图像的旋转矩阵后,我在相机坐标系上定义了一个单位向量,并通过使用POSIT给出的两个旋转矩阵的逆来对其进行多重运算,从而在模型坐标系上对其进行了计算,从而在模型中获得了两个新向量坐标系.当我在模型坐标系中计算这两个向量之间的角度时,输出的结果不是应该的-10度.

I'm using POSIT on two different images where theoretically I should get a rotation of 0 (for the first) and 10 (for the second) degrees between the model and the camera coordinate system. After I get the rotation matrix for each image, I defined a unit vector on the camera coordinate system and computed it on the model coordinate system by multypling it by the inverse of the two rotation matrices given by POSIT, getting two new vectors in the model coordinate system. When I calculate the angle between these two vectors in the model coordinate system, the output isn't as it should be - 10 degrees.

有人知道我要去哪里错吗?

Does anyone have an idea where am I going wrong?

推荐答案

图像分辨率是多少?主点应靠近图像中心.镜头的焦距是多少?根据您需要的精度,该校准误差可能很好. 为了避免由镜头失真引起的误差,您应该使用undistortPoints使传递到POSIT的图像点不失真.该误差有多大取决于镜头的畸变程度.

Which is the image resolution? The principal point should be close to the image center. which is the focal length of the lens? That calibration error could be fine depending on the precision that you need. In order to avoid the error introduced by the lens distortion you should undistort the image points passed to POSIT using undistortPoints. How big is this error depends on how big is the distortion of your lens.

这篇关于相机校准(OpenCV 2.3)-如何使用失真参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆