39 #include <visp3/core/vpConfig.h> 40 #include <visp3/core/vpDebug.h> 45 #if (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_OPENCV)) 47 #include <visp3/core/vpImage.h> 48 #include <visp3/io/vpImageIo.h> 49 #include <visp3/io/vpParseArgv.h> 50 #include <visp3/core/vpIoTools.h> 52 #include <visp3/gui/vpDisplayOpenCV.h> 53 #include <visp3/gui/vpDisplayGTK.h> 54 #include <visp3/gui/vpDisplayX.h> 55 #include <visp3/gui/vpDisplayGDI.h> 56 #include <visp3/gui/vpDisplayD3D.h> 66 #define GETOPTARGS "i:hlt:dc" 76 void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype);
77 bool getOptions(
int argc,
const char **argv,
78 std::string &ipath, vpDisplayType &dtype,
bool &list,
79 bool &click_allowed,
bool &
display );
91 void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype)
94 Test video devices or display.\n\ 97 %s [-i <input image path>] \n\ 98 [-t <type of video device>] [-l] [-c] [-d] [-h]\n\ 103 case vpX11: display =
"X11";
break;
104 case vpGTK: display =
"GTK";
break;
105 case vpGDI: display =
"GDI";
break;
106 case vpD3D: display =
"D3D";
break;
107 case vpCV: display =
"CV";
break;
112 -i <input image path> %s\n\ 113 Set image input path.\n\ 114 From this path read \"ViSP-images/Klimt/Klimt.pgm\"\n\ 115 and \"ViSP-images/Klimt/Klimt.ppm\" images.\n\ 116 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 117 variable produces the same behaviour than using\n\ 120 -t <type of video device> \"%s\"\n\ 121 String specifying the video device to use.\n\ 123 \"X11\": only on UNIX platforms,\n\ 124 \"GTK\": on all plaforms,\n\ 125 \"GDI\": only on Windows platform (Graphics Device Interface),\n\ 126 \"D3D\": only on Windows platform (Direct3D).\n\ 127 \"CV\" : (OpenCV).\n\ 130 Disable the mouse click. Useful to automaze the \n\ 131 execution of this program without humain intervention.\n\ 134 Turn off the display.\n\ 137 Print the list of video-devices available and exit.\n\ 140 Print the help.\n\n",
141 ipath.c_str(), display.c_str());
144 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
161 bool getOptions(
int argc,
const char **argv,
162 std::string &ipath, vpDisplayType &dtype,
bool &list,
163 bool &click_allowed,
bool &display )
167 std::string sDisplayType;
171 case 'i': ipath = optarg_;
break;
172 case 'l': list =
true;
break;
173 case 't': sDisplayType = optarg_;
175 if (sDisplayType.compare(
"X11") == 0) {
178 else if (sDisplayType.compare(
"GTK") == 0) {
181 else if (sDisplayType.compare(
"GDI") == 0) {
184 else if (sDisplayType.compare(
"D3D") == 0) {
187 else if (sDisplayType.compare(
"CV") == 0) {
192 case 'h': usage(argv[0], NULL, ipath,dtype);
return false;
break;
193 case 'c': click_allowed =
false;
break;
194 case 'd': display =
false;
break;
197 usage(argv[0], optarg_, ipath,dtype);
return false;
break;
202 if ((c == 1) || (c == -1)) {
204 usage(argv[0], NULL, ipath, dtype);
205 std::cerr <<
"ERROR: " << std::endl;
206 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
214 main(
int argc,
const char ** argv)
217 std::string env_ipath;
218 std::string opt_ipath;
219 bool opt_list =
false;
220 vpDisplayType opt_dtype;
222 std::string filename;
223 bool opt_click_allowed =
true;
224 bool opt_display =
true;
227 #if defined VISP_HAVE_GTK 229 #elif defined VISP_HAVE_X11 231 #elif defined VISP_HAVE_GDI 233 #elif defined VISP_HAVE_D3D9 235 #elif defined VISP_HAVE_OPENCV 243 if (! env_ipath.empty())
247 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list,
248 opt_click_allowed, opt_display) ==
false) {
254 unsigned nbDevices = 0;
255 std::cout <<
"List of video-devices available: \n";
256 #if defined VISP_HAVE_GTK 257 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
260 #if defined VISP_HAVE_X11 261 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
264 #if defined VISP_HAVE_GDI 265 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
268 #if defined VISP_HAVE_D3D9 269 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
272 #if defined VISP_HAVE_OPENCV 273 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
277 std::cout <<
" No display is available\n";
283 if (!opt_ipath.empty())
288 if (!opt_ipath.empty() && !env_ipath.empty()) {
289 if (ipath != env_ipath) {
290 std::cout << std::endl
291 <<
"WARNING: " << std::endl;
292 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 293 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
294 <<
" we skip the environment variable." << std::endl;
299 if (opt_ipath.empty() && env_ipath.empty()){
300 usage(argv[0], NULL, ipath, opt_dtype);
301 std::cerr << std::endl
302 <<
"ERROR:" << std::endl;
303 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " 305 <<
" environment variable to specify the location of the " << std::endl
306 <<
" image path where test images are located." << std::endl << std::endl;
317 vpCTRACE <<
"Load " << filename << std::endl;
322 vpCTRACE <<
"Load " << filename << std::endl;
331 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
332 #if defined VISP_HAVE_X11 335 std::cout <<
" Sorry, X11 video device is not available.\n";
336 std::cout <<
"Use \"" << argv[0]
337 <<
" -l\" to print the list of available devices.\n";
342 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
343 #if defined VISP_HAVE_GTK 346 std::cout <<
" Sorry, GTK video device is not available.\n";
347 std::cout <<
"Use \"" << argv[0]
348 <<
" -l\" to print the list of available devices.\n";
353 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
354 #if defined VISP_HAVE_GDI 357 std::cout <<
" Sorry, GDI video device is not available.\n";
358 std::cout <<
"Use \"" << argv[0]
359 <<
" -l\" to print the list of available devices.\n";
364 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
365 #if defined VISP_HAVE_D3D9 368 std::cout <<
" Sorry, D3D video device is not available.\n";
369 std::cout <<
"Use \"" << argv[0]
370 <<
" -l\" to print the list of available devices.\n";
375 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
376 #if defined(VISP_HAVE_OPENCV) 379 std::cout <<
" Sorry, OpenCV video device is not available.\n";
380 std::cout <<
"Use \"" << argv[0]
381 <<
" -l\" to print the list of available devices.\n";
390 display->
init(I, 100, 100,
"Display...") ;
400 std::cout <<
"A click to continue...\n";
401 if ( opt_click_allowed )
410 display->
init(I, 100, 100);
420 std::cout <<
"A click to continue...\n";
421 if ( opt_click_allowed )
429 display->
init(Irgba, 100, 100,
"Color display...");
440 std::cout <<
"A click to continue...\n";
441 if ( opt_click_allowed )
444 display->
close(Irgba);
450 display->
init(Irgba, 100, 100);
461 std::cout <<
"A click to exit...\n";
462 if ( opt_click_allowed )
virtual void init(vpImage< unsigned char > &I, int x=-1, int y=-1, const char *title=NULL)=0
Class that defines generic functionnalities for display.
static void close(vpImage< unsigned char > &I)
vpDisplayGDI()
Basic constructor.
Define the X11 console to display images.
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Display for windows using Direct3D.
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
virtual bool getClick(bool blocking=true)=0
static void read(vpImage< unsigned char > &I, const char *filename)