38#include <visp3/core/vpConfig.h>
39#include <visp3/core/vpDisplay.h>
40#include <visp3/core/vpImage.h>
41#include <visp3/gui/vpDisplayD3D.h>
42#include <visp3/gui/vpDisplayGDI.h>
43#include <visp3/gui/vpDisplayGTK.h>
44#include <visp3/gui/vpDisplayOpenCV.h>
45#include <visp3/gui/vpDisplayX.h>
46#include <visp3/io/vpParseArgv.h>
47#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \
48 defined(VISP_HAVE_OPENCV))
58#define GETOPTARGS "hlt:dc"
60typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType;
62void usage(
const char *name,
const char *badparam, vpDisplayType &dtype);
63bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &display);
74void usage(
const char *name,
const char *badparam, vpDisplayType &dtype)
77Test to open video devices or display.\n\
80 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
105 -t <type of video device> \"%s\"\n\
106 String specifying the video device to use.\n\
108 \"X11\": only on UNIX platforms,\n\
109 \"GTK\": on all plaforms,\n\
110 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
111 \"D3D\": only on Windows platform (Direct3D).\n\
112 \"CV\" : (OpenCV).\n\
115 Disable the mouse click. Useful to automate the \n\
116 execution of this program without human intervention.\n\
119 Turn off the display.\n\
122 Print the list of video-devices available and exit.\n\
125 Print the help.\n\n",
129 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
145bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &display)
149 std::string sDisplayType;
157 sDisplayType = optarg_;
159 if (sDisplayType.compare(
"X11") == 0) {
161 }
else if (sDisplayType.compare(
"GTK") == 0) {
163 }
else if (sDisplayType.compare(
"GDI") == 0) {
165 }
else if (sDisplayType.compare(
"D3D") == 0) {
167 }
else if (sDisplayType.compare(
"CV") == 0) {
173 usage(argv[0], NULL, dtype);
177 click_allowed =
false;
184 usage(argv[0], optarg_, dtype);
190 if ((c == 1) || (c == -1)) {
192 usage(argv[0], NULL, dtype);
193 std::cerr <<
"ERROR: " << std::endl;
194 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
201int main(
int argc,
const char **argv)
204 bool opt_list =
false;
205 vpDisplayType opt_dtype;
206 bool opt_click_allowed =
true;
207 bool opt_display =
true;
210#if defined(VISP_HAVE_GTK)
212#elif defined(VISP_HAVE_X11)
214#elif defined(VISP_HAVE_GDI)
216#elif defined(VISP_HAVE_D3D9)
218#elif defined VISP_HAVE_OPENCV
223 if (getOptions(argc, argv, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
229 unsigned nbDevices = 0;
230 std::cout <<
"List of video-devices available: \n";
231#if defined(VISP_HAVE_GTK)
232 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
235#if defined(VISP_HAVE_X11)
236 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
239#if defined(VISP_HAVE_GDI)
241 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
244#if defined(VISP_HAVE_D3D9)
245 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
248#if defined VISP_HAVE_OPENCV
249 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
253 std::cout <<
" No display is available\n";
269 std::cout <<
"Requested X11 display functionalities..." << std::endl;
270#if defined(VISP_HAVE_X11)
274 std::cout <<
" Sorry, X11 video device is not available.\n";
275 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
280 std::cout <<
"Requested GTK display functionalities..." << std::endl;
281#if defined(VISP_HAVE_GTK)
285 std::cout <<
" Sorry, GTK video device is not available.\n";
286 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
291 std::cout <<
"Requested GDI display functionalities..." << std::endl;
292#if defined(VISP_HAVE_GDI)
297 std::cout <<
" Sorry, GDI video device is not available.\n";
298 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
303 std::cout <<
"Requested D3D display functionalities..." << std::endl;
304#if defined(VISP_HAVE_D3D9)
308 std::cout <<
" Sorry, D3D video device is not available.\n";
309 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
314 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
315#if defined(HAVE_OPENCV_HIGHGUI)
319 std::cout <<
" Sorry, OpenCV video device is not available.\n";
320 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
327 int winx1 = 100, winy1 = 200;
328 d1->init(I1, winx1, winy1,
"Display 1");
330 int winx2 = winx1 + 10 + (int)I1.
getWidth(), winy2 = winy1;
331 d2->init(I2, winx2, winy2,
"Display 2");
340 std::cout <<
"A click in display 1 to exit..." << std::endl;
341 if (opt_click_allowed)
348 std::cout <<
"Catch an exception: " << e << std::endl;
354int 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)
unsigned int getWidth() const
error that can be emitted by ViSP classes.
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)