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 "hldc"
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);
242 main(
int argc,
const char ** argv)
245 bool opt_list =
false;
246 bool opt_click_allowed =
true;
247 bool opt_display =
true;
251 if (getOptions(argc, argv, opt_list,
252 opt_click_allowed, opt_display) ==
false) {
258 unsigned nbDevices = 0;
259 std::cout <<
"List of video-devices available: \n";
260 #if defined VISP_HAVE_GTK
261 std::cout <<
" GTK\n";
264 #if defined VISP_HAVE_X11
265 std::cout <<
" X11\n";
268 #if defined VISP_HAVE_GDI
269 std::cout <<
" GDI\n";
272 #if defined VISP_HAVE_D3D9
273 std::cout <<
" D3D\n";
276 #if defined VISP_HAVE_OPENCV
277 std::cout <<
" OpenCV\n";
281 std::cout <<
" No display is available\n";
298 #if defined VISP_HAVE_X11
301 Ix.
init(480, 640, 255);
304 displayX->
init(Ix, 100, 100,
"Display X11") ;
308 if (opt_click_allowed)
313 #if defined(VISP_HAVE_OPENCV)
316 Icv.
init(480, 640, 255);
319 displayCv->
init(Icv, 100, 100,
"Display OpenCV") ;
323 if (opt_click_allowed)
328 #if defined VISP_HAVE_GTK
331 Igtk.
init(480, 640, 255);
334 displayGtk->
init(Igtk, 100, 100,
"Display GTK") ;
338 if (opt_click_allowed)
343 #if defined VISP_HAVE_GDI
346 Igdi.
init(480, 640, 255);
349 displayGdi->
init(Igdi, 100, 100,
"Display GDI") ;
353 if (opt_click_allowed)
358 #if defined VISP_HAVE_D3D9
361 Id3d.
init(480, 640, 255);
364 displayD3d->
init(Id3d, 100, 100,
"Display Direct 3D") ;
368 if (opt_click_allowed)
375 #if defined VISP_HAVE_X11
379 #if defined VISP_HAVE_GTK
383 #if defined(VISP_HAVE_OPENCV)
387 #if defined VISP_HAVE_GDI
391 #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).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
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)
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