Visual Servoing Platform  version 3.0.0
tutorial-viewer.cpp
1 #include <visp3/gui/vpDisplayD3D.h>
4 #include <visp3/gui/vpDisplayGDI.h>
5 #include <visp3/gui/vpDisplayGTK.h>
6 #include <visp3/gui/vpDisplayX.h>
7 #include <visp3/gui/vpDisplayOpenCV.h>
10 #include <visp3/io/vpImageIo.h>
12 
13 int main(int argc, char** argv)
14 {
15  if(argc != 2) {
16  printf( "Usage: %s <image name.[pgm,ppm,jpeg,png,tiff,bmp,ras,jp2]>\n", argv[0] );
17  return -1;
18  }
19 
23 
25  try {
26  vpImageIo::read(I, argv[1]);
27  }
28  catch(...) {
29  std::cout << "Cannot read image \"" << argv[1] << "\"" << std::endl;
30  return -1;
31  }
33 
34  try {
36 #if defined(VISP_HAVE_X11)
37  vpDisplayX d(I);
38 #elif defined(VISP_HAVE_GDI)
39  vpDisplayGDI d(I);
40 #elif defined(VISP_HAVE_OPENCV)
41  vpDisplayOpenCV d(I);
42 #elif defined(VISP_HAVE_GTK)
43  vpDisplayGTK d(I);
44 #elif defined(VISP_HAVE_D3D9)
45  vpDisplayD3d d(I);
46 #else
47  std::cout << "No image viewer is available..." << std::endl;
48 #endif
49  vpDisplay::setTitle(I, "My image");
57  std::cout << "A click to quit..." << std::endl;
61  }
62  catch(vpException e) {
63  std::cout << "Catch an exception: " << e << std::endl;
64  }
65 }
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
Define the X11 console to display images.
Definition: vpDisplayX.h:148
error that can be emited by ViSP classes.
Definition: vpException.h:73
static void flush(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:2233
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
The vpDisplayOpenCV allows to display image using the opencv library.
virtual void setTitle(const char *title)=0
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
Definition: vpDisplayGTK.h:141
virtual bool getClick(bool blocking=true)=0
static void read(vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:274