Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 15 additions & 13 deletions meshroom/aliceVision/ImportAlembic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0"
__version__ = "1.1"

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
Expand All @@ -19,18 +19,20 @@ class ImportAlembic(desc.AVCommandLineNode):
description="The external Alembic file to import.",
value="",
),
desc.File(
name="imagesDir",
label="Images Directory",
description="Directory containing the images.",
value="",
desc.FloatParam(
name="framerate",
label="Frame rate",
description="Alembic frame rate to compute frame id from time",
value=24.0,
range=(10.0, 50.0, 1.0),
),
desc.ChoiceParam(
name="extension",
label="Images Extension",
description="File extension for the images in the directory to be taken into account.",
value=".exr",
values=[".exr", ".jpg", ".png"],
desc.IntParam(
name="imageWidth",
label="Image(s) Width",
description="Alembic does not export the camera resolutions. \n"
"Setup the image width for all images, the height will depend on the sensor size ratio.",
value=1920,
range=(640, 10000, 10),
),
desc.ChoiceParam(
name="verboseLevel",
Expand All @@ -46,6 +48,6 @@ class ImportAlembic(desc.AVCommandLineNode):
name="output",
label="SfMData",
description="SfMData file populated with the camera poses from the external Alembic file.",
value="{nodeCacheFolder}/importedAbc.sfm",
value="{nodeCacheFolder}/importedAbc.abc",
),
]
12 changes: 11 additions & 1 deletion meshroom/aliceVision/SfMPoseInjecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from meshroom.core.utils import VERBOSE_LEVEL

import json
import pathlib

class SfMPoseInjecting(desc.AVCommandLineNode):

Expand All @@ -23,16 +24,25 @@ class SfMPoseInjecting(desc.AVCommandLineNode):
desc.File(
name="posesFilename",
label="Poses",
description="Input JSON file containing the poses.",
description="Input file containing the poses (Json or ABC).",
value="",
),
desc.FloatParam(
name="framerate",
label="Frame rate",
description="Alembic frame rate to compute frame id from time",
value=24.0,
range=(10.0, 50.0, 1.0),
enabled=lambda node: pathlib.Path(node.posesFilename.value).suffix.lower() == ".abc"
),
desc.ChoiceParam(
name="rotationFormat",
label="Rotation Format",
description="Defines the rotation format for the input poses:\n"
" - EulerZXY: Euler rotation in degrees (Y*X*Z)",
values=["EulerZXY"],
value="EulerZXY",
enabled=lambda node: pathlib.Path(node.posesFilename.value).suffix.lower() == ".json"
),
desc.ChoiceParam(
name="verboseLevel",
Expand Down
8 changes: 4 additions & 4 deletions meshroom/aliceVision/SfmBootstrapping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.1"
__version__ = "4.2"

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
Expand All @@ -21,8 +21,8 @@ class SfMBootStrapping(desc.AVCommandLineNode):
desc.ChoiceParam(
name="method",
label="Method",
description="Bootstrapping method: classic (epipolar geometry), mesh (3D mesh constraints), or depth (depth map information).",
values=["classic", "mesh", "depth"],
description="Bootstrapping method: classic (epipolar geometry), mesh (3D mesh constraints), mesh_single (mesh without visual parallax), or depth (depth map information).",
values=["classic", "mesh", "mesh_single", "depth"],
value="classic",
),
desc.File(
Expand All @@ -36,7 +36,7 @@ class SfMBootStrapping(desc.AVCommandLineNode):
label="Mesh File",
description="Mesh file (*.obj).",
value="",
enabled=lambda node: node.method.value == "mesh"
enabled=lambda node: node.method.value.startswith("mesh")
),
desc.File(
name="pairs",
Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/dataio/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ std::vector<boost::json::value> readJsons(std::istream& is, boost::system::error
while (true)
{
totalRead = p.write_some(content, ec);

//remove processed string from content
content = content.substr(totalRead);

// If the parser did not find a value, then it won't
// find anything more.
Expand All @@ -28,9 +31,6 @@ std::vector<boost::json::value> readJsons(std::istream& is, boost::system::error
// content
jvs.push_back(p.release());
p.reset();

//remove processed string from content
content = content.substr(totalRead);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ void BundleAdjustmentCeres::addLandmarksToProblem(const sfmData::SfMData& sfmDat
problem.AddResidualBlock(costFunction, nullptr, params);
}

if (!refineStructure || landmark.state == EEstimatorParameterState::CONSTANT)
if (!refineStructure || landmark.state == EEstimatorParameterState::CONSTANT || landmark.isPrecise())
{
// set the whole landmark parameter block as constant.
_statistics.addState(EParameter::LANDMARK, EEstimatorParameterState::CONSTANT);
Expand Down
68 changes: 53 additions & 15 deletions src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@
{
return false;
}

if (_pointFetcherHandler)
{
setConstraints(sfmData, tracksHandler, validViewIds);
}

_historyHandler->saveState(sfmData);

Expand All @@ -172,108 +167,151 @@
return true;
}

bool ExpansionChunk::triangulate(sfmData::SfMData & sfmData, const track::TracksHandler & tracksHandler, const std::set<IndexT> & viewIds)
{
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate start");
SfmTriangulation triangulation(_triangulationMinPoints, _maxTriangulationError);


ALICEVISION_LOG_INFO("ExpansionChunk::triangulate start");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate start");
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate start");

const bool enableMultiviewTriangulation = true;

const size_t minPoints = _triangulationHandler->getMinObservations();

if (enableMultiviewTriangulation)
{
std::set<IndexT> evaluatedTracks;
std::map<IndexT, sfmData::Landmark> outputLandmarks;
std::mt19937 randomNumberGenerator;
if (!triangulation.process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
if (!_triangulationHandler->process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
randomNumberGenerator, viewIds,
evaluatedTracks, outputLandmarks, false))
{
return false;
}

auto & landmarks = sfmData.getLandmarks();
ALICEVISION_LOG_INFO("Existing landmarks : " << landmarks.size());

for (const auto & pl : outputLandmarks)
{
const auto & landmark = pl.second;

if (landmarks.find(pl.first) != landmarks.end())
{
landmarks.erase(pl.first);
}

if (landmark.getObservations().size() < _triangulationMinPoints)
if (landmark.getObservations().size() < minPoints)
{
continue;
}

if (!SfmTriangulation::checkChierality(sfmData, landmark))
{
continue;
}

double maxAngle = SfmTriangulation::getMaximalAngle(sfmData, landmark);
if (maxAngle < _minTriangulationAngleDegrees)
{
continue;
}

landmarks.insert(pl);
}

ALICEVISION_LOG_INFO("New landmarks count : " << landmarks.size());
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate end");
}

if (_enableDepthPrior)
{
std::set<IndexT> evaluatedTracks;
std::map<IndexT, sfmData::Landmark> outputLandmarks;
std::mt19937 randomNumberGenerator;
if (!triangulation.process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
if (!_triangulationHandler->process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
randomNumberGenerator, viewIds,
evaluatedTracks, outputLandmarks, true))
{
return false;
}

auto & landmarks = sfmData.getLandmarks();
ALICEVISION_LOG_INFO("Existing landmarks : " << landmarks.size());

for (const auto & pl : outputLandmarks)
{
const auto & landmark = pl.second;

if (landmarks.find(pl.first) != landmarks.end())
{
if (!_ignoreMultiviewOnPrior)
{
continue;
}
}

if (landmark.getObservations().size() < minPoints)
{
continue;
}

if (!SfmTriangulation::checkChierality(sfmData, landmark))
{
continue;
}

landmarks.insert(pl);
}

ALICEVISION_LOG_INFO("New landmarks count : " << landmarks.size());
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate end");
Comment on lines +229 to +265
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!_triangulationHandler->process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
randomNumberGenerator, viewIds,
evaluatedTracks, outputLandmarks, true))
{
return false;
}
auto & landmarks = sfmData.getLandmarks();
ALICEVISION_LOG_INFO("Existing landmarks : " << landmarks.size());
for (const auto & pl : outputLandmarks)
{
const auto & landmark = pl.second;
if (landmarks.find(pl.first) != landmarks.end())
{
if (!_ignoreMultiviewOnPrior)
{
continue;
}
}
if (landmark.getObservations().size() < minPoints)
{
continue;
}
if (!SfmTriangulation::checkChierality(sfmData, landmark))
{
continue;
}
landmarks.insert(pl);
}
ALICEVISION_LOG_INFO("New landmarks count : " << landmarks.size());
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate end");

}

if (_enableMeshPrior)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (_enableMeshPrior)
if (_enableDepthPrior || _enableMeshPrior)

{
std::set<IndexT> evaluatedTracks;
std::map<IndexT, sfmData::Landmark> outputLandmarks;
std::mt19937 randomNumberGenerator;
if (!_triangulationHandler->process(sfmData, tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
randomNumberGenerator, viewIds,
evaluatedTracks, outputLandmarks, true))
{
return false;
}

auto & landmarks = sfmData.getLandmarks();
ALICEVISION_LOG_INFO("Existing landmarks : " << landmarks.size());

for (const auto & pl : outputLandmarks)
{
const auto & landmark = pl.second;

if (landmarks.find(pl.first) != landmarks.end())
{
if (!_ignoreMultiviewOnPrior)
{
continue;
}
}

if (landmark.getObservations().size() < _triangulationMinPoints)
if (landmark.getObservations().size() < minPoints)
{
continue;
}

if (!SfmTriangulation::checkChierality(sfmData, landmark))
{
continue;
}

landmarks.insert(pl);
}

ALICEVISION_LOG_INFO("New landmarks count : " << landmarks.size());
ALICEVISION_LOG_INFO("ExpansionChunk::triangulate end");
}

return true;
}

Check notice on line 314 in src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.cpp

View check run for this annotation

codefactor.io / CodeFactor

src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.cpp#L170-L314

Complex Method
void ExpansionChunk::addPose(sfmData::SfMData & sfmData, IndexT viewId, const Eigen::Matrix4d & pose)
{
const sfmData::View & v = sfmData.getView(viewId);
Expand All @@ -285,7 +323,7 @@

void ExpansionChunk::setConstraints(sfmData::SfMData & sfmData, const track::TracksHandler & tracksHandler, const std::set<IndexT> & viewIds)
{
ALICEVISION_LOG_INFO("ExpansionChunk::setConstraints start");
/*ALICEVISION_LOG_INFO("ExpansionChunk::setConstraints start");
const track::TracksMap & tracks = tracksHandler.getAllTracks();
const track::TracksPerView & tracksPerView = tracksHandler.getTracksPerView();

Expand Down Expand Up @@ -399,7 +437,7 @@
}

ALICEVISION_LOG_INFO("ExpansionChunk::setConstraints added " << constraints.size() << " constraints");
ALICEVISION_LOG_INFO("ExpansionChunk::setConstraints end");
ALICEVISION_LOG_INFO("ExpansionChunk::setConstraints end");*/
}

} // namespace sfm
Expand Down
37 changes: 9 additions & 28 deletions src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <aliceVision/sfmData/SfMData.hpp>
#include <aliceVision/sfm/pipeline/expanding/ExpansionHistory.hpp>
#include <aliceVision/sfm/pipeline/expanding/SfmBundle.hpp>
#include <aliceVision/sfm/pipeline/expanding/PointFetcher.hpp>
#include <aliceVision/sfm/pipeline/expanding/SfmResection.hpp>
#include <aliceVision/sfm/pipeline/expanding/SfmTriangulation.hpp>

namespace aliceVision {
namespace sfm {
Expand Down Expand Up @@ -45,7 +45,7 @@ class ExpansionChunk
}

/**
* brief setup the expansion history handler
* @brief setup the expansion history handler
* @param expansionHistory a shared ptr
*/
void setExpansionHistoryHandler(ExpansionHistory::sptr & expansionHistory)
Expand All @@ -54,16 +54,7 @@ class ExpansionChunk
}

/**
* brief setup the point fetcher handler
* @param pointFetcher a unique ptr. the Ownership will be taken
*/
void setPointFetcherHandler(PointFetcher::uptr & pointFetcherHandler)
{
_pointFetcherHandler = std::move(pointFetcherHandler);
}

/**
* brief setup the point fetcher handler
* @brief setup the Resection handler
* @param resectionHandler a unique ptr. the Ownership will be taken
*/
void setResectionHandler(SfmResection::uptr & resectionHandler)
Expand All @@ -72,21 +63,12 @@ class ExpansionChunk
}

/**
* @brief set the minimal number of points to enable triangulation of a track
* @param count the number of points
*/
void setTriangulationMinPoints(size_t count)
{
_triangulationMinPoints = count;
}

/**
* @brief set the maximal reprojection error in the triangulation process.
* @param count the number of points
* @brief setup the Triangulation handler
* @param triangulationHandler a unique ptr. the Ownership will be taken
*/
void setTriangulationMaxError(double error)
void setTriangulationHandler(SfmTriangulation::uptr & triangulationHandler)
{
_maxTriangulationError = error;
_triangulationHandler = std::move(triangulationHandler);
}

/**
Expand Down Expand Up @@ -159,16 +141,15 @@ class ExpansionChunk
private:
SfmBundle::uptr _bundleHandler;
ExpansionHistory::sptr _historyHandler;
PointFetcher::uptr _pointFetcherHandler;
std::set<IndexT> _ignoredViews;
SfmResection::uptr _resectionHandler;
SfmTriangulation::uptr _triangulationHandler;

private:
size_t _triangulationMinPoints = 2;
double _minTriangulationAngleDegrees = 3.0;
double _maxTriangulationError = 8.0;
size_t _weakResectionSize = 100;
bool _enableDepthPrior = true;
bool _enableMeshPrior = true;
bool _ignoreMultiviewOnPrior = false;
};

Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/sfm/pipeline/expanding/ExpansionIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ExpansionIteration
}

/**
* brief setup the expansion history handler
* @brief setup the expansion history handler
* @param expansionHistory a shared ptr
*/
void setExpansionHistoryHandler(ExpansionHistory::sptr & expansionHistory)
Expand All @@ -51,7 +51,7 @@ class ExpansionIteration
}

/**
* brief setup the expansion history handler
* @brief setup the expansion history handler
* @param expansionPolicy a unique ptr. Ownership will be taken
*/
void setExpansionPolicyHandler(ExpansionPolicy::uptr & expansionPolicy)
Expand All @@ -60,7 +60,7 @@ class ExpansionIteration
}

/**
* brief setup the expansion chunk handler
* @brief setup the expansion chunk handler
* @param expansionChunk a unique ptr. Ownership will be taken
*/
void setExpansionChunkHandler(ExpansionChunk::uptr & expansionChunk)
Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/sfm/pipeline/expanding/ExpansionProcess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ExpansionProcess{
}

/**
* brief setup the expansion history handler
* @brief setup the expansion history handler
* @param expansionHistory a shared ptr
*/
void setExpansionHistoryHandler(ExpansionHistory::sptr & expansionHistory)
Expand All @@ -49,7 +49,7 @@ class ExpansionProcess{
}

/**
* brief setup the expansion iteration handler
* @brief setup the expansion iteration handler
* @param expansionIteration a unique ptr. Ownership will be taken
*/
void setExpansionIterationHandler(ExpansionIteration::uptr & expansionIteration)
Expand All @@ -58,7 +58,7 @@ class ExpansionProcess{
}

/**
* brief setup the expansion iteration post process handler
* @brief setup the expansion iteration post process handler
* @param expansionPostProcess a unique ptr. Ownership will be taken
*/
void setExpansionIterationPostProcessHandler(ExpansionPostProcess::uptr & expansionPostProcess)
Expand Down
Loading
Loading