Add missing cv2eigen overload#25751
Merged
asmorkalov merged 3 commits intoopencv:4.xfrom Jun 20, 2024
Merged
Conversation
Add overloads to cv2eigen to handle eigen matrices of type Eigen::Matrix<Tp_, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
Contributor
opencv-alalek
left a comment
There was a problem hiding this comment.
Thank you for contribution!
modules/core/test/test_mat.cpp
Outdated
|
|
||
| TEST(Core_Eigen, cv2eigen_check_RowMajor) | ||
| { | ||
| Mat A(2, 2, CV_32FC1, Scalar::all(0)); |
Contributor
There was a problem hiding this comment.
2, 2
It makes sense to use different values for width/height (e.g. 3,2) to verify argument order issue.
| void cv2eigen( const Mat& src, | ||
| Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>& dst ) | ||
| { | ||
| dst.resize(src.rows, src.cols); |
Contributor
There was a problem hiding this comment.
check for src.dims == 2:
CV_CheckEQ(src.dims, 2, "");
modules/core/test/test_mat.cpp
Outdated
| Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_A; | ||
| EXPECT_NO_THROW(cv2eigen(A, eigen_A)); | ||
|
|
||
| ASSERT_EQ(eigen_A(0, 0), 1.0); |
Contributor
There was a problem hiding this comment.
Signature for _EQ is ASSERT_EQ(expected_reference, actual_result);.
Correct order of parameters are required to emit valid error messages.
Reference: https://github.com/opencv/opencv/blob/4.0.0/modules/ts/include/opencv2/ts/ts_gtest.h#L8196-L8200
GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
const char* actual_expression,
const std::string& expected_value,
const std::string& actual_value,
bool ignoring_case);
opencv-alalek
approved these changes
Jun 19, 2024
Contributor
opencv-alalek
left a comment
There was a problem hiding this comment.
LGTM 👍 Thank you for contribution!
Merged
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.
Fixes #16606
Add overloads to cv2eigen to handle eigen matrices of type
Eigen::Matrix<Tp_, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
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.