48 #include <visp3/core/vpConfig.h>
50 #if defined(VISP_HAVE_FLYCAPTURE)
52 #include <visp3/core/vpImage.h>
53 #include <visp3/core/vpImageConvert.h>
54 #include <visp3/gui/vpDisplayGDI.h>
55 #include <visp3/gui/vpDisplayOpenCV.h>
56 #include <visp3/gui/vpDisplayX.h>
57 #include <visp3/io/vpImageIo.h>
58 #include <visp3/io/vpParseArgv.h>
59 #include <visp3/sensor/vpFlyCaptureGrabber.h>
61 #define GETOPTARGS "cdhi:n:o:"
73 void usage(
const char *name,
const char *badparam,
unsigned int icamera, std::string &opath)
76 Acquire and display images using PointGrey FlyCapture SDK.\n\
79 %s [-c] [-d] [-i <camera index>] [-o <output image filename>] [-h] \n", name);
84 Disable mouse click and acquire only 10 images.\n\
87 Turn off the display.\n\
90 Camera index to connect (0 for the first one). \n\
93 Filename for image saving. \n\
95 The %%d is for the image numbering.\n\
99 \n", icamera, opath.c_str());
102 fprintf(stderr,
"ERROR: \n");
103 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
123 bool getOptions(
int argc,
const char **argv,
bool &display,
bool &click,
bool &save, std::string &opath,
124 unsigned int &icamera)
138 icamera = (
unsigned int)atoi(optarg_);
145 usage(argv[0], NULL, icamera, opath);
150 usage(argv[0], optarg_, icamera, opath);
156 if ((c == 1) || (c == -1)) {
158 usage(argv[0], NULL, icamera, opath);
159 std::cerr <<
"ERROR: " << std::endl;
160 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
170 int main(
int argc,
const char **argv)
173 bool opt_display =
true;
174 bool opt_click =
true;
175 bool opt_save =
false;
176 unsigned int opt_icamera = 0;
177 std::string opt_opath =
"I%04d.pgm";
182 if (getOptions(argc, argv, opt_display, opt_click, opt_save, opt_opath, opt_icamera) ==
false) {
186 std::cout <<
"Use device : " << opt_icamera << std::endl;
191 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
195 #if defined(VISP_HAVE_X11)
197 #elif defined(VISP_HAVE_GDI)
199 #elif defined(VISP_HAVE_OPENCV)
202 std::cout <<
"No image viewer is available..." << std::endl;
210 static unsigned int frame = 0;
211 char buf[FILENAME_MAX];
212 sprintf(buf, opt_opath.c_str(), frame++);
213 std::string filename(buf);
214 std::cout <<
"Write: " << filename << std::endl;
221 if (opt_click && opt_display) {
225 static unsigned int cpt = 0;
244 std::cout <<
"You do not have PointGrey FlyCapture SDK enabled..." << std::endl;
245 std::cout <<
"Tip:" << std::endl;
246 std::cout <<
"- Install FlyCapture SDK, configure again ViSP using cmake and build again this example" << std::endl;