4 #include <visp3/core/vpConfig.h>
5 #include <visp3/core/vpImageConvert.h>
6 #include <visp3/io/vpImageIo.h>
8 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
9 #include <opencv2/core/core.hpp>
10 #include <opencv2/imgproc/imgproc.hpp>
11 #include <opencv2/imgcodecs/imgcodecs.hpp>
15 #ifdef ENABLE_VISP_NAMESPACE
40 std::cout <<
"Save converted images from vpImage to cv::Mat" << std::endl;
41 std::cout <<
"- monkey-cv-color.jpeg" << std::endl;
42 std::cout <<
"- monkey-cv-grey.jpeg" << std::endl;
44 cv::imwrite(
"monkey-cv-color.jpeg", cv_img_color);
47 cv::imwrite(
"monkey-cv-grey.jpeg", cv_img_grey);
54 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
55 cv::Mat cv_img_color = cv::imread(
"monkey.jpeg", cv::IMREAD_COLOR);
57 cv::Mat cv_img_color = cv::imread(
"monkey.jpeg", CV_LOAD_IMAGE_COLOR);
67 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
68 cv::Mat cv_img_grey = cv::imread(
"monkey.jpeg", cv::IMREAD_GRAYSCALE);
70 cv::Mat cv_img_grey = cv::imread(
"monkey.jpeg", CV_LOAD_IMAGE_GRAYSCALE);
79 std::cout <<
"Save converted images from cv::Mat to vpImage" << std::endl;
80 std::cout <<
"- monkey-vp-color.jpeg" << std::endl;
81 std::cout <<
"- monkey-vp-grey.jpeg" << std::endl;
93 std::cout <<
"This tutorial required OpenCV imgproc and imgcodecs modules." << std::endl;
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)