Add size check for Rodrigues() function #16242
Merged
opencv-pushbot merged 1 commit intoopencv:3.4from Dec 27, 2019
Merged
Conversation
catree
commented
Dec 27, 2019
modules/calib3d/src/calibration.cpp
Outdated
| CV_INSTRUMENT_REGION(); | ||
|
|
||
| Mat src = _src.getMat(); | ||
| CV_Check(src.rows, (src.rows == 1 && src.cols == 3) || (src.rows == 3 && src.cols == 1) || (src.rows == 3 && src.cols == 3), |
Contributor
Author
There was a problem hiding this comment.
It is
#define CV_Check(v, test_expr, msg)
Here, somehow it would have been better to have multiple v to print the values of src.rows and src.cols or have a version without v maybe: #define CV_Check(test_expr, msg)?
Alternative is to use CV_Assert((src.rows == 1 && src.cols == 3) || (src.rows == 3 && src.cols == 1) || (src.rows == 3 && src.cols == 3));
But I think it is better to have an error message and I hope that most of the users will actually read the full message error.
7366169 to
badd0d1
Compare
alalek
approved these changes
Dec 27, 2019
Member
alalek
left a comment
There was a problem hiding this comment.
Thank you!
CV_Check(src.rows, ...
I will add support for Size / MatSize in check utilities in a separate PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pullrequest changes
When calling the
Rodriguesfunction with a4x4(or any wrong size) matrix, the function does nothing and lets the destination matrix unitialized. This leads to this kind of confusion / issue: SO issueWhich strategy should be adopted to deal with bad arguments (maybe related #8300)?
Here the shape of the input source matrix is wrong, so it makes sense in my opinion to throw an error.
Otherwise, at least a debug mesage or trace log should be somehow recorded.
Also, unfortunately people are still looking at, refering to the 2.4 documentation.