Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Closed
Labels
Description
System information (version)
- OpenCV =>>= 4.5.0
- Operating System / Platform => N/A
- Compiler => N/A
Detailed description
Inliers convention withsolvePnPRansac and USAC option (from this GSoC work#17683) is different from defaultsolvePnPRansac methods:
- with USAC, it is a vector of
0/1for the input points - with classical methods, it is a vector of inlier indexes
I think using the same convention than before would be ok.
/cc@ivashmak
Steps to reproduce
constsize_t nbPoints =10; std::vector<cv::Point3d> objectPoints; std::vector<cv::Point2d> imagePoints; cv::RNGrng(0x123456789);for (size_t i =0; i < nbPoints; i++) { objectPoints.push_back(cv::Point3d(rng.uniform(0.0,0.1), rng.uniform(0.0,0.1), rng.uniform(0.0,0.1))); } cv::Matx31drvec(0.1,0.2,0.3), tvec(0.1,0.2,1); cv::Matx33dcameraMatrix(600,0,320,0,600,240,0,0,1);cv::projectPoints(objectPoints, rvec, tvec, cameraMatrix, cv::noArray(), imagePoints); imagePoints[0].x +=10; imagePoints[1].y +=10; imagePoints[2].x +=10; cv::Matx31d rvec_est, tvec_est; std::vector<int> inlierIndex;cv::solvePnPRansac(objectPoints, imagePoints, cameraMatrix, cv::noArray(), rvec_est, tvec_est, false, 1000, 2.0, 0.99, inlierIndex, cv::SOLVEPNP_ITERATIVE); std::vector<int> inlierIndex_usac; cv::Matx31d rvec_est_usac, tvec_est_usac;cv::solvePnPRansac(objectPoints, imagePoints, cameraMatrix, cv::noArray(), rvec_est_usac, tvec_est_usac, false, 1000, 2.0, 0.99, inlierIndex_usac, cv::USAC_ACCURATE); std::vector<int> inlierIndex_usac2; cv::Matx31d rvec_est_usac2, tvec_est_usac2;cv::solvePnPRansac(objectPoints, imagePoints, cameraMatrix, cv::noArray(), rvec_est_usac2, tvec_est_usac2, inlierIndex_usac2); std::cout <<"\nNORMAL:" << std::endl; std::cout <<"rvec:" << rvec.t() << std::endl; std::cout <<"rvec_est:" << rvec_est.t() << std::endl; std::cout <<"tvec:" << tvec.t() << std::endl; std::cout <<"tvec_est:" << tvec_est.t() << std::endl; std::cout <<"Inlier index:" << std::endl;for (auto idx : inlierIndex) { std::cout << idx << std::endl; } std::cout <<"\nUSAC:" << std::endl; std::cout <<"rvec:" << rvec.t() << std::endl; std::cout <<"rvec_est_usac:" << rvec_est_usac.t() << std::endl; std::cout <<"tvec:" << tvec.t() << std::endl; std::cout <<"tvec_est_usac:" << tvec_est_usac.t() << std::endl; std::cout <<"Inlier index:" << std::endl;for (auto idx : inlierIndex_usac) { std::cout << idx << std::endl; } std::cout <<"\nUSAC 2:" << std::endl; std::cout <<"rvec:" << rvec.t() << std::endl; std::cout <<"rvec_est_usac2:" << rvec_est_usac2.t() << std::endl; std::cout <<"tvec:" << tvec.t() << std::endl; std::cout <<"tvec_est_usac2:" << tvec_est_usac2.t() << std::endl; std::cout <<"Inlier index:" << std::endl;for (auto idx : inlierIndex_usac2) { std::cout << idx << std::endl; }
Output:
NORMAL:rvec: [0.1, 0.2, 0.3]rvec_est: [0.1000001115198924, 0.2000000619071916, 0.2999998504321869]tvec: [0.1, 0.2, 1]tvec_est: [0.0999999851190521, 0.2000000191436395, 1.000000038294651]Inlier index:3456789USAC:rvec: [0.1, 0.2, 0.3]rvec_est_usac: [0.0999956768017629, 0.1999999513689168, 0.3000022343620654]tvec: [0.1, 0.2, 1]tvec_est_usac: [0.1000017130274078, 0.200002461007063, 1.000010978690636]Inlier index:0001111111USAC 2:rvec: [0.1, 0.2, 0.3]rvec_est_usac2: [0.0999956768017629, 0.1999999513689168, 0.3000022343620654]tvec: [0.1, 0.2, 1]tvec_est_usac2: [0.1000017130274078, 0.200002461007063, 1.000010978690636]Inlier index:0001111111Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc