diff --git a/modules/core/include/opencv2/core/eigen.hpp b/modules/core/include/opencv2/core/eigen.hpp index c8603aca97..741648edb8 100644 --- a/modules/core/include/opencv2/core/eigen.hpp +++ b/modules/core/include/opencv2/core/eigen.hpp @@ -60,7 +60,7 @@ namespace cv //! @{ template static inline -void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst ) +void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, OutputArray dst ) { if( !(src.Flags & Eigen::RowMajorBit) ) { diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 91a93539fc..f585c4f28f 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -3,6 +3,12 @@ // of this distribution and at http://opencv.org/license.html. #include "test_precomp.hpp" +#ifdef HAVE_EIGEN +#include +#include +#include "opencv2/core/eigen.hpp" +#endif + namespace opencv_test { namespace { class Core_ReduceTest : public cvtest::BaseTest @@ -1972,4 +1978,22 @@ TEST(Core_Vectors, issue_13078_workaround) ASSERT_EQ(7, ints[3]); } + +#ifdef HAVE_EIGEN +TEST(Core_Eigen, eigen2cv_check_Mat_type) +{ + Mat A(4, 4, CV_32FC1, Scalar::all(0)); + Eigen::MatrixXf eigen_A; + cv2eigen(A, eigen_A); + + Mat_ f_mat; + EXPECT_NO_THROW(eigen2cv(eigen_A, f_mat)); + EXPECT_EQ(CV_32FC1, f_mat.type()); + + Mat_ d_mat; + EXPECT_ANY_THROW(eigen2cv(eigen_A, d_mat)); + //EXPECT_EQ(CV_64FC1, d_mat.type()); +} +#endif // HAVE_EIGEN + }} // namespace