【发布时间】:2015-10-24 16:25:49
【问题描述】:
我已经使用OpenCv代码here获得了相机矩阵、畸变系数、(旋转+平移)矢量和图像点等相机标定参数。
通过在 Matlab 中对相机矩阵、旋转 + 平移向量和对象点坐标 (X,Y,Z,1) 的获得值进行硬编码,我无法获得与图像点相同的坐标值。我在这里想念什么?我是否也需要考虑失真系数以获得准确或正确的图像点?
Matlab 代码:
% Define all the parameters camera matrix , sample image point, object point, rotation and translation vectors%
cameraMatrix = [5.9354 0 3.1950; 0 5.9354 2.3950 ; 0 0 1]
rotationMatrix = [2.5233 1.6803 3.0728];
translationMatrix = [1.2682 1.9657 8.0141];
X = [0; 0; 0; 1];
rotationMatrix = transpose(rotationMatrix);
translationMatrix = transpose(translationMatrix);
%convert the rotation vector into rotation matrix using Rodrigues func.%
rotMat = rodrigues(rotationMatrix);
R_T = horzcat(rotMat, translationMatrix)
%Convert to 2D points%
imgPts = cameraMatrix * R_T * X
lastElement = imgPts(end);
ScreenImgPts = imgPts / lastElement
对象点由棋盘方格(30mm)的方格大小定义,即[0,0,0,1]、[30,0,0,1]等
但是经过我的计算和比较后,存储在 xml 文件中的图像点并不相同。我的结果如下
- 4.1343 3.8508 [0, 0, 0, 1]
- 3.8373 1.0331 [30, 0, 0, 1]
- 3.8002 0.6812 [60, 0, 0, 1]
第一个点、第二个点和第三个点的输出(图像点)应该是:
- 4.13546326e+002 3.85645935e+002
- 3.91346527e+002 3.85897003e+002
- 3.69121155e+002 3.86479431e+002
所有参数的输出文件为here
【问题讨论】:
标签: c++ matlab opencv image-processing