-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Fix objPoints order in GridBoard and CharucoBoard #3174
Conversation
3bd672c
to
f824b1b
Compare
|
||
// rotate camera in pitch axis | ||
Mat rotPitch(3, 1, CV_64FC1); | ||
rotPitch.ptr< double >(0)[0] = pitch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rotPitch.at< double >(i, j) is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
9e0a992
to
03dd8c5
Compare
@@ -294,7 +294,7 @@ class CV_EXPORTS_W Board { | |||
CV_WRAP void setIds(InputArray ids); | |||
|
|||
/// array of object points of all the marker corners in the board | |||
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4. | |||
/// each marker include its 4 corners in CW order. For M markers, the size is Mx4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense to mention CW or CCW without specifying used coordinate system.
Please take a look on calib3d module documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this definition:
/// each marker include its 4 corners in this order:
///- objPoints[i][0] - left-top point of i-th marker
///- objPoints[i][1] - right-top point of i-th marker
///- objPoints[i][2] - right-bottom point of i-th marker
///- objPoints[i][3] - left-bottom point of i-th marker
corners[2] = corners[0] + Point3f(markerLength, -markerLength, 0); | ||
corners[3] = corners[0] + Point3f(0, -markerLength, 0); | ||
corners[2] = corners[0] + Point3f(markerLength, markerLength, 0); | ||
corners[3] = corners[0] + Point3f(0, markerLength, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just changed the coordinate system by flipping Y.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes was added to make coordinate systems consistent.
Now Board::create()
uses this coordinate system:
But Board::draw()
uses another coordinate system:
Also, Board::create()
sets corners for marker in objPoints
with "CCW" order:
But detectMarkers()
finds markers and reorders corners to "CW" order:
This makes coordinate systems not consistent and makes the code hard to read
namespace opencv_test { | ||
namespace { | ||
|
||
static inline double deg2rad(double deg) { return deg * CV_PI / 180.; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid indentation in namespaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
03dd8c5
to
6e81f89
Compare
6e81f89
to
4970a6d
Compare
@alalek thanks for the review) |
53e8e38
to
f18dcbd
Compare
f18dcbd
to
63204ac
Compare
modules/aruco/src/aruco.cpp
Outdated
axis.push_back(Point3f(0.f, 0.f, 0.f)); | ||
axis.push_back(Point3f(length, 0.f, 0.f)); | ||
axis.push_back(Point3f(0.f, length, 0.f)); | ||
axis.push_back(Point3f(0.f, 0.f, -length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why -length
? Your function differs from standard drawFrameAxes with opposite direction of the third axis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to improve appearance. The drawAxis() function doesn't make sense, as it is just calls drawFrameAxes().
axis.push_back(Point3f(offset, offset, 0.f)); | ||
axis.push_back(Point3f(length+offset, offset, 0.f)); | ||
axis.push_back(Point3f(offset, length+offset, 0.f)); | ||
axis.push_back(Point3f(offset, offset, -length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, the result axis direction is opposite to what standard drawFrameAxes does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
3b22360
to
de40e05
Compare
30824a4
to
0f44c79
Compare
0f44c79
to
f8470c6
Compare
@catree, thx) |
@catree, I think that good API for handling SE3/SO3 transformations should add into another PR. This PR fixes only ArUco problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
…oints Fix objPoints order in GridBoard and CharucoBoard * fix gridBoard * fix charucoBoard * add rightBottomBorder * add test_aruco_utils and code refactoring/fix tests * fix axes and add charuco dict * add axes test, remove drawAxis(), update tutorial (cherry picked from commit 56d492c)
Hello, @AleksandrPanov |
It looks like this change makes Is this change intentional? If so, how can I recover the corresponding index for |
Fixes #2623 and #2604
This PR:
Fixed objPoints order in GridBoard and CharucoBoard.
In the
_drawPlanarBoardImpl()
function the y coordiantes of the charuco markers get horizontally mirrored bypf.y = (1.0f - pf.y / sizeY) * float(out.rows);
Nowpf.y = pf.y / sizeY * float(out.rows);
Drawing correctness was checked by example.cpp.txt
Before fix:
objPoints
andids
for 3x4aruco::GridBoard
are in the wrong orderobjPoints
andids
for 3x4aruco::CharucoBoard
are in the wrong order. AlsoobjPoints
coordinates are incorrect.After fix:
Everything is drawn correctly.
Fixed generation of rotated images (in ArUco tests). Now rotated images are generated using the "aircraft principal axes".
Also fixed
objPoints[markerIndex]
order (from CCW to CW) in GridBoard and CharucoBoard. Because tutorial and all ArUco algs use CW order.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.