1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-02-19 09:31:51 +03:00
130 changed files with 6998 additions and 3110 deletions
+52
View File
@@ -245,6 +245,58 @@ TEST_F(fisheyeTest, solvePnP)
ASSERT_TRUE(converged);
}
TEST_F(fisheyeTest, solvePnPRansac)
{
const int inliers_n = 16;
const int outliers_n = 4;
const bool use_extrinsic_guess = false;
const int iterations_count = 100;
const float reprojection_error = 1.0;
const double confidence = 0.99;
const cv::Matx33d R_mat ( 9.9756700084424932e-01, 6.9698277640183867e-02, 1.4929569991321144e-03,
-6.9711825162322980e-02, 9.9748249845531767e-01, 1.2997180766418455e-02,
-5.8331736398316541e-04,-1.3069635393884985e-02, 9.9991441852366736e-01);
const cv::Vec3d T(-9.9217369356044638e-02, 3.1741831972356663e-03, 1.8551007952921010e-04);
cv::Mat rvec;
cv::Rodrigues(R_mat, rvec);
// inliers
cv::Mat inlier_obj_points(1, inliers_n, CV_64FC3);
theRNG().fill(inlier_obj_points, cv::RNG::NORMAL, 2, 1);
inlier_obj_points = cv::abs(inlier_obj_points) * 10;
cv::Mat inlier_img_points;
cv::fisheye::projectPoints(inlier_obj_points, inlier_img_points, rvec, T, this->K, this->D);
// outliers
cv::Mat outlier_obj_points(1, outliers_n, CV_64FC3);
theRNG().fill(outlier_obj_points, cv::RNG::NORMAL, 2, 1);
outlier_obj_points = cv::abs(outlier_obj_points) * 10;
cv::Mat outlier_img_points;
cv::fisheye::projectPoints(outlier_obj_points, outlier_img_points, rvec, (T * 10), this->K, this->D);
cv::Mat obj_points;
cv::hconcat(outlier_obj_points, inlier_obj_points, obj_points);
cv::Mat img_points;
cv::hconcat(outlier_img_points, inlier_img_points, img_points);
cv::Mat rvec_pred;
cv::Mat tvec_pred;
cv::Mat inliers_pred;
bool converged = cv::fisheye::solvePnPRansac(obj_points, img_points, this->K, this->D,
rvec_pred, tvec_pred, use_extrinsic_guess,
iterations_count, reprojection_error, confidence, inliers_pred);
EXPECT_MAT_NEAR(rvec, rvec_pred, 1e-5);
EXPECT_MAT_NEAR(T, tvec_pred, 1e-5);
EXPECT_EQ(inliers_pred.size[0], inliers_n);
ASSERT_TRUE(converged);
}
TEST_F(fisheyeTest, undistortImage)
{
// we use it to reduce patch size for images in testdata