Ask Your Question
1

Problem with some functions of SFM module

asked 2018-10-19 04:28:57 -0600

prater gravatar image

Hi!

I have installed OpenCV 4.0 (C++) with the contrib modules in Ubuntu 18.04 LTS. I had Ceres installed and working before building OpenCV and the other required libraries for SFM module (gflags,glog...), so I was careful about this point. The rest of modules seem to work fine. While generating the cmake file for building OpenCV, I checked that Ceres was detected. When trying to compile one of the examples in the documentation, for example https://docs.opencv.org/4.0.0-alpha/d...), the reconstruct() function is not compiling: the error is "src/StructureFromMotion.cpp:78:3: error: ‘reconstruct’ was not declared in this scope".

In the IDE I am using (Eclipse), it seems that among the functions in the SFM spacename, these ones are missing: fundamentalFromCorrespondences7PointRobust, fundamentalFromCorrespondences8PointRobust and the four reconstruct functions (comparing the available functions to the functions listed in the namespace SFM in the documentation). Among the ../include/opencv4/opencv2/sfm it seems to be all the .hpp files (compared to the GIT repository). In the ../lib there is the libopencv_sfm.so.

When trying to run some tests/examples that were compiled while building openCV, I get the next results:

1.)When running the compiled test_sfm I got the error (all the other test were passed):

[----------] 1 test from Sfm_simple_pipeline

[ RUN ] Sfm_simple_pipeline.backyard unknown file: Failure C++ exception with description "OpenCV(4.0.0-pre) /home/jbg/Descargas/opencv_contrib/modules/sfm/test/test_common.cpp:84: error: (-2:Unspecified error) in function 'parser_2D_tracks' Unable to read file: sfm/backyard_tracks.txt " thrown in the test body.

[ FAILED ] Sfm_simple_pipeline.backyard (0 ms)

[----------] 1 test from Sfm_simple_pipeline (0 ms total)

2.) When running the example_sfm_scene_reconstruction I get the error:

terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.0.0-pre) /home/jbg/Descargas/opencv_contrib/modules/sfm/src/reconstruct.cpp:241: error: (-215:Assertion failed) nviews >= 2 in function 'reconstruct'

I also tried things like defining the CERES_FOUND 1 or CERES_FOUND True, etc. but it did not work either. I also tried to rebuild OpenCV, reinstall CERES, etc.

I hope someone can help me. As you see, I have been reading about it and trying to fix it with different solutions but so far it did not work and I do not know how to move on.

Thank you very much in advance!

edit retag flag offensive close merge delete

Comments

you need the data from the opencv_extra repo, to run the tests successfully

berak gravatar imageberak ( 2018-10-19 04:41:42 -0600 )edit

Thanks for your answer.

Which data do you mean? for the reconstruction example I did give a path where there was the (I think) pictures used for that particular example with the given parameters.

For the other test what should I add?

Any clue about the compilation error of reconstruct function?

Thanks again

prater gravatar imageprater ( 2018-10-19 05:00:27 -0600 )edit

https://github.com/opencv/opencv_cont...

I also tried things like defining the CERES_FOUND 1

unfortunately, this has to happen at library build time.

(the sfm module will still build without proper ceres, you just can't reconstruct anything)

((maybe you need to add your cmake output to the question ?))

berak gravatar imageberak ( 2018-10-19 05:11:23 -0600 )edit

Thanks again!

The cmake file is pretty big and I do not know how to attach it. In any case, what it may would be the relevant part for this case: Found required Ceres dependency: Eigen, Found required Ceres dependency: glog, Found required Ceres dependency: gflags, Found Ceres version: 2.0.0 installed, Checking SFM deps... TRUE. - .... - OpenCV modules: To be built: ... sfm ...

So apparently it has been detected at the build time. I have seen it does not detect for example Atlas, although it is installed, and I don't have OpenBlas. In the other third-party libraries, "Lapack: NO", Eigen: YES and Ceres is not listed at all. Do you think it could be due to this?

prater gravatar imageprater ( 2018-10-19 06:14:10 -0600 )edit
1

Can you try match_reconstruct.cpp?

ceres version 2.0 ? see https://ceres-solver.googlesource.com...

LBerger gravatar imageLBerger ( 2018-10-19 06:20:55 -0600 )edit
1

no, neither atlas nor openblas are used here. the sfm deps are:

  • ceres
  • glog
  • gflags
  • eigen

@LBerger, please take over here ;) (and nice, to have you back !)

berak gravatar imageberak ( 2018-10-19 06:26:32 -0600 )edit

Thanks for your support. Ok, I think it may has something to do with the Ceres I have installed (it seems I am in the future already)...I will reinstall Ceres with the linked source and build again. I will give you feedback when done!

prater gravatar imageprater ( 2018-10-19 06:34:16 -0600 )edit

But it is strange. I did install Ceres using exactly that guide and everything seemed to work fine. I did calculate the suggested example without any problem. But why does it say I have Ceres version 2.0 if the latest version is 1.14??? @LBerger

When running ldconfig -v | grep ceres I get: libceres.so.2 -> libceres.so.2.0.0 /sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-2.27.so is the dynamic linker, ignoring libceres.so.1 -> libceres.so.1.13.0

I have seen that I do not have any "ceres.pc" in the pkgconfig folder of .../include but I have the ceres.so library in .../lib. May does it have to do with this?

prater gravatar imageprater ( 2018-10-19 06:45:29 -0600 )edit

My system is window I cannot help you with your configuration. My cmake output gives Found Ceres version: 1.13.0 installed in: G:/Lib/install/ceres-solver

Now if can you can run my example match_reconstruct.cpp I think that ceres is installed

LBerger gravatar imageLBerger ( 2018-10-19 06:56:50 -0600 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2018-11-01 05:34:37 -0600

prater gravatar image

updated 2018-11-01 09:00:52 -0600

Finally I have managed to solve it! I will leave here a more or less detailled description about how I did it. I was able to build the example https://docs.opencv.org/master/d4/d18... manually using the IDE Eclipse. BTW I built OpenCV in an external hard disk.

It turned out that the source of errors was multiple.

  • First of all, although I had Ceres (installed and working), it was somehow not detected, not during the installation (it did work then and everything installed right), but when using the reconstruct.hpp, maybe due to a "conflict" between my ceres version and my Eigen version. I solved this by commenting out the lines //#if defined(CV_DOXYGEN) || defined(CERES_FOUND) //#endif /* CV_DOXYGEN || CERES_FOUND */ in the file reconstruct.hpp file placed at usr/local/include/opencv4/opencv2/sfm

  • Second, I realised that the 3rdParty libraries (correspondence.a, multiview.a, numeric.a and simple_pipeline.a) were not installed directly in usr/local/lib as all the others libraries installed with OpenCV (where all the opencv_xxx.os are), but in usr/local/lib/opencv4/3rdparty. Hence, I added additional paths in order to access these required libraries for reconstruct.

    So finally, in the IDE Eclipse I was using, the libraries I included and linked and the paths I gave to make it work with the C++ compiler GCC C++ (I am aware there are some redundant and not necessary, but with this configuration it worked for me) are: Include paths (-l): /usr/local/include/opencv4, /usr/local/include/vtk-8.1, /usr/local/include Include files (-include): /usr/local/include/opencv4/opencv2/sfm/reconstruct.hpp, /usr/local/include/opencv4/opencv2/viz,viz3d.hpp

Library search path (-L): usr/local/lib, usr/local/lib/opencv4/3rdparty Libraries (-l): opencv_core, opencv_viz, numeric, simple_pipeline, multiview, correspondence, ceres, opencv_sfm, opencv_imgproc, opencv_imgcodecs, opencv_highgui, opencv_ml, opencv_features2d, opencv_calib3d, opencv_objdetect, opencv_flann

  • Third, there is some wrong versions of the structure from motion examples around, where the part regarding visualisation using the viz module has a couple of wrong lines. Use the code of the official OpenCV repository.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-19 04:28:57 -0600

Seen: 2,213 times

Last updated: Nov 01 '18