44#include <visp3/core/vpConfig.h>
45#include <visp3/core/vpDebug.h>
46#include <visp3/core/vpIoTools.h>
47#include <visp3/io/vpParseArgv.h>
54#if (defined(VISP_HAVE_GTK) || defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9))
56#include <visp3/core/vpImage.h>
57#include <visp3/io/vpImageIo.h>
59#include <visp3/core/vpMouseButton.h>
60#include <visp3/gui/vpDisplayD3D.h>
61#include <visp3/gui/vpDisplayGDI.h>
62#include <visp3/gui/vpDisplayGTK.h>
63#include <visp3/gui/vpDisplayX.h>
65#include <visp3/core/vpTime.h>
68#define GETOPTARGS "cdi:Lp:ht:f:l:s:w"
70#ifdef ENABLE_VISP_NAMESPACE
83void usage(
const char *name,
const char *badparam,
const std::string &ipath,
const std::string &ppath,
unsigned first,
84 unsigned last,
unsigned step, vpDisplayType &dtype);
85bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &ppath,
unsigned &first,
unsigned &last,
86 unsigned &step, vpDisplayType &dtype,
bool &list,
bool &display,
bool &click,
bool &wait);
100void usage(
const char *name,
const char *badparam,
const std::string &ipath,
const std::string &ppath,
101 unsigned first,
unsigned last,
unsigned step, vpDisplayType &dtype)
103#if defined(VISP_HAVE_DATASET)
104#if VISP_HAVE_DATASET_VERSION >= 0x030600
105 std::string ext(
"png");
107 std::string ext(
"pgm");
111 std::string ext(
"png");
115Read an image sequence from the disk and display it.\n\
116The sequence is made of separate images. Each image corresponds\n\
120 %s [-i <test image path>] [-p <personal image path>]\n\
121 [-f <first image>] [-l <last image>] [-s <step>] \n\
122 [-t <type of video device>] [-L] [-w] [-c] [-d] [-h]\n\
144 -i <test image path> %s\n\
145 Set image input path.\n\
146 From this path read \"cube/image.%%04d.%s\"\n\
147 images. These images come from ViSP-images-x.y.z.tar.gz\n\
148 available on the ViSP website.\n\
149 Setting the VISP_INPUT_IMAGE_PATH environment\n\
150 variable produces the same behaviour than using\n\
153 -p <personal image path> %s\n\
154 Specify a personal sequence containing images \n\
156 By image sequence, we mean one file per image.\n\
157 The format is selected by analyzing the filename extension.\n\
158 Example : \"/Temp/visp-images/cube/image.%%04d.%s\"\n\
159 %%04d is for the image numbering.\n\
161 -f <first image> %u\n\
162 First image number of the sequence.\n\
164 -l <last image> %u\n\
165 Last image number of the sequence.\n\
168 Step between two images.\n\
170 -t <type of video device> \"%s\"\n\
171 String specifying the video device to use.\n\
173 \"X11\": only on UNIX platforms,\n\
174 \"GTK\": on all plaforms,\n\
175 \"GDI\": only on Windows platform (Graphics Device Interface),\n\
176 \"D3D\": only on Windows platform (Direct3D).\n\
179 Print the list of video-devices available and exit.\n\
182 Disable mouse click.\n\
185 Disable the image display. This can be useful \n\
186 for automatic tests using crontab under Unix or \n\
187 using the task manager under Windows.\n\
190 Wait for a mouse click between two images.\n\
191 If the image display is disabled (using -d)\n\
192 this option is without effect.\n\
195 Print the help.\n\n",
196 ipath.c_str(), ext.c_str(), ppath.c_str(), ext.c_str(), first, last, step, display.c_str());
199 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
224bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &ppath,
unsigned &first,
unsigned &last,
225 unsigned &step, vpDisplayType &dtype,
bool &list,
bool &display,
bool &click,
bool &wait)
229 std::string sDisplayType;
240 sDisplayType = optarg_;
242 if (sDisplayType.compare(
"X11") == 0) {
245 else if (sDisplayType.compare(
"GTK") == 0) {
248 else if (sDisplayType.compare(
"GDI") == 0) {
251 else if (sDisplayType.compare(
"D3D") == 0) {
266 first =
static_cast<unsigned int>(atoi(optarg_));
269 last =
static_cast<unsigned int>(atoi(optarg_));
272 step =
static_cast<unsigned int>(atoi(optarg_));
278 usage(argv[0],
nullptr, ipath, ppath, first, last, step, dtype);
282 usage(argv[0], optarg_, ipath, ppath, first, last, step, dtype);
287 if ((c == 1) || (c == -1)) {
289 usage(argv[0],
nullptr, ipath, ppath, first, last, step, dtype);
290 std::cerr <<
"ERROR: " << std::endl;
291 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
298int main(
int argc,
const char **argv)
300 std::string env_ipath;
301 std::string opt_ipath;
303 std::string opt_ppath;
306 unsigned opt_first = 30;
307 unsigned opt_last = 40;
308 unsigned opt_step = 1;
309 vpDisplayType opt_dtype;
310 bool opt_list =
false;
311 bool opt_display =
true;
312 bool opt_click =
true;
313 bool opt_click_blocking =
false;
315#if defined(VISP_HAVE_DATASET)
316#if VISP_HAVE_DATASET_VERSION >= 0x030600
317 std::string ext(
"png");
319 std::string ext(
"pgm");
323 std::string ext(
"png");
327#if defined(VISP_HAVE_GTK)
329#elif defined(VISP_HAVE_X11)
331#elif defined(VISP_HAVE_GDI)
333#elif defined(VISP_HAVE_D3D9)
342 if (!env_ipath.empty())
346 if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_first, opt_last, opt_step, opt_dtype, opt_list, opt_display,
347 opt_click, opt_click_blocking) ==
false) {
352 unsigned nbDevices = 0;
353 std::cout <<
"List of video-devices available: \n";
354#if defined(VISP_HAVE_GTK)
355 std::cout <<
" GTK (use \"-t GTK\" option to use it)\n";
358#if defined(VISP_HAVE_X11)
359 std::cout <<
" X11 (use \"-t X11\" option to use it)\n";
362#if defined(VISP_HAVE_GDI)
364 std::cout <<
" GDI (use \"-t GDI\" option to use it)\n";
367#if defined(VISP_HAVE_D3D9)
368 std::cout <<
" D3D (use \"-t D3D\" option to use it)\n";
372 std::cout <<
" No display is available\n";
378 opt_click_blocking =
false;
381 if (!opt_ipath.empty())
386 if (!opt_ipath.empty() && !env_ipath.empty() && opt_ppath.empty()) {
387 if (ipath != env_ipath) {
388 std::cout << std::endl <<
"WARNING: " << std::endl;
389 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
390 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
391 <<
" we skip the environment variable." << std::endl;
396 if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty()) {
397 usage(argv[0],
nullptr, ipath, opt_ppath, opt_first, opt_last, opt_step, opt_dtype);
398 std::cerr << std::endl <<
"ERROR:" << std::endl;
399 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
400 <<
" environment variable to specify the location of the " << std::endl
401 <<
" image path where test images are located." << std::endl
402 <<
" Use -p <personal image path> option if you want to " << std::endl
403 <<
" use personal images." << std::endl
414 unsigned iter = opt_first;
416 if (opt_ppath.empty()) {
432 std::cerr << std::endl <<
"ERROR:" << std::endl;
433 std::cerr <<
" Cannot read " <<
filename << std::endl;
434 std::cerr <<
" Check your -i " << ipath <<
" option, " << std::endl
435 <<
" or your -p " << opt_ppath <<
" option " << std::endl
436 <<
" or VISP_INPUT_IMAGE_PATH environment variable" << std::endl;
444 std::cout <<
"Requested X11 display functionalities..." << std::endl;
445#if defined(VISP_HAVE_X11)
448 std::cout <<
" Sorry, X11 video device is not available.\n";
449 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
454 std::cout <<
"Requested GTK display functionalities..." << std::endl;
455#if defined(VISP_HAVE_GTK)
458 std::cout <<
" Sorry, GTK video device is not available.\n";
459 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
464 std::cout <<
"Requested GDI display functionalities..." << std::endl;
465#if defined(VISP_HAVE_GDI)
469 std::cout <<
" Sorry, GDI video device is not available.\n";
470 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
475 std::cout <<
"Requested D3D display functionalities..." << std::endl;
476#if defined(VISP_HAVE_D3D9)
479 std::cout <<
" Sorry, D3D video device is not available.\n";
480 std::cout <<
"Use \"" << argv[0] <<
" -l\" to print the list of available devices.\n";
490 display->init(I, 100, 100,
"Display...");
508 while (iter < opt_last) {
513 if (opt_ppath.empty()) {
521 std::cout <<
"read : " <<
filename << std::endl;
530 if (opt_click_blocking) {
531 std::cout <<
"A click in the image to continue..." << std::endl;
541 std::cout <<
"Left button was pressed." << std::endl;
544 std::cout <<
"Middle button was pressed." << std::endl;
547 std::cout <<
"Right button was pressed. Bye. " << std::endl;
572int main() {
vpERROR_TRACE(
"You do not have X11 or GTK 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...
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)
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)
VISP_EXPORT double measureTimeMs()
VISP_EXPORT int wait(double t0, double t)