1 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImageConvert.h>
4 #include <visp3/io/vpImageIo.h>
6 #if defined(HAVE_OPENCV_IMGPROC)
7 #include <opencv2/core/core.hpp>
8 #include <opencv2/imgproc/imgproc.hpp>
13 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC)
14 #ifdef ENABLE_VISP_NAMESPACE
18 std::cout <<
"From OpenCV to ViSP conversion" << std::endl;
20 cv::Mat M_cv = (cv::Mat_<double>(3, 4) << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
21 std::cout <<
"M_cv: \n" << M_cv << std::endl;
25 vpMatrix M(
static_cast<unsigned int>(M_cv.rows),
static_cast<unsigned int>(M_cv.cols));
26 memcpy(M.data, M_cv.data,
sizeof(
double) *
static_cast<size_t>(M_cv.rows * M_cv.cols));
27 std::cout <<
"M: \n" << M << std::endl;
32 std::cout <<
"From ViSP to OpenCV conversion" << std::endl;
34 vpMatrix M(3, 4, { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
35 std::cout <<
"M: \n" << M << std::endl;
39 cv::Mat tmp(
static_cast<int>(M.getRows()),
static_cast<int>(M.getCols()), CV_64F,
static_cast<void *
>(M.data));
40 cv::Mat M_cv_deep = tmp.clone();
41 std::cout <<
"M_cv_deep: \n" << M_cv_deep << std::endl;
45 cv::Mat M_cv(
static_cast<int>(M.getRows()),
static_cast<int>(M.getCols()), CV_64F,
static_cast<void *
>(M.data));
46 std::cout <<
"M_cv: \n" << M_cv << std::endl;
50 std::cout <<
"Set M = eye" << std::endl;
52 std::cout <<
"M: \n" << M << std::endl;
53 std::cout <<
"M_cv: \n" << M_cv << std::endl;
Implementation of a matrix and operations on matrices.