Skip to content

fix testBoardSubpixelCoords #3224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AleksandrPanov
Copy link
Contributor

@AleksandrPanov AleksandrPanov commented Apr 11, 2022

Merge with extra: opencv/opencv_extra#969
This PR fix and enable testBoardSubpixelCoords test.
Old test image:
trivial_board_detection
This ChArUco board configuration is currently not possible. The top left square should always be black.

New test image:
new_trivial_board_detection
Blur added to the new test image to make the test more useful (the old image was also blurry, but not as much).

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • 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

Comment on lines -622 to -624
// load board image with corners at round values
cv::String testImagePath = cvtest::TS::ptr()->get_data_path() + "aruco/" + "trivial_board_detection.png";
Mat img = imread(testImagePath);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the test image is generated.

Comment on lines -626 to +632
200, 300,
250, 300,
300, 300,
200, 200,
250, 200,
300, 200,
200, 250,
250, 250,
300, 250,
200, 200,
250, 200,
300, 200
200, 300,
250, 300,
300, 300
Copy link
Contributor Author

@AleksandrPanov AleksandrPanov Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The positions of the "gold" markers have changed.


auto dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_APRILTAG_36h11);
auto board = cv::aruco::CharucoBoard::create(4, 4, 1.f, .8f, dict);

// generate ChArUco board
board->draw(Size(res.width, res.height), gray, 150);
cv::GaussianBlur(gray, gray, Size(5, 5), 1.0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blur test image.

@@ -652,18 +653,16 @@ TEST(Charuco, DISABLED_testBoardSubpixelCoords) // FIXIT: https://github.com/op

cv::Mat c_ids, c_corners;
cv::aruco::interpolateCornersCharuco(corners, ids, gray, board, c_corners, c_ids, K);
cv::Mat corners_reshaped = c_corners.reshape(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable corners_reshaped was not used


c_ids = cv::Mat();
c_corners = cv::Mat();
cv::aruco::interpolateCornersCharuco(corners, ids, gray, board, c_corners, c_ids);
corners_reshaped = c_corners.reshape(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable corners_reshaped was not used


ASSERT_EQ(c_corners.rows, expected_corners.rows);
EXPECT_NEAR(0, cvtest::norm(expected_corners, c_corners.reshape(1), NORM_INF), 1e-3);
EXPECT_NEAR(0, cvtest::norm(expected_corners, c_corners.reshape(1), NORM_INF), 1e-1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced accuracy requirement to 0.1 of a pixel.


ASSERT_EQ(c_corners.rows, expected_corners.rows);
EXPECT_NEAR(0, cvtest::norm(expected_corners, c_corners.reshape(1), NORM_INF), 1e-3);
EXPECT_NEAR(0, cvtest::norm(expected_corners, c_corners.reshape(1), NORM_INF), 1e-1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced accuracy requirement to 0.1 of a pixel.

@AleksandrPanov AleksandrPanov marked this pull request as ready for review April 11, 2022 15:31
@asmorkalov
Copy link
Contributor

LGTM: Tested on Ubuntu 18.04 amd64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants