39#include <visp3/core/vpConfig.h>
41#include "vpImageIoBackend.h"
43#ifdef VISP_HAVE_OPENCV
44#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
45#if defined(HAVE_OPENCV_IMGCODECS)
46#include <opencv2/imgcodecs.hpp>
49#if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)
50#include <opencv2/core/core.hpp>
51#include <opencv2/highgui/highgui.hpp>
52#include <opencv2/imgproc/imgproc.hpp>
57#include <visp3/core/vpImageConvert.h>
59#if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
78#if defined(VISP_HAVE_OPENCV)
79#if VISP_HAVE_OPENCV_VERSION >= 0x030200
80 int flags = cv::IMREAD_GRAYSCALE | cv::IMREAD_IGNORE_ORIENTATION;
81#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
82 int flags = cv::IMREAD_GRAYSCALE;
84 int flags = CV_LOAD_IMAGE_GRAYSCALE;
86 cv::Mat Ip = cv::imread(filename.c_str(), flags);
113#if defined(VISP_HAVE_OPENCV)
114#if VISP_HAVE_OPENCV_VERSION >= 0x030200
115 int flags = cv::IMREAD_COLOR | cv::IMREAD_IGNORE_ORIENTATION;
116#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
117 int flags = cv::IMREAD_COLOR;
119 int flags = CV_LOAD_IMAGE_COLOR;
121 cv::Mat Ip = cv::imread(filename.c_str(), flags);
131#if defined(VISP_HAVE_OPENCV)
132#if VISP_HAVE_OPENCV_VERSION >= 0x030200
133 int flags = cv::IMREAD_COLOR | cv::IMREAD_IGNORE_ORIENTATION;
134#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
135 int flags = cv::IMREAD_COLOR;
137 int flags = CV_LOAD_IMAGE_COLOR;
139 cv::Mat Ip = cv::imread(filename.c_str(), flags);
151#if defined(VISP_HAVE_OPENCV)
152#if VISP_HAVE_OPENCV_VERSION >= 0x030200
153 int flags = cv::IMREAD_COLOR | cv::IMREAD_IGNORE_ORIENTATION;
154#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
155 int flags = cv::IMREAD_COLOR;
157 int flags = CV_LOAD_IMAGE_COLOR;
159 cv::Mat Ip = cv::imread(filename.c_str(), flags);
181 std::vector<int> compression_params;
182 compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
183 compression_params.push_back(quality);
184 cv::imwrite(filename.c_str(), Ip, compression_params);
194void writeOpenCV(
const vpImage<vpRGBa> &I,
const std::string &filename,
int quality)
199 std::vector<int> compression_params;
200 compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
201 compression_params.push_back(quality);
202 cv::imwrite(filename.c_str(), Ip, compression_params);
205void writeOpenCV(
const vpImage<float> &I,
const std::string &filename)
210 cv::imwrite(filename.c_str(), Ip);
218 cv::imwrite(filename.c_str(), Ip);
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Error that can be emitted by the vpImage class and its derivatives.
Definition of the vpImage class member functions.