38 #include <visp3/core/vpConfig.h> 49 #include <visp3/core/vpConfig.h> 51 #if defined(VISP_HAVE_FLYCAPTURE) 53 #include <visp3/gui/vpDisplayX.h> 54 #include <visp3/gui/vpDisplayGDI.h> 55 #include <visp3/gui/vpDisplayOpenCV.h> 56 #include <visp3/core/vpImage.h> 57 #include <visp3/core/vpImageConvert.h> 58 #include <visp3/io/vpParseArgv.h> 59 #include <visp3/io/vpImageIo.h> 60 #include <visp3/sensor/vpFlyCaptureGrabber.h> 62 #define GETOPTARGS "cdhi:n:o:" 74 void usage(
const char *name,
const char *badparam,
79 Acquire and display images using PointGrey FlyCapture SDK.\n\ 82 %s [-c] [-d] [-i <camera index>] [-o <output image filename>] [-h] \n", name);
87 Disable mouse click and acquire only 10 images.\n\ 90 Turn off the display.\n\ 93 Camera index to connect (0 for the first one). \n\ 96 Filename for image saving. \n\ 98 The %%d is for the image numbering.\n\ 102 \n", icamera, opath.c_str());
105 fprintf(stderr,
"ERROR: \n" );
106 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
126 bool getOptions(
int argc,
const char **argv,
bool &display,
bool &click,
127 bool &save, std::string &opath,
unsigned int &icamera)
134 case 'c': click =
false;
break;
135 case 'd': display =
false;
break;
136 case 'i': icamera = (
unsigned int)atoi(optarg_);
break;
139 opath = optarg_;
break;
140 case 'h': usage(argv[0], NULL, icamera, opath);
return false;
break;
143 usage(argv[0], optarg_, icamera, opath);
148 if ((c == 1) || (c == -1)) {
150 usage(argv[0], NULL, icamera, opath);
151 std::cerr <<
"ERROR: " << std::endl;
152 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
162 int main(
int argc,
const char** argv)
165 bool opt_display =
true;
166 bool opt_click =
true;
167 bool opt_save =
false;
168 unsigned int opt_icamera = 0;
169 std::string opt_opath =
"I%04d.pgm";
174 if (getOptions(argc, argv, opt_display, opt_click, opt_save,
175 opt_opath, opt_icamera) ==
false) {
179 std::cout <<
"Use device : " << opt_icamera << std::endl;
184 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
188 #if defined(VISP_HAVE_X11) 190 #elif defined(VISP_HAVE_GDI) 192 #elif defined(VISP_HAVE_OPENCV) 195 std::cout <<
"No image viewer is available..." << std::endl;
203 static unsigned int frame = 0;
204 char buf[FILENAME_MAX];
205 sprintf(buf, opt_opath.c_str(), frame++);
206 std::string filename(buf);
207 std::cout <<
"Write: " << filename << std::endl;
214 if (opt_click && opt_display) {
219 static unsigned int cpt = 0;
239 std::cout <<
"PointGrey FlyCapture SDK is not available..." << std::endl;
Class that defines generic functionnalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void acquire(vpImage< unsigned char > &I)
error that can be emited by ViSP classes.
static void flush(const vpImage< unsigned char > &I)
void setCameraIndex(unsigned int index)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void open(vpImage< unsigned char > &I)
static void write(const vpImage< unsigned char > &I, const std::string &filename)
unsigned int getCameraIndex() const
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
unsigned int getHeight() const
static unsigned int getCameraSerial(unsigned int index)
unsigned int getWidth() const
const std::string & getStringMessage(void) const
Send a reference (constant) related the error message (can be empty).