40 #include <visp3/core/vpDebug.h> 41 #include <visp3/core/vpConfig.h> 43 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) 45 #include <visp3/io/vpDiskGrabber.h> 46 #include <visp3/core/vpDisplay.h> 47 #include <visp3/gui/vpDisplayX.h> 48 #include <visp3/gui/vpDisplayGDI.h> 49 #include <visp3/core/vpImage.h> 50 #include <visp3/core/vpIoTools.h> 51 #include <visp3/io/vpParseArgv.h> 52 #include <visp3/core/vpTime.h> 64 #define GETOPTARGS "b:de:f:i:hn:s:z:" 66 void usage(
const char *name,
const char *badparam, std::string ipath, std::string basename,
67 std::string ext,
int first,
unsigned int nimages,
int step,
unsigned int nzero);
68 bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &basename,
69 std::string &ext,
int &first,
unsigned int &nimages,
70 int &step,
unsigned int &nzero,
bool &display);
87 void usage(
const char *name,
const char *badparam, std::string ipath, std::string basename,
88 std::string ext,
int first,
unsigned int nimages,
int step,
unsigned int nzero)
91 Read an image sequence from the disk. Display it using X11 or GTK.\n\ 92 The sequence is made of separate images. Each image corresponds\n\ 96 %s [-i <input image path>] [-b <base name>] [-e <extension>] \n\ 97 [-f <first frame>] [-n <number of images> [-s <step>] \n\ 98 [-z <number of zero>] [-d] [-h]\n", name);
102 -i <input image path> %s\n\ 103 Set image input path.\n\ 104 From this path read \"ViSP-images/cube/image.%%04d.pgm\"\n\ 106 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 107 variable produces the same behaviour than using\n\ 111 Specify the base name of the files of the sequence\n\ 112 containing the images to process. \n\ 113 By image sequence, we mean one file per image.\n\ 114 The following image file formats PNM (PGM P5, PPM P6)\n\ 115 are supported. The format is selected by analysing \n\ 116 the filename extension.\n\ 119 Specify the extension of the files.\n\ 120 Not taken into account for the moment. Will be a\n\ 123 -f <first frame> %d\n\ 124 First frame number of the sequence\n\ 126 -n <number of images> %u\n\ 127 Number of images to load from the sequence.\n\ 130 Step between two images.\n\ 132 -z <number of zero> %u\n\ 133 Number of digits to encode the image number.\n\ 136 Turn off the display.\n\ 139 Print the help.\n\n",
140 ipath.c_str(), basename.c_str(), ext.c_str(), first,
141 nimages, step, nzero);
144 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
164 bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &basename,
165 std::string &ext,
int &first,
unsigned int &nimages,
166 int &step,
unsigned int &nzero,
bool &display)
173 case 'b': basename = optarg_;
break;
174 case 'd': display =
false;
break;
175 case 'e': ext = optarg_;
break;
176 case 'f': first = atoi(optarg_);
break;
177 case 'i': ipath = optarg_;
break;
178 case 'n': nimages = (unsigned) atoi(optarg_);
break;
179 case 's': step = atoi(optarg_);
break;
180 case 'z': nzero = (unsigned) atoi(optarg_);
break;
181 case 'h': usage(argv[0], NULL, ipath, basename, ext, first, nimages,
182 step, nzero);
return false;
break;
185 usage(argv[0], optarg_, ipath, basename, ext, first, nimages, step, nzero);
190 if ((c == 1) || (c == -1)) {
192 usage(argv[0], NULL, ipath, basename, ext, first, nimages, step, nzero);
193 std::cerr <<
"ERROR: " << std::endl;
194 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
211 int main(
int argc,
const char ** argv)
214 std::string env_ipath;
215 std::string opt_ipath;
217 std::string opt_basename =
"ViSP-images/cube/image.";
218 std::string opt_ext =
"pgm";
219 bool opt_display =
true;
222 unsigned int opt_nimages = 70;
224 unsigned int opt_nzero = 4;
230 if (! env_ipath.empty())
234 if (getOptions(argc, argv, opt_ipath, opt_basename, opt_ext, opt_first,
235 opt_nimages, opt_step, opt_nzero, opt_display) ==
false) {
240 if (!opt_ipath.empty())
245 if (!opt_ipath.empty() && !env_ipath.empty()) {
246 if (ipath != env_ipath) {
247 std::cout << std::endl
248 <<
"WARNING: " << std::endl;
249 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 250 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
251 <<
" we skip the environment variable." << std::endl;
256 if (opt_ipath.empty() && env_ipath.empty()){
257 usage(argv[0], NULL, ipath, opt_basename, opt_ext, opt_first,
258 opt_nimages, opt_step, opt_nzero);
259 std::cerr << std::endl
260 <<
"ERROR:" << std::endl;
261 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " 263 <<
" environment variable to specify the location of the " << std::endl
264 <<
" image path where test images are located." << std::endl << std::endl;
296 std::cout <<
"Image size: width : " << I.
getWidth() <<
" height: " 301 #if defined(VISP_HAVE_X11) 303 #elif defined(VISP_HAVE_GDI) 306 std::cout <<
"No image viewer is available..." << std::endl;
310 display.init(I,100,100,
"Disk Framegrabber");
324 while(cpt ++ < opt_nimages)
342 std::cout <<
"Catch an exception: " << e << std::endl;
351 vpERROR_TRACE(
"You do not have X11 or GTK display functionalities...");
VISP_EXPORT int wait(double t0, double t)
Display for windows using GDI (available on any windows 32 platform).
void setBaseName(const char *name)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
void setDirectory(const char *dir)
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void setNumberOfZero(unsigned int noz)
static void display(const vpImage< unsigned char > &I)
void setImageNumber(long number)
void open(vpImage< unsigned char > &I)
Class to grab (ie. read) images from the disk.
void setExtension(const char *ext)
unsigned int getHeight() const
void acquire(vpImage< unsigned char > &I)
unsigned int getWidth() const