Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
tutorial-viewer.cpp
1 #include <visp3/core/vpConfig.h>
4 #include <visp3/gui/vpDisplayD3D.h>
5 #include <visp3/gui/vpDisplayGDI.h>
6 #include <visp3/gui/vpDisplayGTK.h>
7 #include <visp3/gui/vpDisplayOpenCV.h>
8 #include <visp3/gui/vpDisplayX.h>
11 #include <visp3/io/vpImageIo.h>
13 
14 int main(int argc, char **argv)
15 {
16 #ifdef ENABLE_VISP_NAMESPACE
17  using namespace VISP_NAMESPACE_NAME;
18 #endif
19  if (argc != 2) {
20  printf("Usage: %s <image name.[pgm,ppm,jpeg,png,tiff,bmp,ras,jp2]>\n", argv[0]);
21  return EXIT_FAILURE;
22  }
23 
27 
29  try {
30  vpImageIo::read(I, argv[1]);
31  }
32  catch (...) {
33  std::cout << "Cannot read image \"" << argv[1] << "\"" << std::endl;
34  return EXIT_FAILURE;
35  }
37 
38  try {
40 #if defined(VISP_HAVE_X11)
42 #elif defined(VISP_HAVE_GDI)
44 #elif defined(HAVE_OPENCV_HIGHGUI)
46 #elif defined(VISP_HAVE_GTK)
48 #elif defined(VISP_HAVE_D3D9)
50 #else
51  std::cout << "No image viewer is available..." << std::endl;
52 #endif
53 
56  vpDisplay::setTitle(I, "My image");
62  std::cout << "A click to quit..." << std::endl;
66 }
67  catch (const vpException &e) {
68  std::cout << "Catch an exception: " << e << std::endl;
69  }
70 }
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Definition: vpDisplayD3D.h:106
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:130
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:133
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 setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &I)
@ SCALE_AUTO
Definition: vpDisplay.h:184
error that can be emitted by ViSP classes.
Definition: vpException.h:60
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:147