Skip to content

Add size check for Rodrigues() function #16242

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
catree:add_Rodrigues_input_shape_check
Dec 27, 2019
Merged

Add size check for Rodrigues() function #16242
opencv-pushbot merged 1 commit intoopencv:3.4from
catree:add_Rodrigues_input_shape_check

Conversation

@catree
Copy link
Copy Markdown
Contributor

@catree catree commented Dec 27, 2019

This pullrequest changes

When calling the Rodrigues function with a 4x4 (or any wrong size) matrix, the function does nothing and lets the destination matrix unitialized. This leads to this kind of confusion / issue: SO issue


Which 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.

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),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@catree catree force-pushed the add_Rodrigues_input_shape_check branch from 7366169 to badd0d1 Compare December 27, 2019 05:08
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you!

CV_Check(src.rows, ...

I will add support for Size / MatSize in check utilities in a separate PR.

@opencv-pushbot opencv-pushbot merged commit badd0d1 into opencv:3.4 Dec 27, 2019
This was referenced Dec 28, 2019
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.

4 participants