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) || \ 46 defined(VISP_HAVE_OPENCV)) 48 #include <visp3/core/vpImage.h> 49 #include <visp3/core/vpIoTools.h> 50 #include <visp3/io/vpImageIo.h> 51 #include <visp3/io/vpParseArgv.h> 53 #include <visp3/gui/vpDisplayD3D.h> 54 #include <visp3/gui/vpDisplayGDI.h> 55 #include <visp3/gui/vpDisplayGTK.h> 56 #include <visp3/gui/vpDisplayOpenCV.h> 57 #include <visp3/gui/vpDisplayX.h> 67 #define GETOPTARGS "i:hlt:dc" 69 typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
71 void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype);
72 bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
85 void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype)
88 Test video devices or display.\n\ 91 %s [-i <input image path>] \n\ 92 [-t <type of video device>] [-l] [-c] [-d] [-h]\n\ 116 -i <input image path> %s\n\ 117 Set image input path.\n\ 118 From this path read \"Klimt/Klimt.pgm\"\n\ 119 and \"Klimt/Klimt.ppm\" images.\n\ 120 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 121 variable produces the same behaviour than using\n\ 124 -t <type of video device> \"%s\"\n\ 125 String specifying the video device to use.\n\ 127 \"X11\": only on UNIX platforms,\n\ 128 \"GTK\": on all plaforms,\n\ 129 \"GDI\": only on Windows platform (Graphics Device Interface),\n\ 130 \"D3D\": only on Windows platform (Direct3D).\n\ 131 \"CV\" : (OpenCV).\n\ 134 Disable the mouse click. Useful to automaze the \n\ 135 execution of this program without humain intervention.\n\ 138 Turn off the display.\n\ 141 Print the list of video-devices available and exit.\n\ 144 Print the help.\n\n", ipath.c_str(), display.c_str());
147 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
164 bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
169 std::string sDisplayType;
180 sDisplayType = optarg_;
182 if (sDisplayType.compare(
"X11") == 0) {
184 }
else if (sDisplayType.compare(
"GTK") == 0) {
186 }
else if (sDisplayType.compare(
"GDI") == 0) {
188 }
else if (sDisplayType.compare(
"D3D") == 0) {
190 }
else if (sDisplayType.compare(
"CV") == 0) {
196 usage(argv[0], NULL, ipath, dtype);
200 click_allowed =
false;
207 usage(argv[0], optarg_, ipath, dtype);
213 if ((c == 1) || (c == -1)) {
215 usage(argv[0], NULL, ipath, dtype);
216 std::cerr <<
"ERROR: " << std::endl;
217 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
224 int main(
int argc,
const char **argv)
227 std::string env_ipath;
228 std::string opt_ipath;
229 bool opt_list =
false;
230 vpDisplayType opt_dtype;
232 std::string filename;
233 bool opt_click_allowed =
true;
234 bool opt_display =
true;
237 #if defined VISP_HAVE_GTK 239 #elif defined VISP_HAVE_X11 241 #elif defined VISP_HAVE_GDI 243 #elif defined VISP_HAVE_D3D9 245 #elif defined VISP_HAVE_OPENCV 254 if (!env_ipath.empty())
258 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
264 unsigned nbDevices = 0;
265 std::cout <<
"List of video-devices available: \n";
266 #if defined VISP_HAVE_GTK 267 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
270 #if defined VISP_HAVE_X11 271 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
274 #if defined VISP_HAVE_GDI 275 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
278 #if defined VISP_HAVE_D3D9 279 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
282 #if defined VISP_HAVE_OPENCV 283 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
287 std::cout <<
" No display is available\n";
293 if (!opt_ipath.empty())
298 if (!opt_ipath.empty() && !env_ipath.empty()) {
299 if (ipath != env_ipath) {
300 std::cout << std::endl <<
"WARNING: " << std::endl;
301 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 302 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
303 <<
" we skip the environment variable." << std::endl;
308 if (opt_ipath.empty() && env_ipath.empty()) {
309 usage(argv[0], NULL, ipath, opt_dtype);
310 std::cerr << std::endl <<
"ERROR:" << std::endl;
311 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
312 <<
" environment variable to specify the location of the " << std::endl
313 <<
" image path where test images are located." << std::endl
325 vpCTRACE <<
"Load " << filename << std::endl;
330 vpCTRACE <<
"Load " << filename << std::endl;
338 std::cout <<
"Requested X11 display functionnalities..." << std::endl;
339 #if defined VISP_HAVE_X11 342 std::cout <<
" Sorry, X11 video device is not available.\n";
343 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
348 std::cout <<
"Requested GTK display functionnalities..." << std::endl;
349 #if defined VISP_HAVE_GTK 352 std::cout <<
" Sorry, GTK video device is not available.\n";
353 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
358 std::cout <<
"Requested GDI display functionnalities..." << std::endl;
359 #if defined VISP_HAVE_GDI 362 std::cout <<
" Sorry, GDI video device is not available.\n";
363 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
368 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
369 #if defined VISP_HAVE_D3D9 372 std::cout <<
" Sorry, D3D video device is not available.\n";
373 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
378 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
379 #if defined(VISP_HAVE_OPENCV) 382 std::cout <<
" Sorry, OpenCV video device is not available.\n";
383 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
392 display->init(I, 100, 100,
"Display...");
402 std::cout <<
"A click to continue...\n";
403 if (opt_click_allowed)
412 display->init(I, 100, 100);
422 std::cout <<
"A click to continue...\n";
423 if (opt_click_allowed)
431 display->init(Irgba, 100, 100,
"Color display...");
442 std::cout <<
"A click to continue...\n";
443 if (opt_click_allowed)
446 display->
close(Irgba);
452 display->init(Irgba, 100, 100);
463 std::cout <<
"A click to exit...\n";
464 if (opt_click_allowed)
475 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)
static void close(vpImage< unsigned char > &I)
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
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...
static void read(vpImage< unsigned char > &I, const std::string &filename)