|
|
|
@ -345,11 +345,16 @@ TEST(usac_P3P, accuracy) { |
|
|
|
|
log(1 - pow(inl_ratio, 3 /* sample size */)); |
|
|
|
|
|
|
|
|
|
for (auto flag : flags) { |
|
|
|
|
std::vector<int> inliers; |
|
|
|
|
cv::Mat rvec, tvec, mask, R, P; |
|
|
|
|
CV_Assert(cv::solvePnPRansac(obj_pts, img_pts, K1, cv::noArray(), rvec, tvec, |
|
|
|
|
false, (int)max_iters, (float)thr, conf, mask, flag)); |
|
|
|
|
false, (int)max_iters, (float)thr, conf, inliers, flag)); |
|
|
|
|
cv::Rodrigues(rvec, R); |
|
|
|
|
cv::hconcat(K1 * R, K1 * tvec, P); |
|
|
|
|
mask.create(pts_size, 1, CV_8U); |
|
|
|
|
mask.setTo(Scalar::all(0)); |
|
|
|
|
for (auto inl : inliers) |
|
|
|
|
mask.at<uchar>(inl) = true; |
|
|
|
|
checkInliersMask(TestSolver ::PnP, inl_size, thr, img_pts, obj_pts, P, mask); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -416,19 +421,27 @@ TEST(usac_testUsacParams, accuracy) { |
|
|
|
|
// CV_Error(cv::Error::StsError, "Essential matrix estimation failed!");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<int> inliers(pts_size); |
|
|
|
|
// P3P
|
|
|
|
|
inl_size = generatePoints(rng, pts1, pts2, K1, K2, false, pts_size, TestSolver::PnP, |
|
|
|
|
getInlierRatio(usac_params.maxIterations, 3, usac_params.confidence), 0.01, gt_inliers); |
|
|
|
|
CV_Assert(cv::solvePnPRansac(pts2, pts1, K1, dist_coeff, rvec, tvec, mask, usac_params)); |
|
|
|
|
CV_Assert(cv::solvePnPRansac(pts2, pts1, K1, dist_coeff, rvec, tvec, inliers, usac_params)); |
|
|
|
|
cv::Rodrigues(rvec, R); cv::hconcat(K1 * R, K1 * tvec, model); |
|
|
|
|
mask.create(pts_size, 1, CV_8U); |
|
|
|
|
mask.setTo(Scalar::all(0)); |
|
|
|
|
for (auto inl : inliers) |
|
|
|
|
mask.at<uchar>(inl) = true; |
|
|
|
|
checkInliersMask(TestSolver::PnP, inl_size, usac_params.threshold, pts1, pts2, model, mask); |
|
|
|
|
|
|
|
|
|
// P6P
|
|
|
|
|
inl_size = generatePoints(rng, pts1, pts2, K1, K2, false, pts_size, TestSolver::PnP, |
|
|
|
|
getInlierRatio(usac_params.maxIterations, 6, usac_params.confidence), 0.1, gt_inliers); |
|
|
|
|
cv::Mat K_est; |
|
|
|
|
CV_Assert(cv::solvePnPRansac(pts2, pts1, K_est, dist_coeff, rvec, tvec, mask, usac_params)); |
|
|
|
|
CV_Assert(cv::solvePnPRansac(pts2, pts1, K_est, dist_coeff, rvec, tvec, inliers, usac_params)); |
|
|
|
|
cv::Rodrigues(rvec, R); cv::hconcat(K_est * R, K_est * tvec, model); |
|
|
|
|
mask.setTo(Scalar::all(0)); |
|
|
|
|
for (auto inl : inliers) |
|
|
|
|
mask.at<uchar>(inl) = true; |
|
|
|
|
checkInliersMask(TestSolver::PnP, inl_size, usac_params.threshold, pts1, pts2, model, mask); |
|
|
|
|
|
|
|
|
|
// Affine2D
|
|
|
|
|