@@ -611,35 +611,36 @@ TEST(Charuco, testCharucoCornersCollinear_false)
611611}
612612
613613// test that ChArUco board detection is subpixel accurate
614- TEST (Charuco, DISABLED_testBoardSubpixelCoords) // FIXIT: https://github.com/opencv/opencv_contrib/pull/3213
614+ TEST (Charuco, testBoardSubpixelCoords)
615615{
616616 cv::Size res{500 , 500 };
617617 cv::Mat K = (cv::Mat_<double >(3 ,3 ) <<
618618 0.5 *res.width , 0 , 0.5 *res.width ,
619619 0 , 0.5 *res.height , 0.5 *res.height ,
620620 0 , 0 , 1 );
621621
622- // load board image with corners at round values
623- cv::String testImagePath = cvtest::TS::ptr ()->get_data_path () + " aruco/" + " trivial_board_detection.png" ;
624- Mat img = imread (testImagePath);
622+ // set expected_corners values
625623 cv::Mat expected_corners = (cv::Mat_<float >(9 ,2 ) <<
626- 200 , 300 ,
627- 250 , 300 ,
628- 300 , 300 ,
624+ 200 , 200 ,
625+ 250 , 200 ,
626+ 300 , 200 ,
629627 200 , 250 ,
630628 250 , 250 ,
631629 300 , 250 ,
632- 200 , 200 ,
633- 250 , 200 ,
634- 300 , 200
630+ 200 , 300 ,
631+ 250 , 300 ,
632+ 300 , 300
635633 );
636634
637635 cv::Mat gray;
638- cv::cvtColor (img, gray, cv::COLOR_BGR2GRAY);
639636
640637 auto dict = cv::aruco::getPredefinedDictionary (cv::aruco::DICT_APRILTAG_36h11);
641638 auto board = cv::aruco::CharucoBoard::create (4 , 4 , 1 .f , .8f , dict);
642639
640+ // generate ChArUco board
641+ board->draw (Size (res.width , res.height ), gray, 150 );
642+ cv::GaussianBlur (gray, gray, Size (5 , 5 ), 1.0 );
643+
643644 auto params = cv::aruco::DetectorParameters::create ();
644645 params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_APRILTAG;
645646
@@ -652,18 +653,16 @@ TEST(Charuco, DISABLED_testBoardSubpixelCoords) // FIXIT: https://github.com/op
652653
653654 cv::Mat c_ids, c_corners;
654655 cv::aruco::interpolateCornersCharuco (corners, ids, gray, board, c_corners, c_ids, K);
655- cv::Mat corners_reshaped = c_corners.reshape (1 );
656656
657657 ASSERT_EQ (c_corners.rows , expected_corners.rows );
658- EXPECT_NEAR (0 , cvtest::norm (expected_corners, c_corners.reshape (1 ), NORM_INF), 1e-3 );
658+ EXPECT_NEAR (0 , cvtest::norm (expected_corners, c_corners.reshape (1 ), NORM_INF), 1e-1 );
659659
660660 c_ids = cv::Mat ();
661661 c_corners = cv::Mat ();
662662 cv::aruco::interpolateCornersCharuco (corners, ids, gray, board, c_corners, c_ids);
663- corners_reshaped = c_corners.reshape (1 );
664663
665664 ASSERT_EQ (c_corners.rows , expected_corners.rows );
666- EXPECT_NEAR (0 , cvtest::norm (expected_corners, c_corners.reshape (1 ), NORM_INF), 1e-3 );
665+ EXPECT_NEAR (0 , cvtest::norm (expected_corners, c_corners.reshape (1 ), NORM_INF), 1e-1 );
667666}
668667
669668TEST (CV_ArucoTutorial, can_find_choriginal)
0 commit comments