1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-03-04 16:42:12 +03:00
42 changed files with 3445 additions and 816 deletions
+35
View File
@@ -1131,5 +1131,40 @@ TEST(Imgproc_Resize, issue_26497)
EXPECT_LE(maxv, 3.);
}
TEST(Imgproc_getPerspectiveTransform, issue_26916)
{
double src_data[] = {320, 512, 960, 512, 0, 1024, 1280, 1024};
const Mat src_points(4, 2, CV_64FC1, src_data);
double dst_data[] = {0, 0, 1280, 0, 0, 1024, 1280, 1024};
const Mat dst_points(4, 2, CV_64FC1, dst_data);
Mat src_points_f;
src_points.convertTo(src_points_f, CV_32FC1);
Mat dst_points_f;
dst_points.convertTo(dst_points_f, CV_32FC1);
Mat perspective_transform = getPerspectiveTransform(src_points_f, dst_points_f);
EXPECT_NEAR(perspective_transform.at<double>(2, 2), 0, 1e-16);
EXPECT_NEAR(cv::norm(perspective_transform), 1, 1e-14);
const Mat ones = Mat::ones(4, 1, CV_64FC1);
Mat homogeneous_src_points;
hconcat(src_points, ones, homogeneous_src_points);
Mat obtained_homogeneous_dst_points = (perspective_transform * homogeneous_src_points.t()).t();
for (int row = 0; row < 4; ++row)
{
obtained_homogeneous_dst_points.row(row) /= obtained_homogeneous_dst_points.at<double>(row, 2);
}
Mat expected_homogeneous_dst_points;
hconcat(dst_points, ones, expected_homogeneous_dst_points);
EXPECT_MAT_NEAR(obtained_homogeneous_dst_points, expected_homogeneous_dst_points, 1e-10);
}
}} // namespace
/* End of file. */