Skip to content

Commit

Permalink
dense: use tower mode 4 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave committed Dec 7, 2023
1 parent 186eb29 commit 6449134
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 35 deletions.
2 changes: 1 addition & 1 deletion apps/DensifyPointCloud/DensifyPointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool Application::Initialize(size_t argc, LPCTSTR* argv)
("estimate-roi", boost::program_options::value(&OPT::nEstimateROI)->default_value(2), "estimate and set region-of-interest (0 - disabled, 1 - enabled, 2 - adaptive)")
("crop-to-roi", boost::program_options::value(&OPT::bCrop2ROI)->default_value(true), "crop scene using the region-of-interest")
("remove-dmaps", boost::program_options::value(&bRemoveDmaps)->default_value(false), "remove depth-maps after fusion")
("tower-mode", boost::program_options::value(&OPT::nTowerMode)->default_value(3), "add a cylinder of points in the center of ROI; scene assume to be Z-up oriented (0 - disabled, 1 - replace, 2 - append, 3 - select neighbors, <0 - force tower mode)")
("tower-mode", boost::program_options::value(&OPT::nTowerMode)->default_value(4), "add a cylinder of points in the center of ROI; scene assume to be Z-up oriented (0 - disabled, 1 - replace, 2 - append, 3 - select neighbors, 4 - select neighbors & append, <0 - force tower mode)")
;

// hidden options, allowed both on command line and
Expand Down
60 changes: 26 additions & 34 deletions libs/MVS/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,8 @@ bool Scene::SelectNeighborViews(uint32_t ID, IndexArr& points, unsigned nMinView

void Scene::SelectNeighborViews(unsigned nMinViews, unsigned nMinPointViews, float fOptimAngle, unsigned nInsideROI)
{
#ifdef DENSE_USE_OPENMP
#pragma omp parallel for shared(data, bAbort)
for (int_t ID=0; ID<(int_t)images.GetSize(); ++ID) {
#ifdef SCENE_USE_OPENMP
for (int_t ID=0; ID<(int_t)images.size(); ++ID) {
const IIndex idxImage((IIndex)ID);
#else
FOREACH(idxImage, images) {
Expand Down Expand Up @@ -1847,7 +1846,6 @@ size_t Scene::DrawCircle(PointCloud& pc, PointCloud::PointArr& outCircle, const
pc.pointViews.emplace_back(views);
pc.normals.emplace_back(n);
pc.colors.emplace_back(Pixel8U::YELLOW);
pc.pointWeights.emplace_back(PointCloud::WeightArr{1.f});
}
}
return outCircle.size();
Expand Down Expand Up @@ -2007,15 +2005,17 @@ PointCloud Scene::BuildTowerMesh(const PointCloud& origPointCloud, const Point2f
mesh.faces.emplace_back(v0, v2, v1);
}
}
if (bInverted) {
if (bInverted)
topPoints.swap(botPoints);
}
}
}
mesh.Save("towermesh_dbg.ply");
towerPC.Save("cylinder.ply");
}
mesh.Save("tower_mesh.ply");
} else
#endif
{
mesh.Release();
}
towerPC.Save("tower.ply");
return towerPC;
}

Expand All @@ -2031,17 +2031,12 @@ void Scene::InitTowerScene(const int towerMode)
Point2f centerPoint;
if (!ComputeTowerCylinder(centerPoint, fRadius, fROIRadius, zMin, zMax, minCamZ, towerMode))
return;
DEBUG("Scene camera positions identified ROI as a tower, select neighbors as if ROI is a tower");

// add nTargetPoints points on each circle
PointCloud towerPC(BuildTowerMesh(pointcloud, centerPoint, fRadius, fROIRadius, zMin, zMax, minCamZ, false));
mesh.Release();

switch (ABS(towerMode)) {
case 1: { // replace
pointcloud = std::move(towerPC);
break;
}
case 2: { // append
const auto AppendPointCloud = [this](const PointCloud& towerPC) {
bool bHasNormal(pointcloud.normals.size() == pointcloud.GetSize());
bool bHasColor(pointcloud.colors.size() == pointcloud.GetSize());
bool bHasWeights(pointcloud.pointWeights.size() == pointcloud.GetSize());
Expand All @@ -2055,32 +2050,29 @@ void Scene::InitTowerScene(const int towerMode)
if (bHasWeights)
pointcloud.pointWeights.emplace_back(towerPC.pointWeights[idxPoint]);
}
};

switch (ABS(towerMode)) {
case 1: // replace
pointcloud = std::move(towerPC);
VERBOSE("Scene identified as tower-like; replace existing point-cloud with detected tower point-cloud");
break;
}
case 3: { // select neighbors and remove added points
case 2: // append
AppendPointCloud(towerPC);
VERBOSE("Scene identified as tower-like; append to existing point-cloud the detected tower point-cloud");
break;
case 3: // select neighbors
pointcloud.Swap(towerPC);
SelectNeighborViews(OPTDENSE::nMinViews, OPTDENSE::nMinViewsTrustPoint>1?OPTDENSE::nMinViewsTrustPoint:2, FD2R(OPTDENSE::fOptimAngle), OPTDENSE::nPointInsideROI);
pointcloud.Swap(towerPC);
VERBOSE("Scene identified as tower-like; only select view neighbors from detected tower point-cloud");
break;
}
case 4: { // select neighbors
case 4: // select neighbors and append tower points
pointcloud.Swap(towerPC);
SelectNeighborViews(OPTDENSE::nMinViews, OPTDENSE::nMinViewsTrustPoint>1?OPTDENSE::nMinViewsTrustPoint:2, FD2R(OPTDENSE::fOptimAngle), OPTDENSE::nPointInsideROI);
pointcloud.Swap(towerPC);
bool bHasNormal(pointcloud.normals.size() == pointcloud.GetSize());
bool bHasColor(pointcloud.colors.size() == pointcloud.GetSize());
bool bHasWeights(pointcloud.pointWeights.size() == pointcloud.GetSize());
FOREACH(idxPoint, towerPC.points) {
pointcloud.points.emplace_back(towerPC.points[idxPoint]);
pointcloud.pointViews.emplace_back(towerPC.pointViews[idxPoint]);
if (bHasNormal)
pointcloud.normals.emplace_back(towerPC.normals[idxPoint]);
if (bHasColor)
pointcloud.colors.emplace_back(towerPC.colors[idxPoint]);
if (bHasWeights)
pointcloud.pointWeights.emplace_back(towerPC.pointWeights[idxPoint]);
}
AppendPointCloud(towerPC);
VERBOSE("Scene identified as tower-like; select view neighbors from detected tower point-cloud and next append it to existing point-cloud");
break;
}
}
} // InitTowerScene

0 comments on commit 6449134

Please sign in to comment.