2016-01-13 134 views
1

我使用的OpenCV stereoRectify有许多问题,这些都是我的变量:cvGEMM断言OpenCV中

Mat K_02 = (Mat_<double>(3,3) << 9.597910e+02, 0.000000e+00, 6.960217e+02, 
        0.000000e+00, 9.569251e+02, 2.241806e+02, 
        0.000000e+00, 0.000000e+00, 1.000000e+00); 

    Mat K_03 = (Mat_<double>(3,3) << 9.037596e+02, 0.000000e+00, 6.957519e+02, 
        0.000000e+00, 9.019653e+02, 2.242509e+02, 
        0.000000e+00, 0.000000e+00, 1.000000e+00); 

    Mat D_02 = (Mat_<double>(1,5) << -3.691481e-01, 1.968681e-01, 1.353473e-03, 5.677587e-04, -6.770705e-02); 
    Mat D_03 = (Mat_<double>(1,5) << -3.639558e-01, 1.788651e-01, 6.029694e-04, -3.922424e-04, -5.382460e-02); 

    Mat R_02 = (Mat_<double>(3,3) << 9.999758e-01, -5.267463e-03, -4.552439e-03, 
        5.251945e-03, 9.999804e-01, -3.413835e-03, 
        4.570332e-03, 3.389843e-03, 9.999838e-01); 
    transpose(R_02,R_02); 

    Mat R_03 = (Mat_<double>(3,3) << 9.995599e-01, 1.699522e-02, -2.431313e-02, 
        -1.704422e-02, 9.998531e-01, -1.809756e-03, 
        2.427880e-02, 2.223358e-03, 9.997028e-01); 

    Mat T_02 = (Mat_<double>(1,3) << 5.956621e-02, 2.900141e-04, 2.577209e-03); 
    Mat T_03 = (Mat_<double>(1,3) << -4.731050e-01, 5.551470e-03, -5.250882e-03); 

    Mat rotation = cv::Mat::zeros(3, 3, R_03.type()); 
    Mat translation = cv::Mat::zeros(1, 3, T_03.type()); 
    rotation = R_02 * R_03; 
    translation = T_02 - T_03; 

使用KITTI数据集中获得这些变量,现在我想获得Q矩阵重建现场,问题是,使用stereoRectify

Mat R1,R2,P1,P2,Q; 
stereoRectify(K_02, D_02, K_03, D_03, size, rotation, translation, R1, R2, P1, P2, Q); 

是给我一个可怕的断言:

OpenCV Error: Assertion failed ((D.rows == ((flags & CV_GEMM_A_T) == 0 ? A.rows : A.cols)) && (D.cols == ((flags & CV_GEMM_B_T) == 0 ? B.cols : B.rows)) && D.type() == A.type()) in cvGEMM, file /build/buildd/opencv-2.4.9+dfsg/modules/core/src/matmul.cpp, line 3150 

我无法调试它,因为gdb(throught Kdevelop)找不到openCV的源代码(我已经使用存储库安装了它)。我在网上看到了如何使用这个函数,但它总是使用stereoCalibrate函数的输出,所以我不知道哪个是用于定义我的内在矩阵的正确类型。

有人可以给我如何避免断言提示吗?

回答

1

这个问题似乎是在矩阵translation。您有错误,因为您要将rotation3x3)与translation1x3)相乘。

只需调换translation matrix使用:

transpose(translation, translation); 

或创建T_02T_03Mat_<double>(3, 1),而不是Mat_<double>(1, 3)

让您拥有一个乘法(3x3) x (3x1)

+0

谢谢老兄! – Luca