mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #23647 from AleksandrPanov:fix_charuco_board_detect
Add charuco board check #23647 Added charuco board checking to avoid detection of incorrect board. Fixes #23517 ### Pull Request Readiness Checklist 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 - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -689,4 +689,32 @@ TEST(Charuco, testmatchImagePoints)
|
||||
}
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam<cv::Size> CharucoBoard;
|
||||
INSTANTIATE_TEST_CASE_P(/**/, CharucoBoard, testing::Values(Size(3, 2), Size(3, 2), Size(6, 2), Size(2, 6),
|
||||
Size(3, 4), Size(4, 3), Size(7, 3), Size(3, 7)));
|
||||
TEST_P(CharucoBoard, testWrongSizeDetection)
|
||||
{
|
||||
cv::Size boardSize = GetParam();
|
||||
ASSERT_FALSE(boardSize.width == boardSize.height);
|
||||
aruco::CharucoBoard board(boardSize, 1.f, 0.5f, aruco::getPredefinedDictionary(aruco::DICT_4X4_50));
|
||||
|
||||
vector<int> detectedCharucoIds, detectedArucoIds;
|
||||
vector<Point2f> detectedCharucoCorners;
|
||||
vector<vector<Point2f>> detectedArucoCorners;
|
||||
Mat boardImage;
|
||||
board.generateImage(boardSize*40, boardImage);
|
||||
|
||||
swap(boardSize.width, boardSize.height);
|
||||
aruco::CharucoDetector detector(aruco::CharucoBoard(boardSize, 1.f, 0.5f, aruco::getPredefinedDictionary(aruco::DICT_4X4_50)));
|
||||
// try detect board with wrong size
|
||||
detector.detectBoard(boardImage, detectedCharucoCorners, detectedCharucoIds, detectedArucoCorners, detectedArucoIds);
|
||||
|
||||
// aruco markers must be found
|
||||
ASSERT_EQ(detectedArucoIds.size(), board.getIds().size());
|
||||
ASSERT_EQ(detectedArucoCorners.size(), board.getIds().size());
|
||||
// charuco corners should not be found in board with wrong size
|
||||
ASSERT_TRUE(detectedCharucoCorners.empty());
|
||||
ASSERT_TRUE(detectedCharucoIds.empty());
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user