OpenCV:访问矩阵的值

时间:2017-06-30 07:20:08

标签: c++ opencv matrix

我正在使用OpenCV函数decomposeHomographyMat()。因为我想从OpenCV函数stereoRectifyUncalibrated()中分解我的H1和H2矩阵。

仅仅为了测试,我想将旋转和平移相乘,以查看结果是否相同,一切正常。

decomposeHomographyMat(H1, Mat(Identity), result_rot, result_trans, result_normals);

Matx44f rotM(result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), 0,
               result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), 0,
               result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), result_rot[id].at<float>(0,0), 0,
               0, 0, 0, 1);
    Matx44f transM(1, 0, 0, result_trans[id].at<float>(0,0),
                   0, 1, 0, result_trans[id].at<float>(0,1),
                   0, 0, 1, result_trans[id].at<float>(0,2),
                   0, 0, 0, 1);

H1 = Mat(transM) * Mat(rotM);

我知道对于rotM矩阵,我一直引用相同的值,这是暂时的。

我的问题是,如果我打印出result_rot [id]和rotM,我会得到weir结果:

result_rot[id]: [0.9920521909211247, -0.1258265282306712, 0.0003678069998755973;
 0.1258266147675855, 0.9920522232074044, -0.0002223635722913286;
 -0.0003369043855492455, 0.0002668761040765017, 0.9999999076363849]

rotM: [-0.015474273, -0.015474273, -0.015474273, 0;
 -0.015474273, -0.015474273, -0.015474273, 0;
 -0.015474273, -0.015474273, -0.015474273, 0;
 0, 0, 0, -0.99892187]

值-0.015474273在原始rotationmatrix中不均匀,值1似乎存储为-0.99892187。 我也尝试用double替换float,然后结果再次改变,但仍然不正确。

如何正确获取存储在该矩阵中的正确值?这里出了什么问题?

0 个答案:

没有答案