Error using SFM with Python [closed]

asked 2016-04-23 11:44:10 -0500

mriemoliveira gravatar image


I am trying to use the SFM opencv contrib module with python3.

After dealing with a couple of problems, I can now access to all the SFM functions from python3, e.g. help(cv2.sfm) shows all the functions (see this and this for the details).

I can run the example code for the SFM trajectory reconstruction

Also, I can compile and run a cpp code with a similar code (see this issue)

All this to say that my sfm seems to be working fine.

The problem is when I try to acces it from python.

I get

bash OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in getMatRef, file /home/mike/workingcopy/opencv/modules/core/src/matrix.cpp, line 2675 Traceback (most recent call last): File "/home/mike/catkin_ws/src/v4v/opencv_tests/src/", line 232, in <module> cv2.sfm.reconstruct2(points2d=tracks, Rs=Rs_est, Ts=ts_est, K=K, is_projective=True, points3d=points3d_est) cv2.error: /home/mike/workingcopy/opencv/modules/core/src/matrix.cpp:2675: error: (-215) k == STD_VECTOR_MAT in function getMatRef

This is in

cpp Mat(R).copyTo(Rs.getMatRef(i));

in function cpp virtual void getCameras(OutputArray Rs, OutputArray Ts)

in file simple_pipeline.cpp

I think it has something to do with the way I am initializing the np.arrays from the python side for the Ts, Rs OutputArrays.

How should I initialize in python the variables that go in the reconstruct function (points2d, K, Rs, Ts and points3d)

python reconstruct2(...) reconstruct2(points2d, K[, Rs[, Ts[, points3d[, is_projective]]]]) -> Rs, Ts, K, points3d

Any help would be appreciated.



edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-21 07:16:35.083720