41 #include <visp3/core/vpConfig.h> 42 #include <visp3/core/vpDisplay.h> 43 #include <visp3/core/vpImage.h> 44 #include <visp3/gui/vpDisplayD3D.h> 45 #include <visp3/gui/vpDisplayGDI.h> 46 #include <visp3/gui/vpDisplayGTK.h> 47 #include <visp3/gui/vpDisplayOpenCV.h> 48 #include <visp3/gui/vpDisplayX.h> 49 #include <visp3/io/vpParseArgv.h> 50 #if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \ 51 defined(VISP_HAVE_OPENCV)) 61 #define GETOPTARGS "hlt:dc" 63 typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
65 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype);
66 bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &
display);
77 void usage(
const char *name,
const char *badparam, vpDisplayType &dtype)
80 Test to open video devices or display.\n\ 83 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\ 107 -t <type of video device> \"%s\"\n\ 108 String specifying the video device to use.\n\ 110 \"X11\": only on UNIX platforms,\n\ 111 \"GTK\": on all plaforms,\n\ 112 \"GDI\": only on Windows platform (Graphics Device Interface),\n\ 113 \"D3D\": only on Windows platform (Direct3D).\n\ 114 \"CV\" : (OpenCV).\n\ 117 Disable the mouse click. Useful to automaze the \n\ 118 execution of this program without humain intervention.\n\ 121 Turn off the display.\n\ 124 Print the list of video-devices available and exit.\n\ 127 Print the help.\n\n", display.c_str());
130 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
146 bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &display)
150 std::string sDisplayType;
158 sDisplayType = optarg_;
160 if (sDisplayType.compare(
"X11") == 0) {
162 }
else if (sDisplayType.compare(
"GTK") == 0) {
164 }
else if (sDisplayType.compare(
"GDI") == 0) {
166 }
else if (sDisplayType.compare(
"D3D") == 0) {
168 }
else if (sDisplayType.compare(
"CV") == 0) {
174 usage(argv[0], NULL, dtype);
178 click_allowed =
false;
185 usage(argv[0], optarg_, dtype);
191 if ((c == 1) || (c == -1)) {
193 usage(argv[0], NULL, dtype);
194 std::cerr <<
"ERROR: " << std::endl;
195 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
202 int main(
int argc,
const char **argv)
205 bool opt_list =
false;
206 vpDisplayType opt_dtype;
207 bool opt_click_allowed =
true;
208 bool opt_display =
true;
211 #if defined VISP_HAVE_GTK 213 #elif defined VISP_HAVE_X11 215 #elif defined VISP_HAVE_GDI 217 #elif defined VISP_HAVE_D3D9 219 #elif defined VISP_HAVE_OPENCV 224 if (getOptions(argc, argv, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
230 unsigned nbDevices = 0;
231 std::cout <<
"List of video-devices available: \n";
232 #if defined VISP_HAVE_GTK 233 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
236 #if defined VISP_HAVE_X11 237 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
240 #if defined VISP_HAVE_GDI 241 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
244 #if defined VISP_HAVE_D3D9 245 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
248 #if defined VISP_HAVE_OPENCV 249 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
253 std::cout <<
" No display is available\n";
269 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
270 #if defined VISP_HAVE_X11 274 std::cout <<
" Sorry, X11 video device is not available.\n";
275 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
280 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
281 #if defined VISP_HAVE_GTK 285 std::cout <<
" Sorry, GTK video device is not available.\n";
286 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
291 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
292 #if defined VISP_HAVE_GDI 296 std::cout <<
" Sorry, GDI video device is not available.\n";
297 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
302 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
303 #if defined VISP_HAVE_D3D9 307 std::cout <<
" Sorry, D3D video device is not available.\n";
308 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
313 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
314 #if defined(VISP_HAVE_OPENCV) 318 std::cout <<
" Sorry, OpenCV video device is not available.\n";
319 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
326 int winx1 = 100, winy1 = 200;
327 d1->init(I1, winx1, winy1,
"Display 1");
329 int winx2 = winx1 + 10 + (int)I1.
getWidth(), winy2 = winy1;
330 d2->init(I2, winx2, winy2,
"Display 2");
339 std::cout <<
"A click in display 1 to exit..." << std::endl;
340 if (opt_click_allowed)
346 std::cout <<
"Catch an exception: " << e << std::endl;
352 int main() {
vpERROR_TRACE(
"You do not have display functionalities..."); }
Class that defines generic functionnalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getWidth() const
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...