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
16 changes: 12 additions & 4 deletions meshroom/aliceVision/SfmBootstrapping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.0"
__version__ = "4.1"

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
Expand Down Expand Up @@ -37,13 +37,21 @@ class SfMBootStrapping(desc.AVCommandLineNode):
value="",
),
desc.FloatParam(
name="minAngleInitialPair",
label="Min Angle Initial Pair",
description="Minimum angle for the initial pair.",
name="minAngleSoftInitialPair",
label="Min Angle Initial Pair (Soft)",
description="Pair score is downgraded heavily if angle is under this value",
value=5.0,
range=(0.1, 10.0, 0.1),
advanced=True,
),
desc.FloatParam(
name="minAngleHardInitialPair",
label="Min Angle Initial Pair (Hard)",
description="Minimum angle for the initial pair validation.",
value=1.0,
range=(0.1, 10.0, 0.1),
advanced=True,
),
desc.FloatParam(
name="maxAngleInitialPair",
label="Max Angle Initial Pair",
Expand Down
12 changes: 10 additions & 2 deletions meshroom/aliceVision/SfmExpanding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0"
__version__ = "2.1"

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
Expand Down Expand Up @@ -131,11 +131,19 @@ class SfMExpanding(desc.AVCommandLineNode):
desc.FloatParam(
name="maxReprojectionError",
label="Max Reprojection Error",
description="Maximum reprojection error.",
description="Maximum reprojection error in the bundle verification step.",
value=4.0,
range=(0.1, 10.0, 0.1),
advanced=True,
),
desc.FloatParam(
name="maxTriangulationError",
label="Max Triangulation Error",
description="Maximum reprojection error in the triangulation process.",
value=8.0,
range=(0.1, 10.0, 0.1),
advanced=True,
),
desc.BoolParam(
name="lockAllIntrinsics",
label="Lock All Intrinsic Camera Parameters",
Expand Down
4 changes: 2 additions & 2 deletions meshroom/cameraTrackingExperimental.mg
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"Publish": "1.3",
"RelativePoseEstimating": "3.0",
"ScenePreview": "2.0",
"SfMBootStrapping": "4.0",
"SfMBootStrapping": "4.1",
"SfMColorizing": "1.0",
"SfMExpanding": "2.0",
"SfMExpanding": "2.1",
"SfMTransfer": "2.1",
"SfMTransform": "3.1",
"SfMTriangulation": "1.0",
Expand Down
4 changes: 2 additions & 2 deletions meshroom/cameraTrackingWithoutCalibrationExperimental.mg
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"Publish": "1.3",
"RelativePoseEstimating": "3.0",
"ScenePreview": "2.0",
"SfMBootStrapping": "4.0",
"SfMBootStrapping": "4.1",
"SfMColorizing": "1.0",
"SfMExpanding": "2.0",
"SfMExpanding": "2.1",
"SfMTransfer": "2.1",
"SfMTransform": "3.1",
"SfMTriangulation": "1.0",
Expand Down
4 changes: 2 additions & 2 deletions meshroom/photogrammetryAndCameraTrackingExperimental.mg
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"Publish": "1.3",
"RelativePoseEstimating": "3.0",
"ScenePreview": "2.0",
"SfMBootStrapping": "4.0",
"SfMBootStrapping": "4.1",
"SfMColorizing": "1.0",
"SfMExpanding": "2.0",
"SfMExpanding": "2.1",
"SfMTransfer": "2.1",
"SfMTransform": "3.1",
"Texturing": "6.0",
Expand Down
4 changes: 2 additions & 2 deletions meshroom/photogrammetryExperimental.mg
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"Meshing": "7.0",
"Publish": "1.3",
"RelativePoseEstimating": "3.0",
"SfMBootStrapping": "4.0",
"SfMBootStrapping": "4.1",
"SfMColorizing": "1.0",
"SfMExpanding": "2.0",
"SfMExpanding": "2.1",
"SfMTransform": "3.1",
"Texturing": "6.0",
"TracksBuilding": "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
/**
* @brief Constructor.
* @param[in] observations The observations 2d points in pixels.
* @param[in] weights The observations weights.
* @param[in] poses the transformation for each observation.
* @param[in] intrinsics the camera intrinsic for each observation.
*/
TriangulationSphericalKernel(
const std::vector<Vec2> & observations,
const std::vector<double> & weights,
const std::vector<Eigen::Matrix4d>& poses,
std::vector<std::shared_ptr<camera::IntrinsicBase>> & intrinsics
)
: _poses(poses)
, _intrinsics(intrinsics)
, _weights(weights)
{
for (int id = 0; id < observations.size(); id++)
{
Expand Down Expand Up @@ -134,10 +137,10 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
}

/**
* @brief Error for the i-th view
* @param[in] sample The index of the view for which the error is computed.
* @brief Error for the i-th observation
* @param[in] sample The index of the observation for which the error is computed.
* @param[in] model The 3D point.
* @return The estimation error for the given view and 3D point.
* @return The estimation error for the given observation and 3D point.
*/
double error(std::size_t sample, const ModelT & model) const override
{
Expand All @@ -147,9 +150,11 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
X = X / X(3);
}

double w = _weights[sample];

Vec2 residual = _intrinsics[sample]->residual(_poses[sample], X, _observations[sample], false);

return residual.norm();
return residual.norm() * w;
}

/**
Expand Down Expand Up @@ -217,6 +222,7 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
private:
std::vector<Vec3> _lifted;
std::vector<Vec2> _observations;
std::vector<double> _weights;
const std::vector<Eigen::Matrix4d> _poses;
const std::vector<std::shared_ptr<camera::IntrinsicBase>> _intrinsics;
multiview::TriangulateNViewsSphericalSolver _solver;
Expand Down
17 changes: 11 additions & 6 deletions src/aliceVision/sfm/pipeline/bootstrapping/PairsScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
const track::TracksPerView & tracksPerView,
const std::set<IndexT> & filterIn,
const std::set<IndexT> & filterOut,
double minAngle,
double hardMinAngle,
double softMinAngle,
double maxAngle)
{
IndexT bestPair = UndefinedIndexT;
Expand Down Expand Up @@ -74,26 +75,30 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
continue;
}

if (radianToDegree(angle) > maxAngle)
double degrees = radianToDegree(angle);
if (degrees > maxAngle)
{
continue;
}


if (degrees < hardMinAngle)
{
continue;
}

const sfmData::View & vref = sfmData.getView(pair.reference);
const sfmData::View & vnext = sfmData.getView(pair.next);

int maxref = std::max(vref.getImage().getWidth(), vref.getImage().getHeight());
int maxnext = std::max(vnext.getImage().getWidth(), vnext.getImage().getHeight());


double refScore = sfm::ExpansionPolicyLegacy::computeScore(tracksMap, usedTracks, pair.reference, maxref, 5);
double nextScore = sfm::ExpansionPolicyLegacy::computeScore(tracksMap, usedTracks, pair.next, maxnext, 5);

double score = std::min(refScore, nextScore) * std::max(1e-12, radianToDegree(angle));
//If the angle is too small, then dramatically reduce its chances
if (radianToDegree(angle) < minAngle)

//If the angle is too small, then dramatically reduce its chances
if (degrees < softMinAngle)
{
score = -1.0 / score;
}
Expand Down
6 changes: 4 additions & 2 deletions src/aliceVision/sfm/pipeline/bootstrapping/PairsScoring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace sfm {
* @param tracksPerView tracks grouped by views
* @param filterIn pair must contains one of the views inside this set (if non empty)
* @param filterout pair must NOT contains one of the views inside this set (if non empty)
* @param minAngle minimal angle allowed
* @param hardMinAngle minimal angle allowed (rejected)
* @param softMinAngle minimal angle allowed (tolerated, but heavily downgraded)
* @param maxAngle maximal angle allowed
* @return index in "pairs" of the best pair or UndefinedIndexT if no pair found
*/
Expand All @@ -32,7 +33,8 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
const track::TracksPerView & tracksPerView,
const std::set<IndexT> & filterIn,
const std::set<IndexT> & filterOut,
double minAngle,
double hardMinAngle,
double softMinAngle,
double maxAngle);

}
Expand Down
10 changes: 9 additions & 1 deletion src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class ExpansionChunk
/**
* @brief set the maximal error allowed for ransac resection module
* @param error the error value or <= 0 for automatic decision
* @param count the number of points
*/
void setResectionMaxError(double error)
{
Expand All @@ -89,6 +88,15 @@ class ExpansionChunk
_triangulationMinPoints = count;
}

/**
* @brief set the maximal reprojection error in the triangulation process.
* @param count the number of points
*/
void setTriangulationMaxError(double error)
{
_maxTriangulationError = error;
}

/**
* @brief set the minimal allowed parallax degree for triangulation
* @param angle the angle in DEGREES
Expand Down
6 changes: 5 additions & 1 deletion src/aliceVision/sfm/pipeline/expanding/SfmTriangulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ bool SfmTriangulation::processTrack(
{
feature::EImageDescriberType descType = track.descType;

std::vector<double> weights;
std::vector<Vec2> observations;
std::vector<std::shared_ptr<camera::IntrinsicBase>> intrinsics;
std::vector<Eigen::Matrix4d> poses;
Expand All @@ -126,6 +127,9 @@ bool SfmTriangulation::processTrack(
observations.push_back(coords);
intrinsics.push_back(intrinsic);
poses.push_back(pose);

//Weight is dependent on the feature scale
weights.push_back(1.0 / trackItem.scale);

indexedViewIds.push_back(viewId);
}
Expand All @@ -135,7 +139,7 @@ bool SfmTriangulation::processTrack(
robustEstimation::MatrixModel<Vec4> model;
std::vector<std::size_t> inliers;
robustEstimation::ScoreEvaluator<multiview::TriangulationSphericalKernel> scorer(_maxError);
multiview::TriangulationSphericalKernel kernel(observations, poses, intrinsics);
multiview::TriangulationSphericalKernel kernel(observations, weights, poses, intrinsics);

if (observations.size() <= 0)
{
Expand Down
10 changes: 6 additions & 4 deletions src/software/pipeline/main_sfmBootstrapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// These constants define the current software version.
// They must be updated when the command line is changed.
#define ALICEVISION_SOFTWARE_VERSION_MAJOR 4
#define ALICEVISION_SOFTWARE_VERSION_MINOR 0
#define ALICEVISION_SOFTWARE_VERSION_MINOR 1

using namespace aliceVision;

Expand Down Expand Up @@ -136,7 +136,8 @@ int aliceVision_main(int argc, char** argv)

// user optional parameters
const double maxEpipolarDistance = 4.0;
double minAngle = 5.0;
double minAngleHard = 1.0;
double minAngleSoft = 5.0;
double maxAngle = 40.0;
std::pair<std::string, std::string> initialPairString("", "");

Expand All @@ -155,7 +156,8 @@ int aliceVision_main(int argc, char** argv)
po::options_description optionalParams("Required parameters");
optionalParams.add_options()
("outputViewsAndPoses", po::value<std::string>(&outputSfMViewsAndPoses)->default_value(outputSfMViewsAndPoses), "Path to the output SfMData file (with only views and poses).")
("minAngleInitialPair", po::value<double>(&minAngle)->default_value(minAngle), "Minimum angle for the initial pair.")
("minAngleSoftInitialPair", po::value<double>(&minAngleSoft)->default_value(minAngleSoft), "Minimum angle for the initial pair (Score is downgraded heavily if angle is under this value).")
("minAngleHardInitialPair", po::value<double>(&minAngleHard)->default_value(minAngleHard), "Minimum angle for the initial pair validation.")
("maxAngleInitialPair", po::value<double>(&maxAngle)->default_value(maxAngle), "Maximum angle for the initial pair.")
("meshFilename,t", po::value<std::string>(&meshFilename)->required(), "Mesh object file.")
("initialPairA", po::value<std::string>(&initialPairString.first)->default_value(initialPairString.first), "UID or filepath or filename of the first image.")
Expand Down Expand Up @@ -342,7 +344,7 @@ int aliceVision_main(int argc, char** argv)
IndexT bestPairId = findBestPair(sfmData, reconstructedPairs,
tracksHandler.getAllTracks(), tracksHandler.getTracksPerView(),
filterIn, filterOut,
minAngle, maxAngle);
minAngleHard, minAngleSoft, maxAngle);

if (bestPairId == UndefinedIndexT)
{
Expand Down
7 changes: 5 additions & 2 deletions src/software/pipeline/main_sfmExpanding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// These constants define the current software version.
// They must be updated when the command line is changed.
#define ALICEVISION_SOFTWARE_VERSION_MAJOR 2
#define ALICEVISION_SOFTWARE_VERSION_MINOR 0
#define ALICEVISION_SOFTWARE_VERSION_MINOR 1

using namespace aliceVision;

Expand Down Expand Up @@ -97,6 +97,7 @@ int aliceVision_main(int argc, char** argv)
double minAngleForTriangulation = 3.0;
double minAngleForLandmark = 2.0;
double maxReprojectionError = 4.0;
double maxTriangulationError = 8.0;
bool lockAllIntrinsics = false;
int minNbCamerasToRefinePrincipalPoint = 3;
bool useRigConstraint = true;
Expand Down Expand Up @@ -132,7 +133,8 @@ int aliceVision_main(int argc, char** argv)
("minNumberOfObservationsForTriangulation", po::value<std::size_t>(&minNbObservationsForTriangulation)->default_value(minNbObservationsForTriangulation),"Minimum number of observations to triangulate a point")
("minAngleForTriangulation", po::value<double>(&minAngleForTriangulation)->default_value(minAngleForTriangulation),"Minimum angle for triangulation.")
("minAngleForLandmark", po::value<double>(&minAngleForLandmark)->default_value(minAngleForLandmark), "Minimum angle for landmark.")
("maxReprojectionError", po::value<double>(&maxReprojectionError)->default_value(maxReprojectionError), "Maximum reprojection error.")
("maxTriangulationError", po::value<double>(&maxTriangulationError)->default_value(maxTriangulationError), "Maximum reprojection error in the triangulation process.")
("maxReprojectionError", po::value<double>(&maxReprojectionError)->default_value(maxReprojectionError), "Maximum reprojection error in the bundle verification step.")
("lockAllIntrinsics", po::value<bool>(&lockAllIntrinsics)->default_value(lockAllIntrinsics), "Force lock of all camera intrinsic parameters, so they will not be refined during Bundle Adjustment.")
("minNbCamerasToRefinePrincipalPoint", po::value<int>(&minNbCamerasToRefinePrincipalPoint)->default_value(minNbCamerasToRefinePrincipalPoint),
"Minimal number of cameras to refine the principal point of the cameras (one of the intrinsic parameters of the camera). "
Expand Down Expand Up @@ -242,6 +244,7 @@ int aliceVision_main(int argc, char** argv)
expansionChunk->setExpansionHistoryHandler(expansionHistory);
expansionChunk->setResectionMaxIterations(localizerEstimatorMaxIterations);
expansionChunk->setResectionMaxError(localizerEstimatorError);
expansionChunk->setTriangulationMaxError(maxTriangulationError);
expansionChunk->setTriangulationMinPoints(minNbObservationsForTriangulation);
expansionChunk->setMinAngleTriangulation(minAngleForTriangulation);
expansionChunk->setPointFetcherHandler(pointFetcherHandler);
Expand Down
Loading