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"
69typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
71void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype);
72bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
85void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype)
88Test video devices or display.\n\
91 %s [-i <input image path>] \n\
92 [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
117 -i <input image path> %s\n\
118 Set image input path.\n\
119 From this path read \"Klimt/Klimt.pgm\"\n\
120 and \"Klimt/Klimt.ppm\" images.\n\
121 Setting the VISP_INPUT_IMAGE_PATH environment\n\
122 variable produces the same behaviour than using\n\
125 -t <type of video device> \"%s\"\n\
126 String specifying the video device to use.\n\
128 \"X11\": only on UNIX platforms,\n\
129 \"GTK\": on all plaforms,\n\
130 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
131 \"D3D\": only on Windows platform (Direct3D).\n\
132 \"CV\" : (OpenCV).\n\
135 Disable the mouse click. Useful to automate the \n\
136 execution of this program without human intervention.\n\
139 Turn off the display.\n\
142 Print the list of video-devices available and exit.\n\
145 Print the help.\n\n",
146 ipath.c_str(), display.c_str());
149 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
166bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
171 std::string sDisplayType;
182 sDisplayType = optarg_;
184 if (sDisplayType.compare(
"X11") == 0) {
186 }
else if (sDisplayType.compare(
"GTK") == 0) {
188 }
else if (sDisplayType.compare(
"GDI") == 0) {
190 }
else if (sDisplayType.compare(
"D3D") == 0) {
192 }
else if (sDisplayType.compare(
"CV") == 0) {
198 usage(argv[0], NULL, ipath, dtype);
202 click_allowed =
false;
209 usage(argv[0], optarg_, ipath, dtype);
215 if ((c == 1) || (c == -1)) {
217 usage(argv[0], NULL, ipath, dtype);
218 std::cerr <<
"ERROR: " << std::endl;
219 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
226int main(
int argc,
const char **argv)
229 std::string env_ipath;
230 std::string opt_ipath;
231 bool opt_list =
false;
232 vpDisplayType opt_dtype;
234 std::string filename;
235 bool opt_click_allowed =
true;
236 bool opt_display =
true;
239#if defined(VISP_HAVE_GTK)
241#elif defined(VISP_HAVE_X11)
243#elif defined(VISP_HAVE_GDI)
245#elif defined(VISP_HAVE_D3D9)
247#elif defined VISP_HAVE_OPENCV
256 if (!env_ipath.empty())
260 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
266 unsigned nbDevices = 0;
267 std::cout <<
"List of video-devices available: \n";
268#if defined(VISP_HAVE_GTK)
269 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
272#if defined(VISP_HAVE_X11)
273 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
276#if defined(VISP_HAVE_GDI)
278 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
281#if defined(VISP_HAVE_D3D9)
282 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
285#if defined VISP_HAVE_OPENCV
286 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
290 std::cout <<
" No display is available\n";
296 if (!opt_ipath.empty())
301 if (!opt_ipath.empty() && !env_ipath.empty()) {
302 if (ipath != env_ipath) {
303 std::cout << std::endl <<
"WARNING: " << std::endl;
304 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
305 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
306 <<
" we skip the environment variable." << std::endl;
311 if (opt_ipath.empty() && env_ipath.empty()) {
312 usage(argv[0], NULL, ipath, opt_dtype);
313 std::cerr << std::endl <<
"ERROR:" << std::endl;
314 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
315 <<
" environment variable to specify the location of the " << std::endl
316 <<
" image path where test images are located." << std::endl
328 vpCTRACE <<
"Load " << filename << std::endl;
333 vpCTRACE <<
"Load " << filename << std::endl;
341 std::cout <<
"Requested X11 display functionalities..." << std::endl;
342#if defined(VISP_HAVE_X11)
345 std::cout <<
" Sorry, X11 video device is not available.\n";
346 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
351 std::cout <<
"Requested GTK display functionalities..." << std::endl;
352#if defined(VISP_HAVE_GTK)
355 std::cout <<
" Sorry, GTK video device is not available.\n";
356 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
361 std::cout <<
"Requested GDI display functionalities..." << std::endl;
362#if defined(VISP_HAVE_GDI)
366 std::cout <<
" Sorry, GDI video device is not available.\n";
367 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
372 std::cout <<
"Requested D3D display functionalities..." << std::endl;
373#if defined(VISP_HAVE_D3D9)
376 std::cout <<
" Sorry, D3D video device is not available.\n";
377 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
382 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
383#if defined(HAVE_OPENCV_HIGHGUI)
386 std::cout <<
" Sorry, OpenCV video device is not available.\n";
387 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
396 display->init(I, 100, 100,
"Display...");
406 std::cout <<
"A click to continue...\n";
407 if (opt_click_allowed)
416 display->init(I, 100, 100);
426 std::cout <<
"A click to continue...\n";
427 if (opt_click_allowed)
435 display->init(Irgba, 100, 100,
"Color display...");
446 std::cout <<
"A click to continue...\n";
447 if (opt_click_allowed)
450 display->close(Irgba);
456 display->init(Irgba, 100, 100);
467 std::cout <<
"A click to exit...\n";
468 if (opt_click_allowed)
479int main() {
vpERROR_TRACE(
"You do not have display functionalities..."); }
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)