Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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/vpDisplayOpenCV.h>
7 #include <visp3/gui/vpDisplayX.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  } catch (...) {
28  std::cout << "Cannot read image \"" << argv[1] << "\"" << std::endl;
29  return -1;
30  }
32 
33  try {
35 #if defined(VISP_HAVE_X11)
37 #elif defined(VISP_HAVE_GDI)
39 #elif defined(VISP_HAVE_OPENCV)
41 #elif defined(VISP_HAVE_GTK)
43 #elif defined(VISP_HAVE_D3D9)
44  vpDisplayD3d d(I, vpDisplay::SCALE_AUTO);
45 #else
46  std::cout << "No image viewer is available..." << std::endl;
47 #endif
48 
51  vpDisplay::setTitle(I, "My image");
57  std::cout << "A click to quit..." << std::endl;
61  } catch (const vpException &e) {
62  std::cout << "Catch an exception: " << e << std::endl;
63  }
64 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:129
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:151
error that can be emited by ViSP classes.
Definition: vpException.h:71
static void flush(const vpImage< unsigned char > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:138
static void read(vpImage< unsigned char > &I, const std::string &filename)
Definition: vpImageIo.cpp:207
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)