mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-20 12:55:15 +08:00
Merge pull request #1677 from gmedan:fix-charuco-topology
* fix #1665 ChAruco board topology (nearestMarkerIdx) is sensitive to scale
This commit is contained in:

committed by
Alexander Alekhin

parent
2bd8d58513
commit
02b991a433
@@ -194,7 +194,7 @@ void CharucoBoard::_getNearestMarkerCorners() {
|
|||||||
double sqDistance;
|
double sqDistance;
|
||||||
Point3f distVector = charucoCorner - center;
|
Point3f distVector = charucoCorner - center;
|
||||||
sqDistance = distVector.x * distVector.x + distVector.y * distVector.y;
|
sqDistance = distVector.x * distVector.x + distVector.y * distVector.y;
|
||||||
if(j == 0 || fabs(sqDistance - minDist) < 0.0001) {
|
if(j == 0 || fabs(sqDistance - minDist) < cv::pow(0.01 * _squareLength, 2)) {
|
||||||
// if same minimum distance (or first iteration), add to nearestMarkerIdx vector
|
// if same minimum distance (or first iteration), add to nearestMarkerIdx vector
|
||||||
nearestMarkerIdx[i].push_back(j);
|
nearestMarkerIdx[i].push_back(j);
|
||||||
minDist = sqDistance;
|
minDist = sqDistance;
|
||||||
|
@@ -538,7 +538,48 @@ void CV_CharucoDiamondDetection::run(int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check charuco board creation
|
||||||
|
*/
|
||||||
|
class CV_CharucoBoardCreation : public cvtest::BaseTest {
|
||||||
|
public:
|
||||||
|
CV_CharucoBoardCreation();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
CV_CharucoBoardCreation::CV_CharucoBoardCreation() {}
|
||||||
|
|
||||||
|
void CV_CharucoBoardCreation::run(int)
|
||||||
|
{
|
||||||
|
Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::DICT_5X5_250);
|
||||||
|
int n = 6;
|
||||||
|
|
||||||
|
float markerSizeFactor = 0.5f;
|
||||||
|
|
||||||
|
for (float squareSize_mm = 5.0f; squareSize_mm < 35.0f; squareSize_mm += 0.1f)
|
||||||
|
{
|
||||||
|
Ptr<aruco::CharucoBoard> board_meters = aruco::CharucoBoard::create(
|
||||||
|
n, n, squareSize_mm*1e-3f, squareSize_mm * markerSizeFactor * 1e-3f, dictionary);
|
||||||
|
|
||||||
|
Ptr<aruco::CharucoBoard> board_millimeters = aruco::CharucoBoard::create(
|
||||||
|
n, n, squareSize_mm, squareSize_mm * markerSizeFactor, dictionary);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < board_meters->nearestMarkerIdx.size(); i++)
|
||||||
|
{
|
||||||
|
if (board_meters->nearestMarkerIdx[i].size() != board_millimeters->nearestMarkerIdx[i].size() ||
|
||||||
|
board_meters->nearestMarkerIdx[i][0] != board_millimeters->nearestMarkerIdx[i][0])
|
||||||
|
{
|
||||||
|
ts->printf(cvtest::TS::LOG,
|
||||||
|
cv::format("Charuco board topology is sensitive to scale with squareSize=%.1f\n",
|
||||||
|
squareSize_mm).c_str());
|
||||||
|
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(CV_CharucoDetection, accuracy) {
|
TEST(CV_CharucoDetection, accuracy) {
|
||||||
@@ -546,7 +587,6 @@ TEST(CV_CharucoDetection, accuracy) {
|
|||||||
test.safe_run();
|
test.safe_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(CV_CharucoPoseEstimation, accuracy) {
|
TEST(CV_CharucoPoseEstimation, accuracy) {
|
||||||
CV_CharucoPoseEstimation test;
|
CV_CharucoPoseEstimation test;
|
||||||
test.safe_run();
|
test.safe_run();
|
||||||
@@ -557,4 +597,9 @@ TEST(CV_CharucoDiamondDetection, accuracy) {
|
|||||||
test.safe_run();
|
test.safe_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(CV_CharucoBoardCreation, accuracy) {
|
||||||
|
CV_CharucoBoardCreation test;
|
||||||
|
test.safe_run();
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
Reference in New Issue
Block a user