39 #include <visp3/core/vpConfig.h> 40 #include <visp3/core/vpImage.h> 41 #include <visp3/core/vpDisplay.h> 42 #include <visp3/gui/vpDisplayOpenCV.h> 43 #include <visp3/gui/vpDisplayGTK.h> 44 #include <visp3/gui/vpDisplayX.h> 45 #include <visp3/gui/vpDisplayGDI.h> 46 #include <visp3/gui/vpDisplayD3D.h> 47 #include <visp3/io/vpParseArgv.h> 50 #if (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_OPENCV)) 61 #define GETOPTARGS "hlt:dc" 71 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype);
72 bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &
display);
83 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype)
86 Test to open video devices or display.\n\ 89 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\ 94 case vpX11: display =
"X11";
break;
95 case vpGTK: display =
"GTK";
break;
96 case vpGDI: display =
"GDI";
break;
97 case vpD3D: display =
"D3D";
break;
98 case vpCV: display =
"CV";
break;
103 -t <type of video device> \"%s\"\n\ 104 String specifying the video device to use.\n\ 106 \"X11\": only on UNIX platforms,\n\ 107 \"GTK\": on all plaforms,\n\ 108 \"GDI\": only on Windows platform (Graphics Device Interface),\n\ 109 \"D3D\": only on Windows platform (Direct3D).\n\ 110 \"CV\" : (OpenCV).\n\ 113 Disable the mouse click. Useful to automaze the \n\ 114 execution of this program without humain intervention.\n\ 117 Turn off the display.\n\ 120 Print the list of video-devices available and exit.\n\ 123 Print the help.\n\n",
127 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
143 bool getOptions(
int argc,
const char **argv,
144 vpDisplayType &dtype,
bool &list,
145 bool &click_allowed,
bool &display)
149 std::string sDisplayType;
153 case 'l': list =
true;
break;
154 case 't': sDisplayType = optarg_;
156 if (sDisplayType.compare(
"X11") == 0) {
159 else if (sDisplayType.compare(
"GTK") == 0) {
162 else if (sDisplayType.compare(
"GDI") == 0) {
165 else if (sDisplayType.compare(
"D3D") == 0) {
168 else if (sDisplayType.compare(
"CV") == 0) {
173 case 'h': usage(argv[0], NULL, dtype);
return false;
break;
174 case 'c': click_allowed =
false;
break;
175 case 'd': display =
false;
break;
178 usage(argv[0], optarg_, dtype);
return false;
break;
182 if ((c == 1) || (c == -1)) {
184 usage(argv[0], NULL, dtype);
185 std::cerr <<
"ERROR: " << std::endl;
186 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
193 int main(
int argc,
const char ** argv)
196 bool opt_list =
false;
197 vpDisplayType opt_dtype;
198 bool opt_click_allowed =
true;
199 bool opt_display =
true;
202 #if defined VISP_HAVE_GTK 204 #elif defined VISP_HAVE_X11 206 #elif defined VISP_HAVE_GDI 208 #elif defined VISP_HAVE_D3D9 210 #elif defined VISP_HAVE_OPENCV 215 if (getOptions(argc, argv, opt_dtype, opt_list,
216 opt_click_allowed, opt_display) ==
false) {
222 unsigned nbDevices = 0;
223 std::cout <<
"List of video-devices available: \n";
224 #if defined VISP_HAVE_GTK 225 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
228 #if defined VISP_HAVE_X11 229 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
232 #if defined VISP_HAVE_GDI 233 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
236 #if defined VISP_HAVE_D3D9 237 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
240 #if defined VISP_HAVE_OPENCV 241 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
245 std::cout <<
" No display is available\n";
261 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
262 #if defined VISP_HAVE_X11 266 std::cout <<
" Sorry, X11 video device is not available.\n";
267 std::cout <<
"Use \"" << argv[0]
268 <<
" -l\" to print the list of available devices.\n";
273 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
274 #if defined VISP_HAVE_GTK 278 std::cout <<
" Sorry, GTK video device is not available.\n";
279 std::cout <<
"Use \"" << argv[0]
280 <<
" -l\" to print the list of available devices.\n";
285 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
286 #if defined VISP_HAVE_GDI 290 std::cout <<
" Sorry, GDI video device is not available.\n";
291 std::cout <<
"Use \"" << argv[0]
292 <<
" -l\" to print the list of available devices.\n";
297 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
298 #if defined VISP_HAVE_D3D9 302 std::cout <<
" Sorry, D3D video device is not available.\n";
303 std::cout <<
"Use \"" << argv[0]
304 <<
" -l\" to print the list of available devices.\n";
309 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
310 #if defined(VISP_HAVE_OPENCV) 314 std::cout <<
" Sorry, OpenCV video device is not available.\n";
315 std::cout <<
"Use \"" << argv[0]
316 <<
" -l\" to print the list of available devices.\n";
323 int winx1 = 100, winy1 = 200;
324 d1->init(I1, winx1, winy1,
"Display 1");
326 int winx2 = winx1+10+(int)I1.
getWidth(), winy2 = winy1;
327 d2->init(I2, winx2, winy2,
"Display 2");
336 std::cout <<
"A click in display 1 to exit..." << std::endl;
337 if ( opt_click_allowed )
344 std::cout <<
"Catch an exception: " << e << std::endl;
Class that defines generic functionnalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
vpDisplayGDI()
Basic constructor.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
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 3rd party. Thus to enable this class Direct3D should be installed...
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
unsigned int getWidth() const