39#include <visp3/core/vpConfig.h>
40#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>
68#define GETOPTARGS "i:hlt:dc"
70typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
72void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype);
73bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
86void usage(
const char *name,
const char *badparam, std::string ipath, vpDisplayType &dtype)
89Test click functionnalities in video devices or display.\n\
92 %s [-i <input image path>] \n\
93 [-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 Print the list of video-devices available and exit.\n\
138 Disable the mouse click. Useful to automaze the \n\
139 execution of this program without humain intervention.\n\
142 Turn off the display.\n\
145 Print the help.\n\n", ipath.c_str(), display.c_str());
148 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
169bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
174 std::string sDisplayType;
185 sDisplayType = optarg_;
187 if (sDisplayType.compare(
"X11") == 0) {
189 }
else if (sDisplayType.compare(
"GTK") == 0) {
191 }
else if (sDisplayType.compare(
"GDI") == 0) {
193 }
else if (sDisplayType.compare(
"D3D") == 0) {
195 }
else if (sDisplayType.compare(
"CV") == 0) {
201 usage(argv[0], NULL, ipath, dtype);
205 click_allowed =
false;
212 usage(argv[0], optarg_, ipath, dtype);
218 if ((c == 1) || (c == -1)) {
220 usage(argv[0], NULL, ipath, dtype);
221 std::cerr <<
"ERROR: " << std::endl;
222 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
229int main(
int argc,
const char **argv)
232 std::string env_ipath;
233 std::string opt_ipath;
234 bool opt_list =
false;
235 vpDisplayType opt_dtype;
237 std::string filename;
238 bool opt_click_allowed =
true;
239 bool opt_display =
true;
242#if defined VISP_HAVE_GTK
244#elif defined VISP_HAVE_X11
246#elif defined VISP_HAVE_GDI
248#elif defined VISP_HAVE_D3D9
250#elif defined VISP_HAVE_OPENCV
259 if (!env_ipath.empty())
263 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
269 unsigned nbDevices = 0;
270 std::cout <<
"List of video-devices available: \n";
271#if defined VISP_HAVE_GTK
272 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
275#if defined VISP_HAVE_X11
276 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
279#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 functionnalities..." << 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 functionnalities..." << 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 functionnalities..." << std::endl;
357#if defined VISP_HAVE_GDI
360 std::cout <<
" Sorry, GDI video device is not available.\n";
361 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
366 std::cout <<
"Requested D3D display functionnalities..." << std::endl;
367#if defined VISP_HAVE_D3D9
370 std::cout <<
" Sorry, D3D video device is not available.\n";
371 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
376 std::cout <<
"Requested OpenCV display functionnalities..." << std::endl;
377#if defined(VISP_HAVE_OPENCV)
380 std::cout <<
" Sorry, OpenCV video device is not available.\n";
381 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
391 display->init(I, 100, 100,
"Display...");
401 if (opt_click_allowed) {
402 std::cout <<
"Click on a pixel to get his coordinates...\n";
406 std::cout <<
" You click down on pixel (" << ip <<
") ";
409 std::cout <<
"with left button.\n";
412 std::cout <<
"with middle button.\n";
415 std::cout <<
"with right button.\n";
421 std::cout <<
" You click up on pixel (" << ip <<
") ";
424 std::cout <<
"with left button.\n";
427 std::cout <<
"with middle button.\n";
430 std::cout <<
"with right button.\n";
436 std::cout <<
" Pointer poisition : " << ip << std::endl;
437 std::cout <<
"A click to exit...\n";
449int 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 functionnalities 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 ...
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)