nmoehrle / mvs-texturing

Algorithm to texture 3D reconstructions from multi-view stereo images
Other
974 stars 334 forks source link

Segmentation Fault at View Selection step #149

Closed xubury closed 4 years ago

xubury commented 4 years ago

I follow the instruction at https://www.gcc.tu-darmstadt.de/home/proj/texrecon and use the dataset provided by https://www.gcc.tu-darmstadt.de/home/proj/mve/. But when I tried to compile the program using mingw-w64-gcc, it failed with serveral errors error: cast from 'mapmap::_s_t<double, 4>*' {aka 'double*'} to 'long unsigned int' loses precision [-fpermissive]. So I change every (unsigned long) ptr to (uintptr_t) ptr in vector_math.impl.h. Then the compile passed. Unfortunately when I try to generate texture it prompt a Segmentation Fault. Did my change to the mapmap lead to this SegFault? If so, how can I properly compile this project?

 Bury@DESKTOP-18IUEN2  /d/Downloads/mve-kermit-20130522/views /g/codes/ReconProject/texrecon/build/apps/texrecon/texrecon.exe scene::undistorted surface-clean.ply textured
G:\codes\ReconProject\texrecon\build\apps\texrecon\texrecon.exe (built on Jul 25 2020, 18:58:47)
Load and prepare mesh:
PLY Loader: comment Export generated by libmve
Reading PLY: 1780 verts... 3356 faces... done.
Warning: Zero-length normals detected: 0 face normals, 1 vertex normals
Generating texture views:
Initializing scene with 9 views...
Initialized 9 views (max ID is 8), took 4ms.
        Loading 100%... done. (Took 0s)
Building adjacency graph:
        Adding edges 100%... done. (Took 0.007s)
        4932 total edges.
View selection:
        Building BVH from 3356 faces... done. (Took: 2 ms)
        Calculating face qualities 100%... done. (Took 0.069s)
        Postprocessing face infos 100%... done. (Took 0s)
        Maximum quality of a face within an image: 213.894
        Clamping qualities to 71.298 within normalization.
        Writing data cost file... done.
        Optimizing:
                Time[s] Energy
Received signal SIGSEGV (segmentation fault)
Segmentation fault
xubury commented 4 years ago

Also, I noticed that in the usage description:Within a scene folder a .cam file has to be given for each image. A .cam file is structured as follows: tx ty tz R00 R01 R02 R10 R11 R12 R20 R21 R22 I use mve to generate camera parameters and get a meta.ini instead of .cam, could this be the problem?

xubury commented 4 years ago

I tried to debug the program. The segmentation fault happens inside of a function line 118: solver.optimize(solution, ctr); in view_selection_cpp. I dig into a little bit, looks like the segfault was caused by mapmap. mapmap tries to run a parallel_do and crash the whole program. I really don't know how can I fix this issue. BTW, I running this code on Windows 10.

tbb::parallel_do(queue.begin(), queue.end(),
        [&](const luint_t n, tbb::parallel_do_feeder<luint_t>& feeder)
xubury commented 4 years ago

eh. Just tested the program on Ubuntu 18.04 and didn't encounter this issue. I thinks it has something to do with libtbb which used by mapmap. The version of libtbb on my Windows 10 is newer than the one on Ubuntu. So maybe switch to older version might help? On Windows 10, it shows compiler warning that some header files of tbb are deprecated and the program always crashed in _mm256_setzero_ps

xubury commented 4 years ago

I thinks it has something to do with libtbb which used by mapmap. The version of libtbb on my Windows 10 is newer than the one on Ubuntu. So maybe switch to older version might help?

Tested with latested libtbb on Ubutnu 20.04, the texturing process works despite the compile warning

xubury commented 4 years ago

So, apparently this is caused by a bug from mingw-gcc, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49001 I have made a little tuning to the code for anybody encounter the same issue using mingw-gcc. https://github.com/xubury/mvs-texturing