Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
tutorial-image-converter.cpp
1
2#include <visp3/core/vpImageConvert.h>
3#include <visp3/io/vpImageIo.h>
4
5int main()
6{
7#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
8 try {
9 cv::Mat A;
10#if VISP_HAVE_OPENCV_VERSION >= 0x030200
11 int flags = cv::IMREAD_GRAYSCALE | cv::IMREAD_IGNORE_ORIENTATION;
12#elif VISP_HAVE_OPENCV_VERSION >= 0x030000
13 int flags = cv::IMREAD_GRAYSCALE;
14#else
15 int flags = CV_LOAD_IMAGE_GRAYSCALE;
16#endif
17
18 A = cv::imread("monkey.bmp", flags);
19
22
23#ifdef VISP_HAVE_PNG
24 vpImageIo::write(I, "monkey.png"); // Gray
25#endif
26 } catch (const vpException &e) {
27 std::cout << "Catch an exception: " << e << std::endl;
28 }
29#endif
30}
error that can be emitted by ViSP classes.
Definition vpException.h:59
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition of the vpImage class member functions.
Definition vpImage.h:135