Skip to content

Commit a2c32bd

Browse files
authored
Merge pull request #1912 from alicevision/dev/sfmParameters
[sfm] Add new parameters to the SfM process
2 parents 652eca2 + 072b35f commit a2c32bd

File tree

13 files changed

+80
-34
lines changed

13 files changed

+80
-34
lines changed

meshroom/aliceVision/SfmBootstrapping.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.0"
1+
__version__ = "4.1"
22

33
from meshroom.core import desc
44
from meshroom.core.utils import VERBOSE_LEVEL
@@ -37,13 +37,21 @@ class SfMBootStrapping(desc.AVCommandLineNode):
3737
value="",
3838
),
3939
desc.FloatParam(
40-
name="minAngleInitialPair",
41-
label="Min Angle Initial Pair",
42-
description="Minimum angle for the initial pair.",
40+
name="minAngleSoftInitialPair",
41+
label="Min Angle Initial Pair (Soft)",
42+
description="Pair score is downgraded heavily if angle is under this value",
4343
value=5.0,
4444
range=(0.1, 10.0, 0.1),
4545
advanced=True,
4646
),
47+
desc.FloatParam(
48+
name="minAngleHardInitialPair",
49+
label="Min Angle Initial Pair (Hard)",
50+
description="Minimum angle for the initial pair validation.",
51+
value=1.0,
52+
range=(0.1, 10.0, 0.1),
53+
advanced=True,
54+
),
4755
desc.FloatParam(
4856
name="maxAngleInitialPair",
4957
label="Max Angle Initial Pair",

meshroom/aliceVision/SfmExpanding.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.0"
1+
__version__ = "2.1"
22

33
from meshroom.core import desc
44
from meshroom.core.utils import VERBOSE_LEVEL
@@ -131,11 +131,19 @@ class SfMExpanding(desc.AVCommandLineNode):
131131
desc.FloatParam(
132132
name="maxReprojectionError",
133133
label="Max Reprojection Error",
134-
description="Maximum reprojection error.",
134+
description="Maximum reprojection error in the bundle verification step.",
135135
value=4.0,
136136
range=(0.1, 10.0, 0.1),
137137
advanced=True,
138138
),
139+
desc.FloatParam(
140+
name="maxTriangulationError",
141+
label="Max Triangulation Error",
142+
description="Maximum reprojection error in the triangulation process.",
143+
value=8.0,
144+
range=(0.1, 10.0, 0.1),
145+
advanced=True,
146+
),
139147
desc.BoolParam(
140148
name="lockAllIntrinsics",
141149
label="Lock All Intrinsic Camera Parameters",

meshroom/cameraTrackingExperimental.mg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"Publish": "1.3",
2828
"RelativePoseEstimating": "3.0",
2929
"ScenePreview": "2.0",
30-
"SfMBootStrapping": "4.0",
30+
"SfMBootStrapping": "4.1",
3131
"SfMColorizing": "1.0",
32-
"SfMExpanding": "2.0",
32+
"SfMExpanding": "2.1",
3333
"SfMTransfer": "2.1",
3434
"SfMTransform": "3.1",
3535
"SfMTriangulation": "1.0",

meshroom/cameraTrackingWithoutCalibrationExperimental.mg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"Publish": "1.3",
2727
"RelativePoseEstimating": "3.0",
2828
"ScenePreview": "2.0",
29-
"SfMBootStrapping": "4.0",
29+
"SfMBootStrapping": "4.1",
3030
"SfMColorizing": "1.0",
31-
"SfMExpanding": "2.0",
31+
"SfMExpanding": "2.1",
3232
"SfMTransfer": "2.1",
3333
"SfMTransform": "3.1",
3434
"SfMTriangulation": "1.0",

meshroom/photogrammetryAndCameraTrackingExperimental.mg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"Publish": "1.3",
2828
"RelativePoseEstimating": "3.0",
2929
"ScenePreview": "2.0",
30-
"SfMBootStrapping": "4.0",
30+
"SfMBootStrapping": "4.1",
3131
"SfMColorizing": "1.0",
32-
"SfMExpanding": "2.0",
32+
"SfMExpanding": "2.1",
3333
"SfMTransfer": "2.1",
3434
"SfMTransform": "3.1",
3535
"Texturing": "6.0",

meshroom/photogrammetryExperimental.mg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"Meshing": "7.0",
1616
"Publish": "1.3",
1717
"RelativePoseEstimating": "3.0",
18-
"SfMBootStrapping": "4.0",
18+
"SfMBootStrapping": "4.1",
1919
"SfMColorizing": "1.0",
20-
"SfMExpanding": "2.0",
20+
"SfMExpanding": "2.1",
2121
"SfMTransform": "3.1",
2222
"Texturing": "6.0",
2323
"TracksBuilding": "1.0"

src/aliceVision/multiview/triangulation/TriangulationSphericalKernel.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
2121
/**
2222
* @brief Constructor.
2323
* @param[in] observations The observations 2d points in pixels.
24+
* @param[in] weights The observations weights.
2425
* @param[in] poses the transformation for each observation.
2526
* @param[in] intrinsics the camera intrinsic for each observation.
2627
*/
2728
TriangulationSphericalKernel(
2829
const std::vector<Vec2> & observations,
30+
const std::vector<double> & weights,
2931
const std::vector<Eigen::Matrix4d>& poses,
3032
std::vector<std::shared_ptr<camera::IntrinsicBase>> & intrinsics
3133
)
3234
: _poses(poses)
3335
, _intrinsics(intrinsics)
36+
, _weights(weights)
3437
{
3538
for (int id = 0; id < observations.size(); id++)
3639
{
@@ -134,10 +137,10 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
134137
}
135138

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

153+
double w = _weights[sample];
154+
150155
Vec2 residual = _intrinsics[sample]->residual(_poses[sample], X, _observations[sample], false);
151156

152-
return residual.norm();
157+
return residual.norm() * w;
153158
}
154159

155160
/**
@@ -217,6 +222,7 @@ class TriangulationSphericalKernel : public robustEstimation::IRansacKernel<robu
217222
private:
218223
std::vector<Vec3> _lifted;
219224
std::vector<Vec2> _observations;
225+
std::vector<double> _weights;
220226
const std::vector<Eigen::Matrix4d> _poses;
221227
const std::vector<std::shared_ptr<camera::IntrinsicBase>> _intrinsics;
222228
multiview::TriangulateNViewsSphericalSolver _solver;

src/aliceVision/sfm/pipeline/bootstrapping/PairsScoring.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
1818
const track::TracksPerView & tracksPerView,
1919
const std::set<IndexT> & filterIn,
2020
const std::set<IndexT> & filterOut,
21-
double minAngle,
21+
double hardMinAngle,
22+
double softMinAngle,
2223
double maxAngle)
2324
{
2425
IndexT bestPair = UndefinedIndexT;
@@ -74,26 +75,30 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
7475
continue;
7576
}
7677

77-
if (radianToDegree(angle) > maxAngle)
78+
double degrees = radianToDegree(angle);
79+
if (degrees > maxAngle)
7880
{
7981
continue;
8082
}
8183

82-
84+
if (degrees < hardMinAngle)
85+
{
86+
continue;
87+
}
8388

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

8792
int maxref = std::max(vref.getImage().getWidth(), vref.getImage().getHeight());
8893
int maxnext = std::max(vnext.getImage().getWidth(), vnext.getImage().getHeight());
89-
9094

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

9498
double score = std::min(refScore, nextScore) * std::max(1e-12, radianToDegree(angle));
95-
//If the angle is too small, then dramatically reduce its chances
96-
if (radianToDegree(angle) < minAngle)
99+
100+
//If the angle is too small, then dramatically reduce its chances
101+
if (degrees < softMinAngle)
97102
{
98103
score = -1.0 / score;
99104
}

src/aliceVision/sfm/pipeline/bootstrapping/PairsScoring.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace sfm {
2222
* @param tracksPerView tracks grouped by views
2323
* @param filterIn pair must contains one of the views inside this set (if non empty)
2424
* @param filterout pair must NOT contains one of the views inside this set (if non empty)
25-
* @param minAngle minimal angle allowed
25+
* @param hardMinAngle minimal angle allowed (rejected)
26+
* @param softMinAngle minimal angle allowed (tolerated, but heavily downgraded)
2627
* @param maxAngle maximal angle allowed
2728
* @return index in "pairs" of the best pair or UndefinedIndexT if no pair found
2829
*/
@@ -32,7 +33,8 @@ IndexT findBestPair(const sfmData::SfMData & sfmData,
3233
const track::TracksPerView & tracksPerView,
3334
const std::set<IndexT> & filterIn,
3435
const std::set<IndexT> & filterOut,
35-
double minAngle,
36+
double hardMinAngle,
37+
double softMinAngle,
3638
double maxAngle);
3739

3840
}

src/aliceVision/sfm/pipeline/expanding/ExpansionChunk.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class ExpansionChunk
6969
/**
7070
* @brief set the maximal error allowed for ransac resection module
7171
* @param error the error value or <= 0 for automatic decision
72-
* @param count the number of points
7372
*/
7473
void setResectionMaxError(double error)
7574
{
@@ -89,6 +88,15 @@ class ExpansionChunk
8988
_triangulationMinPoints = count;
9089
}
9190

91+
/**
92+
* @brief set the maximal reprojection error in the triangulation process.
93+
* @param count the number of points
94+
*/
95+
void setTriangulationMaxError(double error)
96+
{
97+
_maxTriangulationError = error;
98+
}
99+
92100
/**
93101
* @brief set the minimal allowed parallax degree for triangulation
94102
* @param angle the angle in DEGREES

0 commit comments

Comments
 (0)