openMVS
openMVS copied to clipboard
DensifyPointCloud clustering step 2 produces no sub-scenes, segfaults at verbosity level 2
I'm trying to test DensifyPointCloud clustering on the sheffield_cross dataset using the example commands at https://github.com/cdcseacave/openMVS/issues/438#issuecomment-800972596 but step 2 is not creating any sub-scenes (scene_0000.mvs, scene_0001.mvs, scene_0002.mvs, etc). Also when running step 2 with verbosity level 2 it segfaults.
System Info
- OS: Gentoo Base System release 2.7
- GCC Version: 11.2.0
- Processor: AMD A10-9700 RADEON R7, 10 COMPUTE CORES 4C+6G
- openMVS Version: Up to date with 'origin/develop', commit e6ecc5ab11fcc4c7d644a1a298d86d32d5cd2944
The following is the commands, command output, and the directory contents after running the command.
Export from openMVG
../../../openMVG/openMVG_Build/Linux-x86_64-RELEASE/openMVG_main_openMVG2openMVS -i ../sfm_data.bin -o scene.mvs -d ./ -n 1
cmd1.txt
cmd1_ls.txt
Example step 1
../../../openMVS/openMVS_build/bin/DensifyPointCloud scene.mvs --max-resolution 800 --fusion-mode 1 --max-threads 4
cmd2.txt
cmd2_ls.txt
Example step 2
../../../openMVS/openMVS_build/bin/DensifyPointCloud scene.mvs --sub-scene-area 165000 --max-threads 4 -v 1
cmd3.txt
cmd3_ls.txt
I then compiled a build of openMVS with CMAKE_BUILD_TYPE=RelWithDebInfo and ran it in gdb to get a backtrace.
Example step 2 verbosity level 2 segfault
gdb --args ../../../openMVS_debug/openMVS_build/bin/DensifyPointCloud scene.mvs --sub-scene-area 165000 --max-threads 4 -v 2
Backtrace
#0 0x00007ffff3e3fab6 in () at /lib64/libc.so.6 #1 0x00007ffff3e0f5c8 in () at /lib64/libc.so.6 #2 0x00007ffff3e1fd06 in () at /lib64/libc.so.6 #3 0x0000555555735286 in vsnprintf (__ap=0x7fffffffcca0, __fmt=0x55555574afa8 "Scene split (%g max-area): %u chunks (%s)", __n=2048, __s=0x7fffffffc450 "Scene split (0 max-area): 165000 chunks (\262kUUU") at /usr/include/bits/stdio2.h:85 #4 SEACAVE::Log::_Record(unsigned int, char const*, __va_list_tag*) (this=0x5555557bf3c0 <SEACAVE::Log::GetInstance()::instance>, lt=4294952016, szFormat=0x55555574afa8 "Scene split (%g max-area): %u chunks (%s)", args=0x7fffffffcca0) at /home/jonathan/openMVS_debug/libs/Common/Log.cpp:152 #5 0x0000555555735443 in SEACAVE::Log::Write(char const*, ...) (this=this@entry=0x5555557bf3c0 <SEACAVE::Log::GetInstance()::instance>, szFormat=szFormat@entry=0x55555574afa8 "Scene split (%g max-area): %u chunks (%s)") at /home/jonathan/openMVS_debug/libs/Common/Log.cpp:88 #6 0x00005555556c6298 in MVS::Scene::Split(SEACAVE::cList<MVS::Scene::ImagesChunk, MVS::Scene::ImagesChunk const&, 2, 16, unsigned int>&, unsigned int, int) const (this=this@entry=0x7fffffffd7f0, chunks=..., maxArea=165000, depthMapStep=depthMapStep@entry=8) at /home/jonathan/openMVS_debug/libs/Common/List.h:1171 #7 0x000055555559d347 in main(int, LPCTSTR*) (argc=<optimized out>, argv=<optimized out>) at /home/jonathan/openMVS_debug/apps/DensifyPointCloud/DensifyPointCloud.cpp:261
cmd3_segmentation_fault.txt
Screenshots of
- scene.mvs
- scene_dense.mvs
- scene_dense.ply
- scene_obb.ply

If you need any more information please let me know.
Thx for the detailed issue. All steps look good, except the one that splits the scene in sub-scenes. The crash is not significant as it seems to be a problem with the printing function (I saw that before on linux, not sure why). So can you pls share the scene.mvs and the undistorted images to debug why it does not create sub-scenes?
Hear you go. openmvs.zip
thank you, I'll try to find some time during the weekend to look at this
I get the same segfault with verbose enabled, with gdb pointing to the formatting functions. Trimmed logs and stack trace:
$ gdb --args DensifyPointCloud -v 4 -i scene.mvs -o dense.ply --max-threads 1
(gdb) r
Starting program: /home/erik/mvs-build/bin/DensifyPointCloud -v 4 -i scene.mvs -o dense.ply --max-threads 1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
15:36:56 [App ] Build date: Oct 29 2021, 15:23:38
15:36:56 [App ] CPU: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz (40 cores)
15:36:56 [App ] RAM: 251.82GB Physical Memory 0B Virtual Memory
15:36:56 [App ] OS: Linux 4.15.0-76-generic (x86_64)
15:36:56 [App ] SSE & AVX compatible CPU & OS detected
15:36:56 [App ] Command line: -v 4 -i scene.mvs -o dense.ply --max-threads 1
[New Thread 0x7fffe9356700 (LWP 37894)]
[New Thread 0x7fffe8b55700 (LWP 37895)]
15:36:56 [App ] CUDA device 0 initialized: Tesla V100-DGXS-32GB (compute capability 7.0; memory 31.72GB)
15:36:56 [App ] CUDA link completed (0ms):
info : 0 bytes gmem
info : Function properties for 'ComputeFaceNormal':
info : used 24 registers, 16 stack, 0 bytes smem, 380 bytes cmem[0], 0 bytes lmem
15:36:56 [App ] Kernel 'ComputeFaceNormal' loaded
15:36:56 [App ] Camera model loaded: platform 0; camera 0; f 1.383x1.383; poses 1800
15:36:56 [App ] Image loaded 0: 32400.jpg
15:36:56 [App ] Image loaded 1: 32401.jpg
15:36:56 [App ] Image loaded 2: 32402.jpg
...
15:36:57 [App ] Image loaded 1799: 34199.jpg
15:36:57 [App ] Scene loaded from interface format (1s52ms):
1800 images (1800 calibrated) with a total of 562.50 MPixels (0.31 MPixels/image)
4925 points, 0 vertices, 0 faces
...
15:29:24 [App ] C1799 =
628303.2255
4135077.0146
-751.5331
15:29:24 [App ] Preparing images for dense reconstruction completed: 1800 images (7s870ms)
Thread 1 "DensifyPointClo" received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
62 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
#1 0x00007ffff12c54d3 in _IO_vfprintf_internal (s=s@entry=0x7fffffffcab0,
format=format@entry=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)",
ap=ap@entry=0x7fffffffcc40) at vfprintf.c:1643
#2 0x00007ffff12f0910 in _IO_vsnprintf (
string=0x7fffffffcba0 "Reference image 4294957410 sees 2684354560 views:",
maxlen=<optimized out>,
format=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)",
args=0x7fffffffcc40) at vsnprintf.c:114
#3 0x0000555555878f98 in _vscprintf (
format=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)",
pargs=0x7fffffffd660) at /home/erik/openMVS/libs/Common/Types.cpp:24
#4 0x000055555559a8a7 in SEACAVE::String::FormatStringSafe (
szFormat=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)",
args=0x7fffffffd660)
at /home/erik/openMVS/apps/DensifyPointCloud/../../libs/MVS/../Common/Strings.h:83
#5 0x0000555555870e95 in SEACAVE::Log::_Record (
this=0x555555c2c560 <SEACAVE::Log::GetInstance()::instance>, lt=4294967295,
szFormat=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)",
args=0x7fffffffd660) at /home/erik/openMVS/libs/Common/Log.cpp:154
#6 0x0000555555870c18 in SEACAVE::Log::Write (
this=0x555555c2c560 <SEACAVE::Log::GetInstance()::instance>,
szFormat=0x5555558bbb48 "Reference image %3u sees %u views:%s (%u shared points)")
at /home/erik/openMVS/libs/Common/Log.cpp:88
#7 0x0000555555765a84 in MVS::Scene::SelectNeighborViews (this=0x7fffffffdef0, ID=0, points=...,
nMinViews=2, nMinPointViews=2, fOptimAngle=0.17453292)
at /home/erik/openMVS/libs/MVS/Scene.cpp:628
#8 0x00005555557f35f4 in MVS::DepthMapsData::SelectViews (this=0x7fffffffdb78, depthData=...)
at /home/erik/openMVS/libs/MVS/SceneDensify.cpp:278
#9 0x0000555555814108 in MVS::Scene::ComputeDepthMaps(MVS::DenseDepthMapData&) [clone ._omp_fn.2]
() at /home/erik/openMVS/libs/MVS/SceneDensify.cpp:1548
#10 0x00007ffff1a9decf in GOMP_parallel () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
#11 0x00005555557fc0ba in MVS::Scene::ComputeDepthMaps (this=0x7fffffffdef0, data=...)
at /home/erik/openMVS/libs/MVS/SceneDensify.cpp:1539
#12 0x00005555557fbc3a in MVS::Scene::DenseReconstruction (this=0x7fffffffdef0, nFusionMode=0)
at /home/erik/openMVS/libs/MVS/SceneDensify.cpp:1424
#13 0x000055555559eaa8 in main (argc=9, argv=0x7fffffffe198)
at /home/erik/openMVS/apps/DensifyPointCloud/DensifyPointCloud.cpp:258
Switching the size checks to the 'buffer size - 1' fixed the segfault for me, but I'm not familiar enough with vsntprintf and the like to know if this is correct for Windows et al and/or mangles the logs.
diff --git a/libs/Common/Log.cpp b/libs/Common/Log.cpp
index da19bd1..823b8ef 100644
--- a/libs/Common/Log.cpp
+++ b/libs/Common/Log.cpp
@@ -149,7 +149,7 @@ void Log::_Record(Idx lt, LPCTSTR szFormat, va_list args)
#else
LPCTSTR const logType(lt<m_arrLogTypes.GetSize() ? m_arrLogTypes[lt] : g_appType);
#endif
- if ((size_t)_vsntprintf(szBuffer, 2048, szFormat, args) > 2048) {
+ if ((size_t)_vsntprintf(szBuffer, 2047, szFormat, args) > 2047) {
// not enough space for the full string, reprint dynamically
m_message.FormatSafe("%s [%s] %s" LINE_SEPARATOR_STR, szTime, logType, String::FormatStringSafe(szFormat, args).c_str());
} else {
diff --git a/libs/Common/Strings.h b/libs/Common/Strings.h
index 711d0a5..90f4467 100644
--- a/libs/Common/Strings.h
+++ b/libs/Common/Strings.h
@@ -44,8 +44,8 @@ public:
va_list args;
va_start(args, szFormat);
TCHAR szBuffer[2048];
- const size_t len((size_t)_vsntprintf(szBuffer, 2048, szFormat, args));
- if (len > 2048) {
+ const size_t len((size_t)_vsntprintf(szBuffer, 2047, szFormat, args));
+ if (len > 2047) {
*this = FormatStringSafe(szFormat, args);
va_end(args);
} else {
@@ -70,8 +70,8 @@ public:
va_list args;
va_start(args, szFormat);
TCHAR szBuffer[2048];
- const size_t len((size_t)_vsntprintf(szBuffer, 2048, szFormat, args));
- if (len > 2048) {
+ const size_t len((size_t)_vsntprintf(szBuffer, 2047, szFormat, args));
+ if (len > 2047) {
const String str(FormatStringSafe(szFormat, args));
va_end(args);
return str;
@erikreed that might be a different issue
@FinalEvilution i think i solved your issue, please try the latest develop
I've pulled the latest develop and tried building it, but make fails with the following error. build-error.txt