#include <iostream>
#include <visp3/core/vpImageConvert.h>
#include <visp3/io/vpImageIo.h>
#if VISP_HAVE_OPENCV_VERSION >= 0x020300
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif
int main()
{
#if VISP_HAVE_OPENCV_VERSION >= 0x020300
{
cv::Mat cv_img_color;
cv::Mat cv_img_grey;
std::cout << "Save converted images from vpImage to cv::Mat" << std::endl;
std::cout << "- monkey-cv-color.jpeg" << std::endl;
std::cout << "- monkey-cv-grey.jpeg" << std::endl;
cv::imwrite("monkey-cv-color.jpeg", cv_img_color);
cv::imwrite("monkey-cv-grey.jpeg", cv_img_grey);
}
{
#if VISP_HAVE_OPENCV_VERSION >= 0x030000
cv::Mat cv_img_color = cv::imread("monkey.jpeg", cv::IMREAD_COLOR);
#else
cv::Mat cv_img_color = cv::imread("monkey.jpeg", CV_LOAD_IMAGE_COLOR);
#endif
#if VISP_HAVE_OPENCV_VERSION >= 0x030000
cv::Mat cv_img_grey = cv::imread("monkey.jpeg", cv::IMREAD_GRAYSCALE);
#else
cv::Mat cv_img_grey = cv::imread("monkey.jpeg", CV_LOAD_IMAGE_GRAYSCALE);
#endif
std::cout << "Save converted images from cv::Mat to vpImage" << std::endl;
std::cout << "- monkey-vp-color.jpeg" << std::endl;
std::cout << "- monkey-vp-grey.jpeg" << std::endl;
}
#endif
}