Ask Your Question

Revision history [back]

Sfm module : test code needed

Hi,

Thanks in advance to test this code. It's about sfm module. Result should be an exception and error source could be data (may be not well formatted) or this line

#include <opencv2/opencv.hpp> 
#include <opencv2/sfm.hpp> 
int main (int argc,char **argv)
{
    vector<Mat> pt2d;
    pt2d.push_back((Mat_<double>(1, 16) << 64., 298., 560., 405., 271., 298., 514., 417., 651., 435., 561, 373., 497., 369., 350., 241));
    pt2d.push_back((Mat_<double>(1,16)<< 62., 272., 5.1840002441406250e+02, 4.1817602539062500e+02, 268.,266., 513., 359., 649., 371., 559., 227., 495., 229., 346., 205.));
    pt2d.push_back((Mat_<double>(1, 16) << 362., 185., 650., 304., 160., 248., 364., 192., 78., 146., 357.,176., 247., 402., 76., 149));
    pt2d.push_back((Mat_<double>(1, 16) << 668., 296., 5.9040000915527344e+01, 3.8880001831054688e+02,6.5520001220703125e+02, 2.6496002197265625e+02,
        4.9447909545898438e+02, 2.9382092285156250e+02,4.6800003051757813e+01, 9.9600006103515625e+01,5.1120001220703125e+02, 4.1280001831054688e+02,
        1.3080000305175781e+02, 2.4600001525878906e+02,2.6873861694335938e+02, 1.1197442626953125e+02 ));
    for (int i=0;i<pt2d.size();i++)
        pt2d[i]= pt2d[i].reshape(2);
    Vec2d track_pt = pt2d[0].col(0).at<Vec2d>(0);
    vector<Mat> Rs_est, ts_est, points3d_estimated;
    Mat ps,pt3d, K = (cv::Mat_<float>(3, 3) << 350, 0, 240, 0, 350, 360, 0, 0, 1);
    reconstruct(pt2d, Rs_est, points3d_estimated, K, true);
return 0;
}