Visual Servoing Platform
version 3.2.0
tutorial-image-converter.cpp
1
2
#include <visp3/core/vpImageConvert.h>
3
#include <visp3/io/vpImageIo.h>
4
5
int
main()
6
{
7
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
8
try
{
9
cv::Mat A;
10
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
11
A = cv::imread(
"monkey.bmp"
, cv::IMREAD_GRAYSCALE);
12
#else
13
A = cv::imread(
"monkey.bmp"
, CV_LOAD_IMAGE_GRAYSCALE);
14
#endif
15
16
vpImage<unsigned char>
I;
17
vpImageConvert::convert
(A, I);
18
19
#ifdef VISP_HAVE_PNG
20
vpImageIo::write
(I,
"monkey.png"
);
// Gray
21
#endif
22
}
catch
(
const
vpException
&e) {
23
std::cout <<
"Catch an exception: "
<< e << std::endl;
24
}
25
#endif
26
}
vpImageConvert::convert
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition:
vpImageConvert.cpp:78
vpImageIo::write
static void write(const vpImage< unsigned char > &I, const std::string &filename)
Definition:
vpImageIo.cpp:374
vpImage< unsigned char >
vpException
error that can be emited by ViSP classes.
Definition:
vpException.h:70
tutorial
image
tutorial-image-converter.cpp
Generated by
1.8.16