Skip to content

Commit d7f587b

Browse files
committed
dense: estimate SfM normals and surface patches
1 parent 1f83acb commit d7f587b

File tree

9 files changed

+482
-23
lines changed

9 files changed

+482
-23
lines changed

apps/DensifyPointCloud/DensifyPointCloud.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ String strExportDepthMapsName;
6161
String strMaskPath;
6262
float fMaxSubsceneArea;
6363
float fSampleMesh;
64+
float fSampleMeshNeighbors;
6465
float fBorderROI;
6566
bool bCrop2ROI;
6667
int nEstimateROI;
@@ -71,6 +72,7 @@ float fEstimateScale;
7172
int nEstimateSegmentation;
7273
int thFilterPointCloud;
7374
int nExportNumViews;
75+
bool bForceNeighborsFromImages;
7476
int nArchiveType;
7577
int nProcessPriority;
7678
unsigned nMaxThreads;
@@ -179,6 +181,8 @@ bool Application::Initialize(size_t argc, LPCTSTR* argv)
179181
// in config file, but will not be shown to the user
180182
boost::program_options::options_description hidden("Hidden options");
181183
hidden.add_options()
184+
("force-neighbors-from-images", boost::program_options::value(&OPT::bForceNeighborsFromImages)->default_value(false), "force estimating neighbor views from image pairs baseline")
185+
("sample-mesh-for-neighbors", boost::program_options::value(&OPT::fSampleMeshNeighbors)->default_value(0.f), "mesh sampling used for neighbor views estimation (0 - disabled/use mesh vertices, <0 - number of points, >0 - sample density per square unit)")
182186
("mesh-file", boost::program_options::value<std::string>(&OPT::strMeshFileName), "mesh file name used for image pair overlap estimation")
183187
("export-roi-file", boost::program_options::value<std::string>(&OPT::strExportROIFileName), "ROI file name to be exported form the scene")
184188
("import-roi-file", boost::program_options::value<std::string>(&OPT::strImportROIFileName), "ROI file name to be imported into the scene")
@@ -473,8 +477,25 @@ int main(int argc, LPCTSTR* argv)
473477
#endif
474478
if ((ARCHIVE_TYPE)OPT::nArchiveType == ARCHIVE_MVS)
475479
sparsePointCloud = scene.pointcloud;
480+
if (OPT::bForceNeighborsFromImages) {
481+
// force estimating neighbor views from image pairs baseline
482+
if (!scene.IsEmpty()) {
483+
scene.pointcloud.Release();
484+
scene.mesh.Release();
485+
VERBOSE("Remove all scene geometry");
486+
}
487+
bool bHasNeighbors(false);
488+
for (Image& image: scene.images) {
489+
if (!image.neighbors.IsEmpty()) {
490+
image.neighbors.Release();
491+
bHasNeighbors = true;
492+
}
493+
}
494+
if (bHasNeighbors)
495+
VERBOSE("Removed all image neighbors");
496+
}
476497
TD_TIMER_START();
477-
if (!scene.DenseReconstruction(OPT::nFusionMode, OPT::bCrop2ROI, OPT::fBorderROI)) {
498+
if (!scene.DenseReconstruction(OPT::nFusionMode, OPT::bCrop2ROI, OPT::fBorderROI, OPT::fSampleMeshNeighbors)) {
478499
if (ABS(OPT::nFusionMode) != 1)
479500
return EXIT_FAILURE;
480501
VERBOSE("Depth-maps estimated (%s)", TD_TIMER_GET_FMT().c_str());

libs/Common/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Find required packages
2+
FIND_PACKAGE(nanoflann REQUIRED)
3+
if(nanoflann_FOUND)
4+
include_directories(${nanoflann_INCLUDE_DIRS})
5+
add_definitions(${nanoflann_DEFINITIONS})
6+
MESSAGE(STATUS "nanoflann ${nanoflann_VERSION} found")
7+
endif()
8+
19
# List sources files
210
FILE(GLOB LIBRARY_FILES_C "*.cpp")
311
FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl")

libs/Common/Types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ namespace cv { namespace gpu = cuda; }
152152
#pragma pop_macro("DEBUG")
153153
#pragma pop_macro("free")
154154

155+
#pragma push_macro("free")
156+
#undef free
157+
#pragma push_macro("malloc")
158+
#undef malloc
159+
#include <nanoflann.hpp>
160+
#pragma pop_macro("malloc")
161+
#pragma pop_macro("free")
162+
155163
#ifdef _USE_SSE
156164
#include <xmmintrin.h>
157165
#include <emmintrin.h>

libs/MVS/DepthMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ bool MVS::ExportConfidenceMap(const String& fileName, const ConfidenceMap& confM
18811881
}
18821882
if (confs.IsEmpty())
18831883
return false;
1884-
const std::pair<float,float> th(ComputeX84Threshold<float,float>(confs.Begin(), confs.GetSize()));
1884+
const std::pair<float,float> th(ComputeX84Threshold<float,float>(confs.data(), confs.size()));
18851885
float minConf = th.first-th.second;
18861886
float maxConf = th.first+th.second;
18871887
if (minConf < 0.1f)
@@ -2301,7 +2301,7 @@ void MVS::CompareNormalMaps(const NormalMap& normalMap, const NormalMap& normalM
23012301
const MeanStd<float,double> ms(errors.Begin(), errors.GetSize());
23022302
const float mean((float)ms.GetMean());
23032303
const float stddev((float)ms.GetStdDev());
2304-
const std::pair<float,float> th(ComputeX84Threshold<float,float>(errors.Begin(), errors.GetSize()));
2304+
const std::pair<float,float> th(ComputeX84Threshold<float,float>(errors.data(), errors.size()));
23052305
VERBOSE("Normal-maps compared for image % 3u: %.2f median %.2f mean %.2f stddev error (%s)",
23062306
idxImage,
23072307
th.first, mean, stddev,

0 commit comments

Comments
 (0)