aruco: new feature testCharucoCornersCollinear() in charuco.hpp/cpp#2514
aruco: new feature testCharucoCornersCollinear() in charuco.hpp/cpp#2514alalek merged 5 commits intoopencv:3.4from
Conversation
Fixed parameter listing for Doxygen.
|
The build failed b/c the parameter names didn't match those in the function. I tried to fix that in charuco.hpp and committed the branch again. |
alalek
left a comment
There was a problem hiding this comment.
It would be nice if you can add simple test for testCharucoCornersCollinear() function
| * The number of ids in charucoIDs should be <= the number of chessboard corners in the board. This functions checks whether the charuco corners are on a straight line (returns true, if so), or not (false). Axis parallel, as well as diagonal and other straight lines detected. Degenerate cases: for number of charucoIDs <= 2, the function returns true. | ||
| */ | ||
| CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr<CharucoBoard> &_board, | ||
| InputArray _charucoIds); |
There was a problem hiding this comment.
_board
You can use parameter names without underscore symbol in headers (no need to synchronize with .cpp)
-indentation fixes -switched order of the test for nCharucoCorners > 2 as suggested
|
Re: |
|
Consider adding test into this file. No need to put/read image somewhere, just hard-code corner values in test code directly (you can dump them from your example pictures above). |
|
Ok -- thanks for the explanation, which I understood. I'll give this a try another day this week. |
|
I created the test and ran it successfully on my system. Before the build system went down for maintenance, it indicated the test code wasn't in compliance w/ C++98, so I tried to fix that on the last commit. |
alalek
left a comment
There was a problem hiding this comment.
Well done! Thank you for contribution 👍
When using charuco corners for calibration, specifically in the robotics context when full-pattern images of the charuco boards are not gauranteed, there are cases when the chaurco corners identified are collinear.
The corners (in my application) are usually axis aligned, but when these identified corners are axis aligned or just linear (some diagonal within the pattern), using these corners will result in errors via CV_ASSERT checks, or poor results b/c of the numerical issues of using collinear points for estimating calibration parameters.
There does not exist any functionality w/in the opencv_contrib module for checking whether the charuco corners are collinear, given a charuco board. In
charuco.cpp, there is functionstatic bool _arePointsEnoughForPoseEstimation(const vector< Point3f > &points)called byestimatePoseCharucoBoard(). This function is local tocharuco.cpp, though, and only checks for axis-aligned collinear charuco corners.The new feature is a function in charuco.hpp/.cpp that checks for collinear charuco corners,
testCharucoCornersCollinear().mwe.zip
The MWE mwe.zip (with some input images) alters
calibrate_camera_charuco.cppto demonstrate situations in which calibration fails when there are collinear charuco corners. In 3.4, the warning messageis displayed and the intrinisic camera calibration matrix contains nan values.
In 4.3/master, an exception is thrown:
The image below illustrate one such image. I did not have a diagonal case detected in my dataset, but created one to test.
Within the MWE, I show how I would use this new feature -- to choose whether to include (or not) detected charuco boards.
For this PR, I included everything in the PR versus putting the failure cases in a separate issue. I am new to submitting PRs to OpenCV, let me know what works better. I also used the 3.4 branch this time.
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.