mirror of
https://github.com/opencv/opencv.git
synced 2026-09-13 05:42:51 -05:00
Merge pull request #25308 from dkurt:not_normalized_findHomography
Not-normalized output from findHomography #25308 ### Pull Request Readiness Checklist resolves https://github.com/opencv/opencv/issues/25133 resolves https://github.com/opencv/opencv/issues/4834 resolves https://github.com/opencv/opencv/issues/22166 resolves https://github.com/opencv/opencv/issues/18592 See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -704,4 +704,27 @@ TEST(Calib3d_Homography, minPoints)
|
||||
EXPECT_THROW(findHomography(p1, p2, RANSAC, 0.01, mask), cv::Exception);
|
||||
}
|
||||
|
||||
TEST(Calib3d_Homography, not_normalized)
|
||||
{
|
||||
Mat_<double> p1({5, 2}, {-1, -1, -2, -2, -1, 1, -2, 2, -1, 0});
|
||||
Mat_<double> p2({5, 2}, {0, -1, -1, -1, 0, 0, -1, 0, 0, -0.5});
|
||||
Mat_<double> ref({3, 3}, {
|
||||
0.74276086, 0., 0.74276086,
|
||||
0.18569022, 0.18569022, 0.,
|
||||
-0.37138043, 0., 0.
|
||||
});
|
||||
|
||||
for (int method : std::vector<int>({0, RANSAC, LMEDS}))
|
||||
{
|
||||
Mat h = findHomography(p1, p2, method);
|
||||
for (auto it = h.begin<double>(); it != h.end<double>(); ++it) {
|
||||
ASSERT_FALSE(cvIsNaN(*it)) << format("method %d\nResult:\n", method) << h;
|
||||
}
|
||||
if (h.at<double>(0, 0) * ref.at<double>(0, 0) < 0) {
|
||||
h *= -1;
|
||||
}
|
||||
ASSERT_LE(cv::norm(h, ref, NORM_INF), 1e-8) << format("method %d\nResult:\n", method) << h;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user