1 #include <visp3/core/vpImageConvert.h> 3 #include <visp3/io/vpImageIo.h> 5 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 6 #include <opencv2/core/core.hpp> 7 #include <opencv2/imgproc/imgproc.hpp> 12 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 14 std::cout <<
"From OpenCV to ViSP conversion" << std::endl;
16 cv::Mat M_cv = (cv::Mat_<double>(3, 4) << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
17 std::cout <<
"M_cv: \n" << M_cv << std::endl;
21 vpMatrix M(static_cast<unsigned int>(M_cv.rows), static_cast<unsigned int>(M_cv.cols));
22 memcpy(M.data, M_cv.data,
sizeof(
double) * static_cast<size_t>(M_cv.rows * M_cv.cols));
23 std::cout <<
"M: \n" << M << std::endl;
28 std::cout <<
"From ViSP to OpenCV conversion" << std::endl;
30 vpMatrix M(3, 4, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} );
31 std::cout <<
"M: \n" << M << std::endl;
35 cv::Mat tmp(static_cast<int>(M.getRows()), static_cast<int>(M.getCols()), CV_64F, static_cast<void *>(M.data));
36 cv::Mat M_cv_deep = tmp.clone();
37 std::cout <<
"M_cv_deep: \n" << M_cv_deep << std::endl;
41 cv::Mat M_cv(static_cast<int>(M.getRows()), static_cast<int>(M.getCols()), CV_64F, static_cast<void *>(M.data));
42 std::cout <<
"M_cv: \n" << M_cv << std::endl;
46 std::cout <<
"Set M = eye" << std::endl;
48 std::cout <<
"M: \n" << M << std::endl;
49 std::cout <<
"M_cv: \n" << M_cv << std::endl;
Implementation of a matrix and operations on matrices.