42 #include <visp/vpConfig.h>
43 #include <visp/vpDebug.h>
49 #if (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_OPENCV))
51 #include <visp/vpImage.h>
52 #include <visp/vpImageIo.h>
53 #include <visp/vpParseArgv.h>
54 #include <visp/vpIoTools.h>
55 #include <visp/vpRect.h>
57 #include <visp/vpDisplayOpenCV.h>
58 #include <visp/vpDisplayGTK.h>
59 #include <visp/vpDisplayX.h>
60 #include <visp/vpDisplayGDI.h>
61 #include <visp/vpDisplayD3D.h>
71 #define GETOPTARGS "hl:dc"
73 void usage(
const char *name,
const char *badparam);
74 bool getOptions(
int argc,
const char **argv,
bool &list,
bool &click_allowed,
bool &display);
85 void usage(
const char *name,
const char *badparam)
88 Test video devices or display.\n\
91 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
99 Disable the mouse click. Useful to automaze the \n\
100 execution of this program without humain intervention.\n\
103 Turn off the display.\n\
106 Print the list of video-devices available and exit.\n\
109 Print the help.\n\n");
112 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
127 bool getOptions(
int argc,
const char **argv,
bool &list,
bool &click_allowed,
bool &display)
131 std::string sDisplayType;
135 case 'l': list =
true;
break;
136 case 'h': usage(argv[0], NULL);
return false;
break;
137 case 'c': click_allowed =
false;
break;
138 case 'd': display =
false;
break;
141 usage(argv[0], optarg_);
return false;
break;
145 if ((c == 1) || (c == -1)) {
147 usage(argv[0], NULL);
148 std::cerr <<
"ERROR: " << std::endl;
149 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
233 vpRect rectangle(iP1, iP2);
244 main(
int argc,
const char ** argv)
247 bool opt_list =
false;
248 bool opt_click_allowed =
true;
249 bool opt_display =
true;
253 if (getOptions(argc, argv, opt_list,
254 opt_click_allowed, opt_display) ==
false) {
260 unsigned nbDevices = 0;
261 std::cout <<
"List of video-devices available: \n";
262 #if defined VISP_HAVE_GTK
263 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
266 #if defined VISP_HAVE_X11
267 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
270 #if defined VISP_HAVE_GDI
271 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
274 #if defined VISP_HAVE_D3D9
275 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
278 #if defined VISP_HAVE_OPENCV
279 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
283 std::cout <<
" No display is available\n";
300 #if defined VISP_HAVE_X11
303 Ix.
init(480, 640, 255);
306 displayX->
init(Ix, 100, 100,
"Display X11") ;
310 if (opt_click_allowed)
315 #if defined VISP_HAVE_OPENCV
318 Icv.
init(480, 640, 255);
321 displayCv->
init(Icv, 100, 100,
"Display OpenCV") ;
325 if (opt_click_allowed)
330 #if defined VISP_HAVE_GTK
333 Igtk.
init(480, 640, 255);
336 displayGtk->
init(Igtk, 100, 100,
"Display GTK") ;
340 if (opt_click_allowed)
345 #if defined VISP_HAVE_GDI
348 Igdi.
init(480, 640, 255);
351 displayGdi->
init(Igdi, 100, 100,
"Display GDI") ;
355 if (opt_click_allowed)
360 #if defined VISP_HAVE_D3D9
363 Id3d.
init(480, 640, 255);
366 displayD3d->
init(Id3d, 100, 100,
"Display Direct 3D") ;
370 if (opt_click_allowed)
377 #if defined VISP_HAVE_X11
381 #if defined VISP_HAVE_GTK
385 #if defined VISP_HAVE_OPENCV
389 #if defined VISP_HAVE_GDI
393 #if defined VISP_HAVE_D3D9
virtual void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)=0
void init(unsigned int height, unsigned int width)
set the size of the image
static const vpColor black
Display for windows using GDI (available on any windows 32 platform).
Define the X11 console to display images.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static const vpColor orange
Display for windows using Direct3D.
void set_i(const double ii)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void set_j(const double jj)
virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)=0
Defines a rectangle in the plane.
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 ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
static const vpColor yellow
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0
static const vpColor blue