From b6f213a8c774a946f63cede4221c919a132d62cd Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Mon, 17 Mar 2025 11:24:46 +0300 Subject: [PATCH] Merge pull request #27079 from MaximSmolskiy:add-test-for-ArucoDetector-detectMarkers Add test for ArucoDetector::detectMarkers #27079 ### Pull Request Readiness Checklist Related to #26968 and #26922 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 --- .../objdetect/test/test_arucodetection.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/objdetect/test/test_arucodetection.cpp b/modules/objdetect/test/test_arucodetection.cpp index fd957698b2..399aa36102 100644 --- a/modules/objdetect/test/test_arucodetection.cpp +++ b/modules/objdetect/test/test_arucodetection.cpp @@ -650,6 +650,40 @@ TEST(CV_ArucoDetectMarkers, regression_contour_24220) } } +TEST(CV_ArucoDetectMarkers, regression_26922) +{ + const auto arucoDict = aruco::getPredefinedDictionary(aruco::DICT_4X4_1000); + const aruco::GridBoard gridBoard(Size(19, 10), 1, 0.25, arucoDict); + + const Size imageSize(7200, 3825); + + Mat boardImage; + gridBoard.generateImage(imageSize, boardImage, 75, 1); + + const aruco::ArucoDetector detector(arucoDict); + + vector> corners; + vector ids; + detector.detectMarkers(boardImage, corners, ids); + + EXPECT_EQ(ids.size(), 190ull); + EXPECT_TRUE(find(ids.begin(), ids.end(), 76) != ids.end()); + EXPECT_TRUE(find(ids.begin(), ids.end(), 172) != ids.end()); + + float transformMatrixData[9] = {1, -0.2f, 300, 0.4f, 1, -1000, 0, 0, 1}; + const Mat transformMatrix(Size(3, 3), CV_32FC1, transformMatrixData); + + Mat warpedImage; + warpPerspective(boardImage, warpedImage, transformMatrix, imageSize); + + detector.detectMarkers(warpedImage, corners, ids); + + EXPECT_EQ(ids.size(), 133ull); + // markers with id 76 and 172 are on border and should not be detected + EXPECT_FALSE(find(ids.begin(), ids.end(), 76) != ids.end()); + EXPECT_FALSE(find(ids.begin(), ids.end(), 172) != ids.end()); +} + TEST(CV_ArucoMultiDict, setGetDictionaries) { vector dictionaries = {aruco::getPredefinedDictionary(aruco::DICT_4X4_50), aruco::getPredefinedDictionary(aruco::DICT_5X5_100)};