Skip to content

Commit 18ba385

Browse files
enpemeta-codesync[bot]
authored andcommitted
Fix flaky fisheye P3P RANSAC test
Summary: The randomized P3P RANSAC test intentionally uses ValidationPrecision with an 85% success threshold for float precision, but a single RANSAC::p3p() false return called OCEAN_SET_FAILED(). That permanently failed the validation and bypassed the statistical contract. Treat an unsuccessful solve as one inaccurate trial and continue without using its output, so repeated failures still fail through the unchanged aggregate threshold. The test also projected every correspondence after deliberately corrupting 15 of them. A corrupted 3D outlier is an arbitrary world point and need not satisfy camera projection preconditions. A deterministic reproduction with initial seed 3097702702 reached the gravity-constrained, unrefined case at iteration 44251; known faulty index 90 had camera-space z=7.15255737e-07, violating FisheyeCameraT<float>::projectToImageIF()'s |z| > 1e-6 precondition. Letting outliers participate in validation could additionally allow a coincidentally precise outlier to compensate for a missed true inlier. Exclude the ground-truth faulty indices from post-RANSAC accuracy validation. This avoids projecting intentionally invalid synthetic data and makes the accuracy check stricter: all valid correspondences must now pass, and outliers cannot hide missed inliers. No production RANSAC behavior, iteration count, or success/error threshold changes. ___ Differential Revision: D115804590 fbshipit-source-id: 6870367861e0f97e79a8b1065079f7cafbdebf04
1 parent a6362a0 commit 18ba385

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

impl/ocean/test/testgeometry/TestRANSAC.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,19 @@ bool TestRANSAC::testP3P(const AnyCameraType anyCameraType, const size_t corresp
530530

531531
if (!result)
532532
{
533-
OCEAN_SET_FAILED(validation);
533+
scopedIteration.setInaccurate();
534534

535535
continue;
536536
}
537537

538+
// Evaluate accuracy only for known inliers; corrupted 3D outliers need not satisfy camera projection preconditions.
539+
const std::vector<uint8_t> faultyStatements = Subset::indices2statements<Index32, 1u>(faultyIndices, objectPoints.size());
540+
const Indices32 validIndices = Subset::statements2indices<Index32, 0u>(faultyStatements);
541+
538542
Scalar sumSqrDistances = 0;
539543
size_t numberPreciseCorrespondences = 0;
540544

541-
for (size_t n = 0; n < objectPoints.size(); ++n)
545+
for (const Index32 n : validIndices)
542546
{
543547
const Vector2& imagePoint = imagePoints[n];
544548
const Vector3& objectPoint = objectPoints[n];

0 commit comments

Comments
 (0)