Visual Servoing Platform version 3.5.0
tutorial-image-viewer.cpp
1
2#include <visp3/core/vpImagePoint.h>
3#include <visp3/gui/vpDisplayGDI.h>
4#include <visp3/gui/vpDisplayOpenCV.h>
5#include <visp3/gui/vpDisplayX.h>
6#include <visp3/io/vpImageIo.h>
7
8int main()
9{
10 try {
12 vpImageIo::read(I, "monkey.ppm");
13
14#if defined(VISP_HAVE_X11)
15 vpDisplayX d(I);
16#elif defined(VISP_HAVE_GDI)
17 vpDisplayGDI d(I);
18#elif defined(VISP_HAVE_OPENCV)
19 vpDisplayOpenCV d(I);
20#else
21 std::cout << "No image viewer is available..." << std::endl;
22#endif
23 vpDisplay::setTitle(I, "Monkey");
25
26 vpDisplay::displayRectangle(I, vpImagePoint(90, 90), 70, 90, vpColor::red, false, 2);
28
31
32 try {
33 vpImageIo::write(I, "monkey-out.jpg");
34 vpImageIo::write(O, "monkey-out-with-overlay.jpg");
35 } catch (...) {
36 std::cout << "Cannot write the image: unsupported format..." << std::endl;
37 }
38
40 } catch (const vpException &e) {
41 std::cout << "Catch an exception: " << e << std::endl;
42 }
43}
static const vpColor red
Definition: vpColor.h:217
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:129
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:135
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:144
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &I)
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
error that can be emited by ViSP classes.
Definition: vpException.h:72
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:149
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:293
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88