mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #25938 from vrabaud:charuco
Properly check markers when none are provided. #25938 CharucoDetectorImpl::detectBoard finds temporary markers when none are provided but those are discarded when charucoDetectorImpl::checkBoard is called. ### 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 - [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:
@@ -762,23 +762,29 @@ TEST_P(CharucoBoard, testWrongSizeDetection)
|
||||
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);
|
||||
for(int i: {0, 1}) {
|
||||
vector<int> detectedCharucoIds, detectedArucoIds;
|
||||
vector<Point2f> detectedCharucoCorners;
|
||||
vector<vector<Point2f>> detectedArucoCorners;
|
||||
if (i == 0) {
|
||||
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());
|
||||
} else {
|
||||
detector.detectBoard(boardImage, detectedCharucoCorners, detectedCharucoIds);
|
||||
}
|
||||
|
||||
// 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());
|
||||
// charuco corners should not be found in board with wrong size
|
||||
ASSERT_TRUE(detectedCharucoCorners.empty());
|
||||
ASSERT_TRUE(detectedCharucoIds.empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user