Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d219c18
refine: take the central-difference image gradient from the image at …
cdcseacave Oct 8, 2026
54779ee
refine: compute the CPU window sums per band of rows
cdcseacave Oct 8, 2026
47bc229
texture: rasterize the view selection at the full image resolution, n…
cdcseacave Oct 8, 2026
4273b29
texture: choose each face's view by the resolution it sees, relative …
cdcseacave Oct 8, 2026
5737a47
texture: fill the atlas gutter from the surrounding patches instead o…
cdcseacave Oct 8, 2026
e575579
texture: disable the unsharp mask by default
cdcseacave Oct 8, 2026
dbb52c4
docs: texturing design document
cdcseacave Oct 8, 2026
529a6c5
texture: compute the Potts LBP messages in O(labels) instead of O(lab…
cdcseacave Oct 9, 2026
a85a62f
docs: texturing design describes the Potts LBP messages
cdcseacave Oct 9, 2026
8d7b212
split: cut the scene into sub-scenes that fit a memory budget
cdcseacave Oct 9, 2026
2984ebf
texture: pack the patch footprints instead of their rectangles
cdcseacave Oct 9, 2026
1700877
texture: count the face pixels of a view outside the critical section
cdcseacave Oct 9, 2026
3393d2e
refine: one CUDA photometric accumulation per reference view
cdcseacave Oct 9, 2026
fff11c5
refine: no per-view depth maps in the CUDA refiner
cdcseacave Oct 9, 2026
b2ced69
texture: flat LBP message buffers, face views released into the infer…
cdcseacave Oct 9, 2026
5453217
refine: refuse --scales 0 instead of crashing
cdcseacave Oct 9, 2026
f6647f7
refine: --scales 0 returns the input mesh instead of being refused
cdcseacave Oct 9, 2026
22fcb77
densify: --fusion-mode 1 no longer saves a dense scene
cdcseacave Oct 9, 2026
3a06e01
common: the free memory on Linux is MemAvailable
cdcseacave Oct 9, 2026
bb0bf3b
split: one command reconstructs a scene of any size, split only when …
cdcseacave Oct 9, 2026
6e279e4
ports: halfmesh 0.5.0 (footprint packing, SubdivideFaces, SamplePoint…
cdcseacave Oct 9, 2026
3fe50bf
texture: patch packing and gutter fill come from halfmesh
cdcseacave Oct 9, 2026
7922129
mesh: a face with no neighbour within the smoothing gradient keeps it…
cdcseacave Oct 9, 2026
3e685be
mesh: subdivision and surface sampling come from halfmesh; unused que…
cdcseacave Oct 9, 2026
3cc2443
mesh: OBJ codec, volume, watertightness, join and sub-mesh come from …
cdcseacave Oct 9, 2026
9c68938
scene split: merge keeps the scene box's upper faces, later steps reu…
cdcseacave Oct 11, 2026
0f33515
mesh: PLY face texture indices checked at load, leveled volume logs c…
cdcseacave Oct 11, 2026
045d119
scene split: whole depth-maps in the cost, merge renumbers views and …
cdcseacave Oct 12, 2026
cf4d7e8
texture: Potts LBP messages look the sender label up in a table
cdcseacave Oct 12, 2026
69a0abf
scene split: tested on the pipeline's depth-maps, folder created on e…
cdcseacave Oct 12, 2026
46c8187
ports: halfmesh v0.5.0 source hash
cdcseacave Oct 12, 2026
37e9924
tests: compare the LBP labels only, not the energies
cdcseacave Oct 12, 2026
58ba28f
build: compile with C++20, the standard halfmesh is built with
cdcseacave Oct 12, 2026
7347786
build: declare the version in project()
cdcseacave Oct 12, 2026
af71f25
build: back to the newest C++ standard, the rule halfmesh now follows…
cdcseacave Oct 12, 2026
f06bcb6
scene split: a chunk keeps its images rather than lose its box
cdcseacave Oct 12, 2026
49ecc7a
scripts: merge empty sub-scene meshes, texture the refined mesh a lat…
cdcseacave Oct 12, 2026
7093202
ports: halfmesh v0.5.1
cdcseacave Oct 12, 2026
b6f612f
docs: describe the texturing and refinement choices by how they work
cdcseacave Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ ENDIF()
# CMake files in this project can refer to the root source directory
# as ${OpenMVS_SOURCE_DIR} and to the root binary directory as
# ${OpenMVS_BINARY_DIR}.
PROJECT(OpenMVS LANGUAGES CXX)

SET(OpenMVS_MAJOR_VERSION 2)
SET(OpenMVS_MINOR_VERSION 4)
SET(OpenMVS_PATCH_VERSION 0)
SET(OpenMVS_VERSION ${OpenMVS_MAJOR_VERSION}.${OpenMVS_MINOR_VERSION}.${OpenMVS_PATCH_VERSION})
PROJECT(OpenMVS VERSION ${OpenMVS_VERSION} LANGUAGES CXX)

# Disable SSE on unsupported platforms
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|ARM|aarch64|AARCH64)")
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Automatic Windows x64 binary builds can be found for each commit on its Artifact

See the usage [example](https://github.com/cdcseacave/openMVS/wiki/Usage) wiki page.

## Large scenes

`scripts/python/MvsScalablePipeline.py scene.mvs` runs the dense reconstruction, mesh, refinement and texturing of a scene of any size: when the scene does not fit the memory this machine has available, it is split into sub-scenes that each do, reconstructed one after the other and merged. A scene that fits is reconstructed whole, as by the modules themselves. `MvgMvsPipeline.py` does the same for its dense steps by default (`--sub-scene-memory off` disables it). See [large scenes](https://github.com/cdcseacave/openMVS/wiki/Usage#large-scenes) on the wiki.

## License

See the [copyright](https://github.com/cdcseacave/openMVS/blob/master/COPYRIGHT.md) file.
Expand Down
36 changes: 25 additions & 11 deletions apps/DensifyPointCloud/DensifyPointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ String strExportDMAPSPathName;
String strDenseConfigFileName;
String strExportDepthMapsName;
String strMaskPath;
float fMaxSubsceneArea;
float fMaxSubsceneMemory;
float fSampleMesh;
uint32_t nSampleMeshSeed;
float fSampleMeshNeighbors;
Expand Down Expand Up @@ -171,7 +171,7 @@ bool Application::Initialize(size_t argc, LPCTSTR* argv)
("estimate-normals", boost::program_options::value(&nEstimateNormals)->default_value(2), "estimate the normals for the dense point-cloud (0 - disabled, 1 - final, 2 - estimate)")
("estimate-scale", boost::program_options::value(&OPT::fEstimateScale)->default_value(0.f), "estimate the point-scale for the dense point-cloud (scale multiplier, 0 - disabled)")
("estimate-segmentation", boost::program_options::value(&OPT::nEstimateSegmentation)->default_value(0), "estimate segmentation of the dense point-cloud based on the image segmentation masks; num views to agree (0 - disabled, <0 - only segmentation)")
("sub-scene-area", boost::program_options::value(&OPT::fMaxSubsceneArea)->default_value(0.f), "split the scene in sub-scenes such that each sub-scene surface does not exceed the given maximum sampling area (0 - disabled)")
("sub-scene-memory", boost::program_options::value(&OPT::fMaxSubsceneMemory)->default_value(0.f), "split the scene in sub-scenes whose depth-map fusion and mesh reconstruction each fit this much memory, in GB (0 - disabled, <0 - fit this machine: the physical memory available now, less a reserve of 10% of the total and at least 2GB)")

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] --sub-scene-area is removed. Boost rejects an unknown option, so a script that still passes the area flag fails at parse time. The replacement is --sub-scene-memory, in GB. docs/design/SceneSplit.md:92 records the removal.

Suggestion: Keep the old name as a hidden option that fails with a message naming --sub-scene-memory.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it removed: Boost already stops at parse time naming the unknown option, so nothing runs with a wrong setting, and no script in the repo passes it. A hidden alias would be a permanent option kept only to print a message.

("sample-mesh", boost::program_options::value(&OPT::fSampleMesh)->default_value(0.f), "uniformly samples points on a mesh (0 - disabled, <0 - number of points, >0 - sample density per square unit)")
("sample-mesh-seed", boost::program_options::value(&OPT::nSampleMeshSeed)->default_value(NO_ID), "seed used to initialize the RNG for mesh sampling, for reproducible results (default - seed from a random device)")
("fusion-mode", boost::program_options::value(&OPT::nFusionMode)->default_value(0), "depth-maps fusion mode (-2 - SGM depth-maps & fusion, -1 - export SGM pair disparity-maps only, 0 - depth-maps & fusion, 1 - export depth-maps only)")
Expand Down Expand Up @@ -453,14 +453,27 @@ int main(int argc, LPCTSTR* argv)
VERBOSE("Mesh projection completed: %u depth-maps (%s)", scene.images.size(), TD_TIMER_GET_FMT().c_str());
return EXIT_SUCCESS;
}
if (OPT::fMaxSubsceneArea > 0) {
// split the scene in sub-scenes by maximum sampling area
if (OPT::fMaxSubsceneMemory != 0) {
// split the scene in sub-scenes by the memory their processing needs
float maxMemory(OPT::fMaxSubsceneMemory);
if (maxMemory < 0) {
// fit this machine: what is available now, less a reserve for the rest of the system and
// the error of the cost model (the fusion's depth-map cache grows into the free memory)
const Util::MemoryInfo memInfo(Util::GetMemoryInfo());
constexpr double GB(1024.0*1024.0*1024.0);
const double reserve(MAXF(0.1*(double)memInfo.totalPhysical, 2.0*GB));
maxMemory = (float)(((double)memInfo.freePhysical - reserve)/GB);
if (maxMemory < 1.f) {
VERBOSE("error: %.1fGB of physical memory available, too little to split the scene", (double)memInfo.freePhysical/GB);
return EXIT_FAILURE;
}
VERBOSE("Sub-scene memory budget: %.1fGB (%.1fGB available of %.1fGB)", maxMemory, (double)memInfo.freePhysical/GB, (double)memInfo.totalPhysical/GB);
}
Scene::ImagesChunkArr chunks;
scene.Split(chunks, OPT::fMaxSubsceneArea);
if (chunks.empty()) {
VERBOSE("error: no sub-scene to export");
if (scene.Split(chunks, maxMemory) <= 0)
return EXIT_FAILURE;
}
if (chunks.empty())
return EXIT_SUCCESS; // the whole scene fits: no sub-scene to export
if (!scene.ExportChunks(chunks, GET_PATH_FULL(OPT::strOutputFileName), (ARCHIVE_TYPE)OPT::nArchiveType)) {
VERBOSE("error: can not export the sub-scenes");
return EXIT_FAILURE;
Expand Down Expand Up @@ -540,9 +553,10 @@ int main(int argc, LPCTSTR* argv)
VERBOSE("Removed all image neighbors");
}
TD_TIMER_START();
if (!scene.DenseReconstruction(OPT::nFusionMode, OPT::bCrop2ROI, OPT::fBorderROI, OPT::fSampleMeshNeighbors)) {
if (ABS(OPT::nFusionMode) != 1)
return EXIT_FAILURE;
if (!scene.DenseReconstruction(OPT::nFusionMode, OPT::bCrop2ROI, OPT::fBorderROI, OPT::fSampleMeshNeighbors))
return EXIT_FAILURE;
if (ABS(OPT::nFusionMode) == 1) {
// only the depth-maps were asked for: the scene's point-cloud is not a dense one to save
VERBOSE("Depth-maps estimated (%s)", TD_TIMER_GET_FMT().c_str());
return EXIT_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/RefineMesh/RefineMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool Application::Initialize(size_t argc, LPCTSTR* argv)
("adaptive-face-size", boost::program_options::value(&OPT::bAdaptiveFaceSize)->default_value(true), "grade the prepared faces per vertex so each one projects to about --max-face-area in the pair that refines it, instead of one world-space density for the whole mesh (a difference only where the camera-to-surface distance varies)")
("simplify-tolerance", boost::program_options::value(&OPT::fSimplifyTolerance)->default_value(0.25f), "decimate the refined mesh within this reprojection error, in pixels of the working resolution in the pair that resolves each vertex best, once the refinement ends (accuracy-neutral, roughly halves the face count; 0 - disabled)")
("fast", boost::program_options::bool_switch(&OPT::bFast)->default_value(false), "trade accuracy for speed: refine a mesh prepared at twice the default face area and decimate the result within 0.5 pixels (1.3x faster for -0.005 mean F1 and a 2.5x smaller mesh); an explicitly given --max-face-area or --simplify-tolerance wins over it")
("scales", boost::program_options::value(&OPT::nScales)->default_value(2), "how many iterations to run mesh optimization on multi-scale images")
("scales", boost::program_options::value(&OPT::nScales)->default_value(2), "how many iterations to run mesh optimization on multi-scale images (0 - return the input mesh unchanged)")
("scale-step", boost::program_options::value(&OPT::fScaleStep)->default_value(0.5f), "image scale factor used at each mesh optimization step")
("alternate-pair", boost::program_options::value(&OPT::nAlternatePair)->default_value(0), "refine mesh using an image pair alternatively as reference (0 - both, 1 - alternate, 2 - only left, 3 - only right)")
("regularity-weight", boost::program_options::value(&OPT::fRegularityWeight)->default_value(0.2f), "scalar regularity weight to balance between photo-consistency and regularization terms during mesh optimization")
Expand Down
3 changes: 2 additions & 1 deletion apps/Tests/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Single integration test: `MVS::PipelineTest()`.
```
Load scene.mvs
→ DenseReconstruction() — point cloud >= 50,000 points
→ SceneSplitTest() — on the depth-maps: ROI-independent depth term, forced split exported
→ ReconstructMesh() — faces in [40,000 – 100,000]
→ Mesh::Clean(decimate=0.7) — faces in [28,000 – 70,000]
→ TestMeshProjectionMT() — (if OpenMP enabled)
Expand All @@ -104,7 +105,7 @@ Load scene.mvs
The face/quality bounds are deliberately wide plausibility windows: they bracket the
spread of both the CPU and GPU PatchMatch backends, which differ by design.

Sets `OPTDENSE::bRemoveDmaps = true` to clean intermediate depth maps. Optionally saves `.ply` outputs when verbose.
Keeps the depth maps on disk (`OPTDENSE::bRemoveDmaps = false`) for `SceneSplitTest` and deletes them right after it, whatever its outcome. Optionally saves `.ply` outputs when verbose (into the data folder: remove them after a verbose run).

## Logging Convention

Expand Down
4 changes: 4 additions & 0 deletions apps/Tests/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ bool UnitTests()
VERBOSE("ERROR: TestTetraFlow failed!");
return false;
}
if (!SEACAVE::TestLBPPotts()) {
VERBOSE("ERROR: TestLBPPotts failed!");
return false;
}
if (Util::toString(L"\x00A9\U0001F600") != "\xC2\xA9\xF0\x9F\x98\x80") {
VERBOSE("ERROR: wide string UTF-8 conversion failed!");
return false;
Expand Down
194 changes: 190 additions & 4 deletions apps/Tests/TestsMVS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,86 @@ bool MeshHalfMeshProcessingTest()
{0, 2, 3}, {0, 3, 4}, {0, 4, 5}, {0, 5, 2},
{1, 3, 2}, {1, 4, 3}, {1, 5, 4}, {1, 2, 5}
};
// the queries and editors halfmesh implements: the unit octahedron bounds 4/3,
// split evenly by z=0; its top half alone is open, and closes against z=0 to 2/3
{
const Mesh& closed(octahedron);
REAL above, below;
if (!closed.IsWatertight() || !ISEQUAL(closed.ComputeVolume(), REAL(4)/3) ||
!ISEQUAL(closed.ComputeVolume(Planef(Planef::VECTOR(0, 0, 1), 0.f), above, below), REAL(4)/3) ||
!ISEQUAL(above, REAL(2)/3) || !ISEQUAL(below, REAL(2)/3)) {
VERBOSE("ERROR: HalfMesh bridge measured the octahedron's volume wrong!");
return false;
}
Mesh::FaceIdxArr top;
for (Mesh::FIndex idxFace: {0u, 1u, 2u, 3u})
top.emplace_back(idxFace);
const Mesh pyramid(closed.SubMesh(top));
if (pyramid.vertices.size() != 5 || pyramid.faces.size() != 4 || pyramid.IsWatertight() ||
!ISEQUAL(pyramid.ComputeVolume(Planef(Planef::VECTOR(0, 0, 1), 0.f), above, below), REAL(2)/3)) {
VERBOSE("ERROR: HalfMesh bridge extracted the octahedron's top wrong!");
return false;
}
Mesh twice(closed);
Mesh shifted(closed);
for (Mesh::Vertex& X: shifted.vertices)
X.x += 3.f;
twice.Join(shifted);
if (twice.vertices.size() != 12 || twice.faces.size() != 16 || !twice.IsWatertight() || !ISEQUAL(twice.ComputeVolume(), REAL(8)/3)) {
VERBOSE("ERROR: HalfMesh bridge joined two meshes wrong!");
return false;
}
// the viewer merges its layers into an empty mesh: the first keeps its colors
Mesh colored(shifted);
colored.vertexColors.resize(colored.vertices.size());
colored.vertexColors.Memset(255);
Mesh merged;
merged.Join(colored);
if (merged.faces.size() != colored.faces.size() || merged.vertexColors.size() != colored.vertices.size()) {
VERBOSE("ERROR: HalfMesh bridge joining onto an empty mesh dropped its attributes!");
return false;
}
Mesh textured(twice);
textured.faceTexcoords.resize(textured.faces.size()*3);
textured.faceTexcoords.Memset(0);
textured.faceTexindices.resize(textured.faces.size());
FOREACH(idxFace, textured.faceTexindices)
textured.faceTexindices[idxFace] = idxFace < 8 ? 0 : 1;
textured.texturesDiffuse.emplace_back(1, 1);
textured.texturesDiffuse.emplace_back(2, 2);
Mesh::FaceIdxArr mapFaceSubsetIndices;
const std::vector<Mesh> perTexture(textured.SplitMeshPerTextureBlob(&mapFaceSubsetIndices));
if (perTexture.size() != 2 || perTexture[0].faces.size() != 8 || perTexture[1].faces.size() != 8 ||
perTexture[1].texturesDiffuse.size() != 1 || perTexture[1].texturesDiffuse[0].width() != 2 ||
!perTexture[1].faceTexindices.empty() || mapFaceSubsetIndices[9] != 1) {
VERBOSE("ERROR: HalfMesh bridge split the mesh per texture wrong!");
return false;
}
const ScopedTempDir tmpDir(_T("MeshHalfMeshBridgeTest"));
if (!tmpDir.IsValid())
return false;
const String fileName(tmpDir(_T("octahedron.obj")));
Mesh loaded;
if (!twice.Save(fileName) || !loaded.Load(fileName) || loaded.vertices.size() != twice.vertices.size() ||
memcmp(loaded.vertices.data(), twice.vertices.data(), twice.vertices.GetDataSize()) != 0 ||
memcmp(loaded.faces.data(), twice.faces.data(), twice.faces.GetDataSize()) != 0) {
VERBOSE("ERROR: HalfMesh bridge OBJ round trip is not exact!");
return false;
}
// a PLY face naming a texture its file does not list is refused at load
const String badFileName(tmpDir(_T("texnumber.ply")));
std::ofstream(badFileName.c_str()) << "ply\nformat ascii 1.0\ncomment TextureFile a.png\ncomment TextureFile b.png\n"
"element vertex 3\nproperty float x\nproperty float y\nproperty float z\nelement face 1\n"
"property list uchar uint vertex_indices\nproperty list uchar float texcoord\nproperty int texnumber\nend_header\n"
"0 0 0\n1 0 0\n0 1 0\n3 0 1 2 6 0 0 1 0 0 1 2\n";
Image8U3 pixel(1, 1);
pixel.memset(0);
Mesh badTexture;
if (!pixel.Save(tmpDir(_T("a.png"))) || !pixel.Save(tmpDir(_T("b.png"))) || badTexture.Load(badFileName)) {
VERBOSE("ERROR: a PLY face texture index past the texture files was accepted!");
return false;
}
}
Mesh::VertexIdxArr verticesRemove;
verticesRemove.emplace_back(0);
if (octahedron.RemoveVerticesAndFill(verticesRemove) != 1 || !octahedron.IsWatertight()) {
Expand Down Expand Up @@ -2082,6 +2162,98 @@ static bool ROIMeshReconstructionTest(Scene& scene)
}
/*----------------------------------------------------------------*/

// The scene split on the pipeline's depth-maps: a scene ROI must not shrink the predicted memory of
// the depth-maps (the fusion loads each one whole), a scene that fits stays whole, and a split one
// exports its sub-scenes, each with its box as ROI, into a folder created for them.
static bool SceneSplitTest(Scene& scene)
{
const OBB3f initialOBB(scene.obb);
scene.obb.Reset();
Scene::ImagesChunkArr chunks;
const float wholePeak(scene.Split(chunks, 1000.f));
if (wholePeak <= 0 || !chunks.empty()) {
VERBOSE("ERROR: SceneSplitTest: the scene (predicted %gGB) does not stay whole in 1000GB (%u sub-scenes)!", wholePeak, chunks.size());
return false;
}
// the ROI: a slab across the middle third of the cloud's longest axis
const AABB3f aabb(scene.pointcloud.GetAABB(0.02f, 0.98f));
const Point3f size(aabb.GetSize());
const int axis(size[0] >= size[1] && size[0] >= size[2] ? 0 : (size[1] >= size[2] ? 1 : 2));
AABB3f slab(aabb);
slab.ptMin[axis] = aabb.ptMin[axis] + size[axis]/3;
slab.ptMax[axis] = aabb.ptMin[axis] + size[axis]*2/3;
scene.obb.Set(OBB3f::MATRIX::Identity(), slab.ptMin, slab.ptMax);
// all the valid depth-map pixels of the images seeing the slab, and the share of the samples in it
double numDepths(0);
size_t numSamples(0), numSamplesROI(0);
for (const Image& imageData: scene.images) {
if (!imageData.IsValid())
continue;
DepthData depthData;
if (!depthData.Load(ComposeDepthFilePath(imageData.ID, "dmap"), HeaderDepthDataRaw::HAS_DEPTH)) {
VERBOSE("ERROR: SceneSplitTest: the depth-map of image %u can not be loaded!", imageData.ID);
return false;
}
const Camera camera(imageData.GetCamera(scene.platforms, depthData.depthMap.size()));
size_t numValid(0), numInROI(0);
for (int r=0; r<depthData.depthMap.rows; ++r) {
for (int c=0; c<depthData.depthMap.cols; ++c) {
const Depth depth(depthData.depthMap(r,c));
if (depth <= 0)
continue;
++numValid;
if (r%8 || c%8)
continue;
++numSamples;
if (scene.obb.Intersects(Cast<float>(camera.TransformPointI2W(Point3(c,r,depth)))))
++numInROI;
}
}
numSamplesROI += numInROI;
if (numInROI)
numDepths += numValid;
}
// below 2/3 of the samples in the ROI, a depth term shrunk to them falls under the bound below
if (numSamplesROI == 0 || numSamplesROI*3 > numSamples*2) {
VERBOSE("ERROR: SceneSplitTest: the test ROI holds %u of %u depth-map samples!", numSamplesROI, numSamples);
return false;
}
// the split samples every 8th pixel: 10% margin on the whole maps' count
const float roiPeak(scene.Split(chunks, 1000.f));
const float depthsPeak(Scene::PredictSubsceneMemory(0.9*numDepths, 0));
if (roiPeak <= 0 || !chunks.empty() || roiPeak < depthsPeak || roiPeak > wholePeak) {
VERBOSE("ERROR: SceneSplitTest: with the ROI the scene is predicted %gGB, the whole depth-maps of its images alone %gGB, the scene without ROI %gGB!", roiPeak, depthsPeak, wholePeak);
return false;
}
// a budget a tenth of the way from a sub-scene's fixed cost to the scene's peak: the points
// alone need three parts
scene.obb.Reset();
const float fixedCost(Scene::PredictSubsceneMemory(0, 0));
if (scene.Split(chunks, fixedCost + (wholePeak-fixedCost)*0.1f) <= 0 || chunks.size() < 2) {
VERBOSE("ERROR: SceneSplitTest: a budget of %gGB split the scene in %u sub-scenes!", fixedCost + (wholePeak-fixedCost)*0.1f, chunks.size());
return false;
}
const ScopedTempDir tmpDir(_T("SceneSplitTest"));
if (!tmpDir.IsValid())
return false;
const String folder(tmpDir(_T("subscenes")));
if (!scene.ExportChunks(chunks, folder)) {
VERBOSE("ERROR: SceneSplitTest: the %u sub-scenes can not be exported to the new folder '%s'!", chunks.size(), folder.c_str());
return false;
}
FOREACH(c, chunks) {
Scene subScene;
if (subScene.Load(folder + String::FormatString("/scene_%04u.mvs", c)) == Scene::SCENE_NA ||
!subScene.IsBounded() || subScene.images.size() != chunks[c].images.size()) {
VERBOSE("ERROR: SceneSplitTest: sub-scene %u is not saved with its %u images and its box!", c, (unsigned)chunks[c].images.size());
return false;
}
}
scene.obb = initialOBB;
return true;
}
/*----------------------------------------------------------------*/

// A region-of-interest that intersects none of the dense points must
// fail cleanly through the "no points available" guard, not silently fall back to using
// every point
Expand Down Expand Up @@ -2283,7 +2455,8 @@ bool PipelineTest(bool forceCPU, bool verbose)
return false;
}
OPTDENSE::init();
OPTDENSE::bRemoveDmaps = true;
// the depth-maps stay on disk for the scene split test, removed after it (below)
OPTDENSE::bRemoveDmaps = false;
// every DEFVAR_OPTION starts at zero and only init()/update() install the declared defaults,
// so the refiner's configuration space needs the same treatment as OPTDENSE
OPTREFINE::init();
Expand All @@ -2304,9 +2477,22 @@ bool PipelineTest(bool forceCPU, bool verbose)
// asked for the weighted path with --constant-weight 0.
// Measured (GPU adjust-ON / CPU adjust-OFF): recon faces 52.9k / 71.4k,
// cleaned faces 37.0k / 49.8k, quality 50.4 / 52.2.
if (!scene.DenseReconstruction() || scene.pointcloud.GetSize() < 50000u) {
VERBOSE("ERROR: TestDataset failed estimating dense point-cloud (%u points)!", scene.pointcloud.GetSize());
return false;
{
// the depth-maps are removed once the scene split test is done, whatever its outcome
struct DepthMapsRemover {
const Scene& scene;
~DepthMapsRemover() {
for (const Image& imageData: scene.images)
if (imageData.IsValid())
File::deleteFile(ComposeDepthFilePath(imageData.ID, "dmap"));
}
} const depthMapsRemover{scene};
if (!scene.DenseReconstruction() || scene.pointcloud.GetSize() < 50000u) {
VERBOSE("ERROR: TestDataset failed estimating dense point-cloud (%u points)!", scene.pointcloud.GetSize());
return false;
}
if (!SceneSplitTest(scene))
return false;
}
if (verbose)
scene.pointcloud.Save(MAKE_PATH("scene_dense.ply"));
Expand Down
Loading
Loading