43 #include <visp/vpConfig.h>
44 #include <visp/vpImage.h>
45 #include <visp/vpDisplay.h>
46 #include <visp/vpDisplayOpenCV.h>
47 #include <visp/vpDisplayGTK.h>
48 #include <visp/vpDisplayX.h>
49 #include <visp/vpDisplayGDI.h>
50 #include <visp/vpDisplayD3D.h>
51 #include <visp/vpParseArgv.h>
54 #if (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_OPENCV))
64 #define GETOPTARGS "hlt:dc"
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)
195 bool opt_list =
false;
196 vpDisplayType opt_dtype;
197 bool opt_click_allowed =
true;
198 bool opt_display =
true;
201 #if defined VISP_HAVE_GTK
203 #elif defined VISP_HAVE_X11
205 #elif defined VISP_HAVE_GDI
207 #elif defined VISP_HAVE_D3D9
209 #elif defined VISP_HAVE_OPENCV
214 if (getOptions(argc, argv, opt_dtype, opt_list,
215 opt_click_allowed, opt_display) ==
false) {
221 unsigned nbDevices = 0;
222 std::cout <<
"List of video-devices available: \n";
223 #if defined VISP_HAVE_GTK
224 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
227 #if defined VISP_HAVE_X11
228 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
231 #if defined VISP_HAVE_GDI
232 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
235 #if defined VISP_HAVE_D3D9
236 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
239 #if defined VISP_HAVE_OPENCV
240 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
244 std::cout <<
" No display is available\n";
260 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
261 #if defined VISP_HAVE_X11
265 std::cout <<
" Sorry, X11 video device is not available.\n";
266 std::cout <<
"Use \"" << argv[0]
267 <<
" -l\" to print the list of available devices.\n";
272 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
273 #if defined VISP_HAVE_GTK
277 std::cout <<
" Sorry, GTK video device is not available.\n";
278 std::cout <<
"Use \"" << argv[0]
279 <<
" -l\" to print the list of available devices.\n";
284 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
285 #if defined VISP_HAVE_GDI
289 std::cout <<
" Sorry, GDI video device is not available.\n";
290 std::cout <<
"Use \"" << argv[0]
291 <<
" -l\" to print the list of available devices.\n";
296 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
297 #if defined VISP_HAVE_D3D9
301 std::cout <<
" Sorry, D3D video device is not available.\n";
302 std::cout <<
"Use \"" << argv[0]
303 <<
" -l\" to print the list of available devices.\n";
308 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
309 #if defined VISP_HAVE_OPENCV
313 std::cout <<
" Sorry, OpenCV video device is not available.\n";
314 std::cout <<
"Use \"" << argv[0]
315 <<
" -l\" to print the list of available devices.\n";
322 int winx1 = 100, winy1 = 200;
323 d1->
init(I1, winx1, winy1,
"Display 1");
325 int winx2 = winx1+10+(int)I1.getWidth(), winy2 = winy1;
326 d2->init(I2, winx2, winy2,
"Display 2");
335 std::cout <<
"A click in display 1 to exit..." << std::endl;
336 if ( opt_click_allowed )