ViSP  2.9.0
tutorial-image-viewer.cpp
1 
2 #include <visp/vpDisplayGDI.h>
3 #include <visp/vpDisplayX.h>
4 #include <visp/vpImageIo.h>
5 #include <visp/vpImagePoint.h>
6 
7 int main()
8 {
9  try {
11  vpImageIo::read(I, "lena.ppm");
12 
13 #if defined(VISP_HAVE_X11)
14  vpDisplayX d(I);
15 #elif defined(VISP_HAVE_GDI)
16  vpDisplayGDI d(I);
17 #else
18  std::cout << "No image viewer is available..." << std::endl;
19 #endif
20  vpDisplay::setTitle(I, "Lena");
22 
23  vpDisplay::displayRectangle(I, vpImagePoint(90,90), 70, 90, vpColor::red, false, 2);
25 
27  vpDisplay::getImage(I, O);
28 
29  try {
30  vpImageIo::write(I, "lena-out.jpg");
31  vpImageIo::write(O, "lena-out-with-overlay.jpg2");
32  }
33  catch(...) {
34  std::cout << "Cannot write the image: unsupported format..." << std::endl;
35  }
36 
38  }
39  catch(vpException e) {
40  std::cout << "Catch an exception: " << e << std::endl;
41  }
42 }
static void write(const vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:452
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:132
Define the X11 console to display images.
Definition: vpDisplayX.h:152
error that can be emited by ViSP classes.
Definition: vpException.h:76
static void flush(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:1994
static const vpColor red
Definition: vpColor.h:167
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
virtual void setTitle(const char *title)=0
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:324
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
static void read(vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:278