Skip to content

aruco: conflicting documentation in estimatePoseSingleMarkers #3250

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

Closed
crackwitz opened this issue May 12, 2022 · 4 comments
Closed

aruco: conflicting documentation in estimatePoseSingleMarkers #3250

crackwitz opened this issue May 12, 2022 · 4 comments
Assignees
Labels
category: aruco category: documentation Documentation fix or update, does not affect code

Comments

@crackwitz
Copy link

crackwitz commented May 12, 2022

  • OpenCV => 4.5.5

Documentation says:

The marker corrdinate [sic] system is centered on the middle of the marker, with the Z axis perpendicular to the marker plane.

This agrees with the implementation.

But it also says:

The coordinates of the four corners of the marker in its own coordinate system are: (0, 0, 0), (markerLength, 0, 0), (markerLength, markerLength, 0), (0, markerLength, 0)

This, to my mind, disagrees with the previous statement. (0,0,0) is the origin, which is the center of the marker, not any of its corners. Perhaps "its own coordinate system" refers to a different coordinate system... which it should not.

I would suggest the following:

The coordinates of the four corners of the marker in its own coordinate system are: (-markerLength/2, -markerLength/2, 0), (markerLength/2, -markerLength/2, 0), (markerLength/2, markerLength/2, 0), (-markerLength/2, markerLength/2, 0)

Or alternatively, to show with a diagram where and in what order the corners are.

I am doubting myself here, because recently someone reported that their code puts an axis triad at the corner of the marker... and I don't see why their code would do that (the python equivalent puts it in the center), but it would agree with the second sentence from the documentation.

@AleksandrPanov AleksandrPanov added category: aruco category: documentation Documentation fix or update, does not affect code labels May 18, 2022
@AleksandrPanov
Copy link
Contributor

AleksandrPanov commented May 18, 2022

@crackwitz, to make the pose estimation for the single marker and boards (estimatePoseSingleMarkers(), estimatePoseBoard(), estimatePoseCharucoBoard()) uniform, the coordinate system has been moved to the top left corner.

Thanks for the issue, I've updated the documentation and tutorial. For compatibility with old codes, I can add a mode for the algorithm.

@AleksandrPanov
Copy link
Contributor

To draw the axes in the old format, you can use this sample:

void drawCustomFrameAxes(Mat img, Mat cameraMatrix, InputArray distCoeffs, InputArray estimatedRvec,
                         InputArray estimatedTvec, float axisLength, int thickness = 3,
                         Point3f center = Point3f(0.f, 0.f, 0.f), Point3f axes = Point3f(1.f, -1.f, -1.f)) {
    vector<Point3f> ax = {center, center + Point3f(axes.x, 0.f, 0.f)*axisLength,
                          center + Point3f(0.f, axes.y, 0.f)* axisLength,
                          center + Point3f(0.f, 0.f, axes.z)*axisLength};
    Scalar colors[3] = {Scalar(0, 0, 255), Scalar(0, 255, 0), Scalar(255, 0, 0)};
    std::vector<Point2f> imagePoints;
    projectPoints(ax, estimatedRvec, estimatedTvec, cameraMatrix, distCoeffs, imagePoints);
    for (size_t i = 1ull; i < ax.size(); i++)
        line(img, imagePoints[0], imagePoints[i], colors[i-1], thickness);
}

drawCustomAxes.cpp.txt

image

Original image for example

CharucoPoseT20001

@AleksandrPanov
Copy link
Contributor

AleksandrPanov commented May 18, 2022

PR #3256 fixes docs/tutorial and add mode for old coordinate system

@crackwitz
Copy link
Author

crackwitz commented May 19, 2022

Does the second picture imply that now Z points into the marker?

Which order of corners is considered counter-clockwise? I'm concerned that the identifiers in #3256 are mixed up. Looking at a marker, it always used to be TL, TR, BR, BL, which I consider clockwise. Now, if X right, Y up, Z near ("old"), that's going negatively around Z. If X right Y down Z far ("new"), that's going positively around Z.

I wouldn't recommend using "clockwise"/"counterclockwise" there at all. The difference isn't the order of corners but the placement (orientation) of the coordinate system.

@AleksandrPanov AleksandrPanov mentioned this issue May 19, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: aruco category: documentation Documentation fix or update, does not affect code
Projects
None yet
Development

No branches or pull requests

3 participants