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"
81 void usage(
const char *name,
const char *badparam)
84 Test video devices or display.\n\
87 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
95 Disable the mouse click. Useful to automaze the \n\
96 execution of this program without humain intervention.\n\
99 Turn off the display.\n\
102 Print the list of video-devices available and exit.\n\
105 Print the help.\n\n");
108 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
123 bool getOptions(
int argc,
const char **argv,
bool &list,
124 bool &click_allowed,
bool &display )
128 std::string sDisplayType;
132 case 'l': list =
true;
break;
133 case 'h': usage(argv[0], NULL);
return false;
break;
134 case 'c': click_allowed =
false;
break;
135 case 'd': display =
false;
break;
138 usage(argv[0], optarg);
return false;
break;
143 if ((c == 1) || (c == -1)) {
145 usage(argv[0], NULL);
146 std::cerr <<
"ERROR: " << std::endl;
147 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
231 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 (use \"-t GTK\" option to use it)\n";
264 #if defined VISP_HAVE_X11
265 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
268 #if defined VISP_HAVE_GDI
269 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
272 #if defined VISP_HAVE_D3D9
273 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
276 #if defined VISP_HAVE_OPENCV
277 std::cout <<
" CV (use \"-t CV\" option to use it)\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
void set_j(const double j)
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 set_i(const double i)
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.
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
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