36#include <visp3/core/vpConfig.h>
37#include <visp3/core/vpDebug.h>
43#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \
44 defined(VISP_HAVE_OPENCV))
46#include <visp3/core/vpImage.h>
47#include <visp3/core/vpIoTools.h>
48#include <visp3/io/vpImageIo.h>
49#include <visp3/io/vpParseArgv.h>
51#include <visp3/gui/vpDisplayD3D.h>
52#include <visp3/gui/vpDisplayGDI.h>
53#include <visp3/gui/vpDisplayGTK.h>
54#include <visp3/gui/vpDisplayOpenCV.h>
55#include <visp3/gui/vpDisplayX.h>
65#define GETOPTARGS "i:hlt:dc"
67typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
69void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype);
70bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
83void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype)
86Test click functionalities in video devices or display.\n\
89 %s [-i <input image path>] \n\
90 [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
115 -i <input image path> %s\n\
116 Set image input path.\n\
117 From this path read \"Klimt/Klimt.pgm\"\n\
118 and \"Klimt/Klimt.ppm\" images.\n\
119 Setting the VISP_INPUT_IMAGE_PATH environment\n\
120 variable produces the same behaviour than using\n\
123 -t <type of video device> \"%s\"\n\
124 String specifying the video device to use.\n\
126 \"X11\": only on UNIX platforms,\n\
127 \"GTK\": on all plaforms,\n\
128 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
129 \"D3D\": only on Windows platform (Direct3D).\n\
130 \"CV\" : (OpenCV).\n\
133 Print the list of video-devices available and exit.\n\
136 Disable the mouse click. Useful to automate the \n\
137 execution of this program without human intervention.\n\
140 Turn off the display.\n\
143 Print the help.\n\n",
144 ipath.c_str(), display.c_str());
147 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
168bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
173 std::string sDisplayType;
184 sDisplayType = optarg_;
186 if (sDisplayType.compare(
"X11") == 0) {
188 }
else if (sDisplayType.compare(
"GTK") == 0) {
190 }
else if (sDisplayType.compare(
"GDI") == 0) {
192 }
else if (sDisplayType.compare(
"D3D") == 0) {
194 }
else if (sDisplayType.compare(
"CV") == 0) {
200 usage(argv[0], NULL, ipath, dtype);
204 click_allowed =
false;
211 usage(argv[0], optarg_, ipath, dtype);
217 if ((c == 1) || (c == -1)) {
219 usage(argv[0], NULL, ipath, dtype);
220 std::cerr <<
"ERROR: " << std::endl;
221 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
228int main(
int argc,
const char **argv)
231 std::string env_ipath;
232 std::string opt_ipath;
233 bool opt_list =
false;
234 vpDisplayType opt_dtype;
236 std::string filename;
237 bool opt_click_allowed =
true;
238 bool opt_display =
true;
241#if defined(VISP_HAVE_GTK)
243#elif defined(VISP_HAVE_X11)
245#elif defined(VISP_HAVE_GDI)
247#elif defined(VISP_HAVE_D3D9)
249#elif defined VISP_HAVE_OPENCV
258 if (!env_ipath.empty())
262 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
268 unsigned nbDevices = 0;
269 std::cout <<
"List of video-devices available: \n";
270#if defined(VISP_HAVE_GTK)
271 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
274#if defined(VISP_HAVE_X11)
275 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
278#if defined(VISP_HAVE_GDI)
280 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
283#if defined(VISP_HAVE_D3D9)
284 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
287#if defined VISP_HAVE_OPENCV
288 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
292 std::cout <<
" No display is available\n";
298 if (!opt_ipath.empty())
303 if (!opt_ipath.empty() && !env_ipath.empty()) {
304 if (ipath != env_ipath) {
305 std::cout << std::endl <<
"WARNING: " << std::endl;
306 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
307 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
308 <<
" we skip the environment variable." << std::endl;
313 if (opt_ipath.empty() && env_ipath.empty()) {
314 usage(argv[0], NULL, ipath, opt_dtype);
315 std::cerr << std::endl <<
"ERROR:" << std::endl;
316 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
317 <<
" environment variable to specify the location of the " << std::endl
318 <<
" image path where test images are located." << std::endl
328 vpCTRACE <<
"Load " << filename << std::endl;
336 std::cout <<
"Requested X11 display functionalities..." << std::endl;
337#if defined(VISP_HAVE_X11)
340 std::cout <<
" Sorry, X11 video device is not available.\n";
341 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
346 std::cout <<
"Requested GTK display functionalities..." << std::endl;
347#if defined(VISP_HAVE_GTK)
350 std::cout <<
" Sorry, GTK video device is not available.\n";
351 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
356 std::cout <<
"Requested GDI display functionalities..." << std::endl;
357#if defined(VISP_HAVE_GDI)
361 std::cout <<
" Sorry, GDI video device is not available.\n";
362 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
367 std::cout <<
"Requested D3D display functionalities..." << std::endl;
368#if defined(VISP_HAVE_D3D9)
371 std::cout <<
" Sorry, D3D video device is not available.\n";
372 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
377 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
378#if defined(HAVE_OPENCV_HIGHGUI)
381 std::cout <<
" Sorry, OpenCV video device is not available.\n";
382 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
392 display->init(I, 100, 100,
"Display...");
402 if (opt_click_allowed) {
403 std::cout <<
"Click on a pixel to get his coordinates...\n";
407 std::cout <<
" You click down on pixel (" << ip <<
") ";
410 std::cout <<
"with left button.\n";
413 std::cout <<
"with middle button.\n";
416 std::cout <<
"with right button.\n";
422 std::cout <<
" You click up on pixel (" << ip <<
") ";
425 std::cout <<
"with left button.\n";
428 std::cout <<
"with middle button.\n";
431 std::cout <<
"with right button.\n";
437 std::cout <<
" Pointer poisition : " << ip << std::endl;
438 std::cout <<
"A click to exit...\n";
450int 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 bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void flush(const vpImage< unsigned char > &I)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)