cdcseacave / openMVS

open Multi-View Stereo reconstruction library
http://cdcseacave.github.io
GNU Affero General Public License v3.0
3.38k stars 910 forks source link

Use OpenSfM exported result inside OpenMVS #209

Open btchouston opened 7 years ago

btchouston commented 7 years ago

Specifications like the version of the project, operating system, and hardware

You can have Specifications inside error down here.

Steps to reproduce the problem

run the command "DensifyPointCloud -i path_to_exported_scene.mvs" i get the following error :

11:18:17 [App ] Build date: Mar 17 2017, 11:50:31 11:18:17 [App ] CPU: Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz 11:18:17 [App ] RAM: 7.60GB Physical Memory 5.70GB Virtual Memory 11:18:17 [App ] OS: Linux 3.13.0-93-generic (x86_64) 11:18:17 [App ] warning: no AVX compatible CPU or OS detected 11:18:17 [App ] Command line: scene.mvs terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Abandon (core dumped)

Can someone help to know what is hapening there ? Am i making a mistake ? How can I use OpenSfM exported result inside OpenMVS ?

Tank you.

cdcseacave commented 7 years ago

It looks like the MVS file is corrupted. My guess is that the opensfm\src\third_party\openmvs\Interface.h is old, and even though I tried to keep compatibility with all versions, I missed something.

In short, a solution is to simply replace that file with the latest version you find in OpenMVS\libs\MVS and recompile OpenSfM.

btchouston commented 7 years ago

Tank you @cdcseacave . I try it and let you know the result.

btchouston commented 7 years ago

I get the following error during compilation :

Scanning dependencies of target depthmap_test [ 95%] Building CXX object CMakeFiles/depthmap_test.dir/depthmap_test.cc.o [ 97%] Linking CXX executable depthmap_test CMakeFiles/depthmap_test.dir/depthmap_test.cc.o: In function (anonymous namespace)::PlaneInducedHomography_RandomPoint_Test::TestBody()': depthmap_test.cc:(.text+0x173e): undefined reference tocv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' depthmap_test.cc:(.text+0x17b8): undefined reference to cv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' CMakeFiles/depthmap_test.dir/depthmap_test.cc.o: In function(anonymous namespace)::Backproject_Reprojection_Test::TestBody()': depthmap_test.cc:(.text+0x20b2): undefined reference to `cv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' collect2: error: ld returned 1 exit status CMakeFiles/depthmap_test.dir/build.make:108: recipe for target 'depthmap_test' failed make[2]: [depthmap_test] Error 1 CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/depthmap_test.dir/all' failed make[1]: [CMakeFiles/depthmap_test.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... In file included from /home/odroid/OpenSfM/opensfm/src/openmvs_exporter.h:3:0, from /home/odroid/OpenSfM/opensfm/src/csfm.cc:13: /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:139:6: error: redefinition of ‘bool ARCHIVE::Save(ARCHIVE::ArchiveSave&, const _Tp&) [with _Tp = unsigned int]’ bool Save(ArchiveSave& a, const TYPE& v) { \ ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:151:1: note: in expansion of macro ‘ARCHIVE_DEFINE_TYPE’ ARCHIVE_DEFINE_TYPE(size_t) ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:139:6: note: ‘bool ARCHIVE::Save(ARCHIVE::ArchiveSave&, const _Tp&) [with _Tp = unsigned int]’ previously declared here bool Save(ArchiveSave& a, const TYPE& v) { \ ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:150:1: note: in expansion of macro ‘ARCHIVE_DEFINE_TYPE’ ARCHIVE_DEFINE_TYPE(uint32_t) ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:144:6: error: redefinition of ‘bool ARCHIVE::Load(ARCHIVE::ArchiveLoad&, _Tp&) [with _Tp = unsigned int]’ bool Load(ArchiveLoad& a, TYPE& v) { \ ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:151:1: note: in expansion of macro ‘ARCHIVE_DEFINE_TYPE’ ARCHIVE_DEFINE_TYPE(size_t) ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:144:6: note: ‘bool ARCHIVE::Load(ARCHIVE::ArchiveLoad&, _Tp&) [with _Tp = unsigned int]’ previously declared here bool Load(ArchiveLoad& a, TYPE& v) { \ ^ /home/odroid/OpenSfM/opensfm/src/third_party/openmvs/Interface.h:150:1: note: in expansion of macro ‘ARCHIVE_DEFINE_TYPE’ ARCHIVE_DEFINE_TYPE(uint32_t) ^ CMakeFiles/csfm.dir/build.make:62: recipe for target 'CMakeFiles/csfm.dir/csfm.cc.o' failed make[2]: [CMakeFiles/csfm.dir/csfm.cc.o] Error 1 CMakeFiles/Makefile2:180: recipe for target 'CMakeFiles/csfm.dir/all' failed make[1]: [CMakeFiles/csfm.dir/all] Error 2 Makefile:94: recipe for target 'all' failed make: [all] Error 2 Building package running build running build_py creating build creating build/lib.linux-armv7l-2.7 creating build/lib.linux-armv7l-2.7/opensfm copying opensfm/video.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/context.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/geotag_from_gpx.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/align.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/dense.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/dataset.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/multiview.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/sensors.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/reconstruction.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/transformations.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/matching.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/exif.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/init.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/unionfind.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/config.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/mesh.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/features.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/types.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/io.py -> build/lib.linux-armv7l-2.7/opensfm copying opensfm/geo.py -> build/lib.linux-armv7l-2.7/opensfm creating build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/compute_depthmaps.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/undistort.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/detect_features.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/extract_metadata.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/export_openmvs.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/match_features.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/init.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/export_visualsfm.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/create_tracks.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/export_ply.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/mesh.py -> build/lib.linux-armv7l-2.7/opensfm/commands copying opensfm/commands/reconstruct.py -> build/lib.linux-armv7l-2.7/opensfm/commands creating build/lib.linux-armv7l-2.7/opensfm/data copying opensfm/data/sensor_data.json -> build/lib.linux-armv7l-2.7/opensfm/data running build_scripts creating build/scripts-2.7 copying bin/opensfm_run_all -> build/scripts-2.7 copying and adjusting bin/opensfm -> build/scripts-2.7 changing mode of build/scripts-2.7/opensfm from 664 to 775

paulinus commented 7 years ago

The above error message seems to be from the old Interface.h version in OpenSfM, not the newer one from openMVS.

Are you using a 32-bit system? size_t and uint32_t seem to be the same.

I've seen this error once and solved it by commenting line 151. That is line 219 on the current version of that file in openMVS

cdcseacave commented 7 years ago

@paulinus thx, I was about to write exactly the same, I guess a general fix is to surround line 219 with a define in case of x64, though I am not sure there is a general macro for that valid on all platforms

btchouston commented 7 years ago

I updated with the latest file Interface.h from OpenMVS, and commented the line 219. now i have this error :

In file included from /home/odroid/OpenSfM/opensfm/src/csfm.cc:13:0: /home/odroid/OpenSfM/opensfm/src/openmvs_exporter.h: In member function ‘void csfm::OpenMVSExporter::Export(std::__cxx11::string)’: /home/odroid/OpenSfM/opensfm/src/openmvsexporter.h:76:5: error: ‘ARCHIVE’ has not been declared ARCHIVE::SerializeSave(scene, filename); ^ CMakeFiles/csfm.dir/build.make:62: recipe for target 'CMakeFiles/csfm.dir/csfm.cc.o' failed make[2]: [CMakeFiles/csfm.dir/csfm.cc.o] Error 1 CMakeFiles/Makefile2:180: recipe for target 'CMakeFiles/csfm.dir/all' failed make[1]: [CMakeFiles/csfm.dir/all] Error 2 Makefile:94: recipe for target 'all' failed make: *** [all] Error 2

What should i do please ?

cdcseacave commented 7 years ago

pls add MVS in front, so: MVS::ARCHIVE::SerializeSave(

btchouston commented 7 years ago

Are these undefined reference normal :

CMakeFiles/depthmap_test.dir/depthmap_test.cc.o: In function (anonymous namespace)::PlaneInducedHomography_RandomPoint_Test::TestBody()': depthmap_test.cc:(.text+0x173e): undefined reference tocv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' depthmap_test.cc:(.text+0x17b8): undefined reference to cv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' CMakeFiles/depthmap_test.dir/depthmap_test.cc.o: In function(anonymous namespace)::Backproject_Reprojection_Test::TestBody()': depthmap_test.cc:(.text+0x20b2): undefined reference to `cv::Rodrigues(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&)' collect2: error: ld returned 1 exit status CMakeFiles/depthmap_test.dir/build.make:108: recipe for target 'depthmap_test' failed make[2]: [depthmap_test] Error 1 CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/depthmap_test.dir/all' failed make[1]: [CMakeFiles/depthmap_test.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... [100%] Linking CXX shared library /home/odroid/OpenSfM/opensfm/csfm.so [100%] Built target csfm Makefile:94: recipe for target 'all' failed make: [all] Error 2

despite these undefined refence, i tested again the export to openmvs format, and get the same error i described in my first comment.

paulinus commented 7 years ago

That does not look normal. The problem does not seem related to openMVS though, so it is better to track it on the OpenSfM repository. I've just added an issue for updating the Interface.h file https://github.com/mapillary/OpenSfM/issues/169 I'll do the update soon, but feel free to post the problems you face there.

cdcseacave commented 7 years ago

thx @paulinus I'm not a linux specialist, but on windows you can have both x86 and x64 binaries on the same system, and that could explain the issue here: the MVS file might be created with x64 while OpenMVS was compiled with x86 (or vice-versa)

paulinus commented 7 years ago

aha, I see thanks. That would explain the original problem where file exported by opensfm did not load in openmvs. I guess that keeping Interface.h updated is still a good idea.

houhaol commented 5 years ago

Sorry. Have you figured it out? I used the latest interface.h but still got the same error as yours.

alke commented 5 years ago

My system ubuntu 16.04 32 bit solved by change ODM-0.7.0/SuperBuild/src/opensfm/opensfm/src/third_party/openmvs/Interface.h to newer version at https://github.com/cdcseacave/openMVS/blob/8a08e1316d416d2363afb6553f3d5893ba41188c/libs/MVS/Interface.h with support to x86

kiwen-lee commented 3 years ago

Hello,How to convert OpenSfm' result file to .mvs file?

cdcseacave commented 3 years ago

opensfm includes an exporter to openmvs