flaky pnp test

This commit is contained in:
matlabbe
2026-06-07 15:24:43 -07:00
parent 1e311f5561
commit ecc416b795
+10 -7
View File
@@ -200,18 +200,21 @@ static Transform computeRegistrationRobust(
RegistrationInfo * infoOut = nullptr)
{
const int estimationType = std::atoi(params.at(Parameters::kVisEstimationType()).c_str());
const int maxAttempts = estimationType == 2 ? 50 : 1;
// Epipolar (type=2) is the most RANSAC-sensitive so it gets the biggest
// attempt budget; PnP (type=1) also uses RANSAC internally via
// cv::solvePnPRansac and has been observed to fail one-shot on CI's
// Ubuntu OpenCV build, so retry it too. F2F (type=0) is largely
// deterministic but cheap, so we still seed and retry a few times for
// uniformity.
const int maxAttempts = estimationType == 2 ? 50 : 10;
Transform result;
RegistrationInfo info;
for(int attempt = 0; attempt < maxAttempts; ++attempt)
{
if(estimationType == 2)
{
cv::theRNG() = cv::RNG(static_cast<uint64_t>(0x9e3779b97f4a7c15ULL) ^
static_cast<uint64_t>(attempt + 1));
}
cv::theRNG() = cv::RNG(static_cast<uint64_t>(0x9e3779b97f4a7c15ULL) ^
static_cast<uint64_t>(attempt + 1));
result = computeRegistration(fromData, toData, params, &info);
if(!result.isNull() || estimationType != 2)
if(!result.isNull())
{
break;
}