34#include <visp3/core/vpConfig.h>
35#include <visp3/core/vpDebug.h>
41#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \
42 defined(VISP_HAVE_OPENCV))
44#include <visp3/core/vpImage.h>
45#include <visp3/core/vpIoTools.h>
46#include <visp3/io/vpImageIo.h>
47#include <visp3/io/vpParseArgv.h>
49#include <visp3/gui/vpDisplayD3D.h>
50#include <visp3/gui/vpDisplayGDI.h>
51#include <visp3/gui/vpDisplayGTK.h>
52#include <visp3/gui/vpDisplayOpenCV.h>
53#include <visp3/gui/vpDisplayX.h>
63#define GETOPTARGS "i:hlt:dc"
65#ifdef ENABLE_VISP_NAMESPACE
69typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
71void usage(
const char *name,
const char *badparam,
const 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,
const std::string &ipath, vpDisplayType &dtype)
88Test click functionalities in 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 Print the list of video-devices available and exit.\n\
138 Disable the mouse click. Useful to automate the \n\
139 execution of this program without human intervention.\n\
142 Turn off the display.\n\
145 Print the help.\n\n",
146 ipath.c_str(), display.c_str());
149 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
170bool getOptions(
int argc,
const char **argv, std::string &ipath, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
175 std::string sDisplayType;
186 sDisplayType = optarg_;
188 if (sDisplayType.compare(
"X11") == 0) {
191 else if (sDisplayType.compare(
"GTK") == 0) {
194 else if (sDisplayType.compare(
"GDI") == 0) {
197 else if (sDisplayType.compare(
"D3D") == 0) {
200 else if (sDisplayType.compare(
"CV") == 0) {
206 usage(argv[0],
nullptr, ipath, dtype);
209 click_allowed =
false;
216 usage(argv[0], optarg_, ipath, dtype);
221 if ((c == 1) || (c == -1)) {
223 usage(argv[0],
nullptr, ipath, dtype);
224 std::cerr <<
"ERROR: " << std::endl;
225 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
232int main(
int argc,
const char **argv)
235 std::string env_ipath;
236 std::string opt_ipath;
237 bool opt_list =
false;
238 vpDisplayType opt_dtype;
241 bool opt_click_allowed =
true;
242 bool opt_display =
true;
245#if defined(VISP_HAVE_GTK)
247#elif defined(VISP_HAVE_X11)
249#elif defined(VISP_HAVE_GDI)
251#elif defined(VISP_HAVE_D3D9)
253#elif defined VISP_HAVE_OPENCV
262 if (!env_ipath.empty())
266 if (getOptions(argc, argv, opt_ipath, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
272 unsigned nbDevices = 0;
273 std::cout <<
"List of video-devices available: \n";
274#if defined(VISP_HAVE_GTK)
275 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
278#if defined(VISP_HAVE_X11)
279 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
282#if defined(VISP_HAVE_GDI)
284 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
287#if defined(VISP_HAVE_D3D9)
288 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
291#if defined VISP_HAVE_OPENCV
292 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
296 std::cout <<
" No display is available\n";
302 if (!opt_ipath.empty())
307 if (!opt_ipath.empty() && !env_ipath.empty()) {
308 if (ipath != env_ipath) {
309 std::cout << std::endl <<
"WARNING: " << std::endl;
310 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
311 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
312 <<
" we skip the environment variable." << std::endl;
317 if (opt_ipath.empty() && env_ipath.empty()) {
318 usage(argv[0],
nullptr, ipath, opt_dtype);
319 std::cerr << std::endl <<
"ERROR:" << std::endl;
320 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
321 <<
" environment variable to specify the location of the " << std::endl
322 <<
" image path where test images are located." << std::endl
340 std::cout <<
"Requested X11 display functionalities..." << std::endl;
341#if defined(VISP_HAVE_X11)
344 std::cout <<
" Sorry, X11 video device is not available.\n";
345 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
350 std::cout <<
"Requested GTK display functionalities..." << std::endl;
351#if defined(VISP_HAVE_GTK)
354 std::cout <<
" Sorry, GTK video device is not available.\n";
355 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
360 std::cout <<
"Requested GDI display functionalities..." << std::endl;
361#if defined(VISP_HAVE_GDI)
365 std::cout <<
" Sorry, GDI video device is not available.\n";
366 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
371 std::cout <<
"Requested D3D display functionalities..." << std::endl;
372#if defined(VISP_HAVE_D3D9)
375 std::cout <<
" Sorry, D3D video device is not available.\n";
376 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
381 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
382#if defined(HAVE_OPENCV_HIGHGUI)
385 std::cout <<
" Sorry, OpenCV video device is not available.\n";
386 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
396 display->init(I, 100, 100,
"Display...");
406 if (opt_click_allowed) {
407 std::cout <<
"Click on a pixel to get his coordinates...\n";
411 std::cout <<
" You click down on pixel (" << ip <<
") ";
414 std::cout <<
"with left button.\n";
417 std::cout <<
"with middle button.\n";
420 std::cout <<
"with right button.\n";
426 std::cout <<
" You click up on pixel (" << ip <<
") ";
429 std::cout <<
"with left button.\n";
432 std::cout <<
"with middle button.\n";
435 std::cout <<
"with right button.\n";
441 std::cout <<
" Pointer position: " << ip << std::endl;
442 std::cout <<
"A click to exit...\n";
455int 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)