40#include <visp3/core/vpConfig.h>
41#include <visp3/core/vpDebug.h>
46#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \
47 defined(VISP_HAVE_OPENCV))
49#include <visp3/core/vpImage.h>
50#include <visp3/core/vpIoTools.h>
51#include <visp3/io/vpImageIo.h>
52#include <visp3/io/vpParseArgv.h>
54#include <visp3/gui/vpDisplayD3D.h>
55#include <visp3/gui/vpDisplayGDI.h>
56#include <visp3/gui/vpDisplayGTK.h>
57#include <visp3/gui/vpDisplayOpenCV.h>
58#include <visp3/gui/vpDisplayX.h>
61#define GETOPTARGS "i:hlt:dc"
63#ifdef ENABLE_VISP_NAMESPACE
76void usage(
const char *name,
const char *badparam,
const std::string &ipath, vpDisplayType &dtype);
77bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
90void usage(
const char *name,
const char *badparam,
const std::string &ipath, vpDisplayType &dtype)
93Test video devices or display.\n\
96 %s [-i <input image path>] \n\
97 [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
122 -i <input image path> %s\n\
123 Set image input path.\n\
124 From this path read \"Klimt/Klimt.pgm\"\n\
125 and \"Klimt/Klimt.ppm\" images.\n\
126 Setting the VISP_INPUT_IMAGE_PATH environment\n\
127 variable produces the same behaviour than using\n\
130 -t <type of video device> \"%s\"\n\
131 String specifying the video device to use.\n\
133 \"X11\": only on UNIX platforms,\n\
134 \"GTK\": on all plaforms,\n\
135 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
136 \"D3D\": only on Windows platform (Direct3D).\n\
137 \"CV\" : (OpenCV).\n\
140 Disable the mouse click. Useful to automate the \n\
141 execution of this program without human intervention.\n\
144 Turn off the display.\n\
147 Print the list of video-devices available and exit.\n\
150 Print the help.\n\n",
151 ipath.c_str(), display.c_str());
154 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
171bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
176 std::string sDisplayType;
187 sDisplayType = optarg_;
189 if (sDisplayType.compare(
"X11") == 0) {
192 else if (sDisplayType.compare(
"GTK") == 0) {
195 else if (sDisplayType.compare(
"GDI") == 0) {
198 else if (sDisplayType.compare(
"D3D") == 0) {
201 else if (sDisplayType.compare(
"CV") == 0) {
207 usage(argv[0],
nullptr, ipath, dtype);
210 click_allowed =
false;
217 usage(argv[0], optarg_, ipath, dtype);
222 if ((c == 1) || (c == -1)) {
224 usage(argv[0],
nullptr, ipath, dtype);
225 std::cerr <<
"ERROR: " << std::endl;
226 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
233int main(
int argc,
const char **argv)
236 std::string env_ipath;
237 std::string opt_ipath;
238 bool opt_list =
false;
239 vpDisplayType opt_dtype;
242 bool opt_click_allowed =
true;
243 bool opt_display =
true;
246#if defined(VISP_HAVE_GTK)
248#elif defined(VISP_HAVE_X11)
250#elif defined(VISP_HAVE_GDI)
252#elif defined(VISP_HAVE_D3D9)
254#elif defined VISP_HAVE_OPENCV
263 if (!env_ipath.empty())
267 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
273 unsigned nbDevices = 0;
274 std::cout <<
"List of video-devices available: \n";
275#if defined(VISP_HAVE_GTK)
276 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
279#if defined(VISP_HAVE_X11)
280 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
283#if defined(VISP_HAVE_GDI)
285 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
288#if defined(VISP_HAVE_D3D9)
289 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
292#if defined VISP_HAVE_OPENCV
293 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
297 std::cout <<
" No display is available\n";
303 if (!opt_ipath.empty())
308 if (!opt_ipath.empty() && !env_ipath.empty()) {
309 if (ipath != env_ipath) {
310 std::cout << std::endl <<
"WARNING: " << std::endl;
311 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
312 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
313 <<
" we skip the environment variable." << std::endl;
318 if (opt_ipath.empty() && env_ipath.empty()) {
319 usage(argv[0],
nullptr, ipath, opt_dtype);
320 std::cerr << std::endl <<
"ERROR:" << std::endl;
321 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
322 <<
" environment variable to specify the location of the " << std::endl
323 <<
" image path where test images are located." << std::endl
348 std::cout <<
"Requested X11 display functionalities..." << std::endl;
349#if defined(VISP_HAVE_X11)
352 std::cout <<
" Sorry, X11 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 GTK display functionalities..." << std::endl;
359#if defined(VISP_HAVE_GTK)
362 std::cout <<
" Sorry, GTK 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 GDI display functionalities..." << std::endl;
369#if defined(VISP_HAVE_GDI)
373 std::cout <<
" Sorry, GDI video device is not available.\n";
374 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
379 std::cout <<
"Requested D3D display functionalities..." << std::endl;
380#if defined(VISP_HAVE_D3D9)
383 std::cout <<
" Sorry, D3D video device is not available.\n";
384 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
389 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
390#if defined(HAVE_OPENCV_HIGHGUI)
393 std::cout <<
" Sorry, OpenCV video device is not available.\n";
394 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
403 display->init(I, 100, 100,
"Display...");
413 std::cout <<
"A click to continue...\n";
414 if (opt_click_allowed)
423 display->init(I, 100, 100);
433 std::cout <<
"A click to continue...\n";
434 if (opt_click_allowed)
442 display->init(Irgba, 100, 100,
"Color display...");
453 std::cout <<
"A click to continue...\n";
454 if (opt_click_allowed)
457 display->close(Irgba);
463 display->init(Irgba, 100, 100);
474 std::cout <<
"A click to exit...\n";
475 if (opt_click_allowed)
487int 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)