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
This commit is contained in:
Maxim Smolskiy 2025-03-17 11:24:46 +03:00 committed by GitHub
parent 0a39f98bee
commit b6f213a8c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<vector<Point2f>> corners;
vector<int> 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<aruco::Dictionary> dictionaries = {aruco::getPredefinedDictionary(aruco::DICT_4X4_50), aruco::getPredefinedDictionary(aruco::DICT_5X5_100)};