Ask Your Question
0

Dynamic Structure from Motion with SFM Module in opencv_contrib

asked 2018-04-12 22:04:28 -0600

updated 2018-04-14 15:14:25 -0600

LBerger gravatar image

Hello everyone,

I stumbled upon this tutorial and have ran through the tutorial with some success: https://docs.opencv.org/3.1.0/d4/d18/...

It doesn't always work on some of my downloaded image sets, but I figured I could use the reconstruct() function to dynamically build up a point cloud using a camera stream.

I am having a hard time prototyping it by feeding it two images at a time in a loop and displaying the resultant point cloud.

Can anyone provide any information or pointers on how to help out? or what I should try?

My next step was to try and pass the images to a function, then find matching points and pass that to the reconstruct() function for it to do the bundle adjustments.

That may work better than passing the images directly since it will not have to worry about finding them. Not sure.

Any insight would be helpful. Thanks! :

   vector<Mat> Rs_est, ts_est, points3d_estimated;

    cout <<"Opening Images..."<<endl;

    for(int i = 0; i<images_paths.size(); i++)
    {
        images.push_back(imread(images_paths[i], IMREAD_GRAYSCALE));
        imshow("Loaded Image", images[i]);
        waitKey(0);
    }

    cout <<"Opened Images..."<<endl;

    cout<<"reconstructing..."<<endl;
    reconstruct(images, Rs_est, ts_est, K, points3d_estimated, is_projective);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-04-13 02:30:33 -0600

LBerger gravatar image

updated 2018-04-14 15:18:02 -0600

may be this link can help you

may be this sample can help you too. reconstruct funcion is called at line reconstruct(pt2d1, Rs_est1, ts_est1, Kr, pt3d1, true); reconstruct here is used when images are matched.

In your case reconstruct(images, Rs_est, ts_est, K, points3d_estimated, is_projective); images should be color image

edit flag offensive delete link more

Comments

I'll have to look through that! Thank you!

I also had a question that you may be able to answer! I posted it on the opencv Github:

In the examples, I see you can pass a vector of image strings or this InputArrayOfArrays parameter that is defined as "Input vector of vectors of 2d points (the inner vector is per image)."

In the trajectory reconstruction example, I see that the points2d variable is a Mat type. Can I get some clarification of what the contents of the variable should look like?

How would I take features that I found between two images and pass it on to this function?

Thanks in advance!

The URL to the documentation I am using: https://docs.opencv.org/3.1.0/da/db5/...

atomoclast gravatar imageatomoclast ( 2018-04-13 02:44:41 -0600 )edit

Hello,

So I changed my loop to look like this:

for(int i = 0; i<images_paths.size(); i++) { images.push_back(imread(images_paths[i], CV_LOAD_IMAGE_COLOR)); }

And still got the same error.

OpenCV(3.4.1) Error: Assertion failed (data && dims <= 2 && (rows == 1 || cols == 1) && rows + cols - 1 == n && channels() == 1) in operator cv::Vec<_Tp, m>, file /home/andrew/opencv_source/opencv/modules/core/include/opencv2/core/mat.inl.hpp, line 1282 terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(3.4.1) /home/andrew/opencv_source/opencv/modules/core/include/opencv2/core/mat.inl.hpp:1282: error: (-215) data && dims <= 2 && (rows == 1 || cols == 1) && rows + cols - 1 == n && channels() == 1 in function operator cv::Vec<_Tp, m>

atomoclast gravatar imageatomoclast ( 2018-04-14 15:28:11 -0600 )edit

To check myself even further:

InputArrayOfArrays test(images); int total = test.total(); cout <<"Total: " << total << endl;

Got: Total: 3

So it is getting three images.

atomoclast gravatar imageatomoclast ( 2018-04-14 15:36:29 -0600 )edit

I can reproduce your issue : you cannot give a vector< Mat > when mat is an image. You must save images on disk and gives a vector< String > to reconstruct

LBerger gravatar imageLBerger ( 2018-04-15 11:39:05 -0600 )edit

iam sorry for bothering you but what are the constraints that i have to apply to prove a success of getting point cloud out of set of images thanks in advance ...

gaber gravatar imagegaber ( 2018-06-12 03:53:07 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-12 22:04:28 -0600

Seen: 617 times

Last updated: Apr 14 '18