Hello,
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](https://github.com/Itseez/opencv_contrib/issues/476) and [this](https://github.com/Itseez/opencv_contrib/issues/636) for the details).
I can run the example code for the [SFM trajectory reconstruction](http://docs.opencv.org/3.1.0/d5/dab/tutorial_sfm_trajectory_estimation.html#gsc.tab=0)
Also, I can compile and run a cpp code with a similar code (see this [issue](https://github.com/Itseez/opencv_contrib/issues/476))
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/reconstruction_test.py", line 232, in
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.
Regards,
Miguel
↧