36#include <visp3/core/vpConfig.h>
37#include <visp3/core/vpDebug.h>
38#include <visp3/core/vpDisplay.h>
39#include <visp3/core/vpImage.h>
40#include <visp3/gui/vpDisplayD3D.h>
41#include <visp3/gui/vpDisplayGDI.h>
42#include <visp3/gui/vpDisplayGTK.h>
43#include <visp3/gui/vpDisplayOpenCV.h>
44#include <visp3/gui/vpDisplayX.h>
45#include <visp3/io/vpParseArgv.h>
46#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || \
47 defined(VISP_HAVE_OPENCV))
57#define GETOPTARGS "hlt:dc"
59#ifdef ENABLE_VISP_NAMESPACE
72void usage(
const char *name,
const char *badparam, vpDisplayType &dtype);
73bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &display);
84void usage(
const char *name,
const char *badparam, vpDisplayType &dtype)
87Test to open video devices or display.\n\
90 %s [-t <type of video device>] [-l] [-c] [-d] [-h]\n\
115 -t <type of video device> \"%s\"\n\
116 String specifying the video device to use.\n\
118 \"X11\": only on UNIX platforms,\n\
119 \"GTK\": on all plaforms,\n\
120 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
121 \"D3D\": only on Windows platform (Direct3D).\n\
122 \"CV\" : (OpenCV).\n\
125 Disable the mouse click. Useful to automate the \n\
126 execution of this program without human intervention.\n\
129 Turn off the display.\n\
132 Print the list of video-devices available and exit.\n\
135 Print the help.\n\n",
139 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
155bool getOptions(
int argc,
const char **argv, vpDisplayType &dtype,
bool &list,
bool &click_allowed,
bool &display)
159 std::string sDisplayType;
167 sDisplayType = optarg_;
169 if (sDisplayType.compare(
"X11") == 0) {
172 else if (sDisplayType.compare(
"GTK") == 0) {
175 else if (sDisplayType.compare(
"GDI") == 0) {
178 else if (sDisplayType.compare(
"D3D") == 0) {
181 else if (sDisplayType.compare(
"CV") == 0) {
187 usage(argv[0],
nullptr, dtype);
190 click_allowed =
false;
197 usage(argv[0], optarg_, dtype);
202 if ((c == 1) || (c == -1)) {
204 usage(argv[0],
nullptr, dtype);
205 std::cerr <<
"ERROR: " << std::endl;
206 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
213int main(
int argc,
const char **argv)
216 bool opt_list =
false;
217 vpDisplayType opt_dtype;
218 bool opt_click_allowed =
true;
219 bool opt_display =
true;
222#if defined(VISP_HAVE_GTK)
224#elif defined(VISP_HAVE_X11)
226#elif defined(VISP_HAVE_GDI)
228#elif defined(VISP_HAVE_D3D9)
230#elif defined VISP_HAVE_OPENCV
235 if (getOptions(argc, argv, opt_dtype, opt_list, opt_click_allowed, opt_display) ==
false) {
241 unsigned nbDevices = 0;
242 std::cout <<
"List of video-devices available: \n";
243#if defined(VISP_HAVE_GTK)
244 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
247#if defined(VISP_HAVE_X11)
248 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
251#if defined(VISP_HAVE_GDI)
253 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
256#if defined(VISP_HAVE_D3D9)
257 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
260#if defined VISP_HAVE_OPENCV
261 std::cout <<
" CV (use \"-t CV\" option to use it)\n";
265 std::cout <<
" No display is available\n";
281 std::cout <<
"Requested X11 display functionalities..." << std::endl;
282#if defined(VISP_HAVE_X11)
287 std::cout <<
" Sorry, X11 video device is not available.\n";
288 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
292 std::cout <<
"Requested GTK display functionalities..." << std::endl;
293#if defined(VISP_HAVE_GTK)
298 std::cout <<
" Sorry, GTK video device is not available.\n";
299 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
303 std::cout <<
"Requested GDI display functionalities..." << std::endl;
304#if defined(VISP_HAVE_GDI)
309 std::cout <<
" Sorry, GDI video device is not available.\n";
310 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
314 std::cout <<
"Requested D3D display functionalities..." << std::endl;
315#if defined(VISP_HAVE_D3D9)
320 std::cout <<
" Sorry, D3D video device is not available.\n";
321 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
325 std::cout <<
"Requested OpenCV display functionalities..." << std::endl;
326#if defined(HAVE_OPENCV_HIGHGUI)
331 std::cout <<
" Sorry, OpenCV video device is not available.\n";
332 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
338 int winx1 = 100, winy1 = 200;
339 d1->init(I1, winx1, winy1,
"Display 1");
341 int winx2 = winx1 + 10 +
static_cast<int>(I1.getWidth()), winy2 = winy1;
342 d2->init(I2, winx2, winy2,
"Display 2");
351 std::cout <<
"A click in display 1 to exit..." << std::endl;
352 if (opt_click_allowed)
360 std::cout <<
"Catch an exception: " <<
e << std::endl;
366int 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)
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)