39 #include <visp3/core/vpConfig.h>
50 #include <visp3/core/vpConfig.h>
52 #if defined(VISP_HAVE_FLYCAPTURE)
54 #include <visp3/core/vpImage.h>
55 #include <visp3/core/vpImageConvert.h>
56 #include <visp3/gui/vpDisplayGDI.h>
57 #include <visp3/gui/vpDisplayOpenCV.h>
58 #include <visp3/gui/vpDisplayX.h>
59 #include <visp3/io/vpImageIo.h>
60 #include <visp3/io/vpParseArgv.h>
61 #include <visp3/sensor/vpFlyCaptureGrabber.h>
63 #define GETOPTARGS "cdhi:n:o:"
75 void usage(
const char *name,
const char *badparam,
unsigned int icamera, std::string &opath)
78 Acquire and display images using PointGrey FlyCapture SDK.\n\
81 %s [-c] [-d] [-i <camera index>] [-o <output image filename>] [-h] \n", name);
86 Disable mouse click and acquire only 10 images.\n\
89 Turn off the display.\n\
92 Camera index to connect (0 for the first one). \n\
95 Filename for image saving. \n\
97 The %%d is for the image numbering.\n\
101 \n", icamera, opath.c_str());
104 fprintf(stderr,
"ERROR: \n");
105 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
125 bool getOptions(
int argc,
const char **argv,
bool &display,
bool &click,
bool &save, std::string &opath,
126 unsigned int &icamera)
140 icamera = (
unsigned int)atoi(optarg_);
147 usage(argv[0], NULL, icamera, opath);
152 usage(argv[0], optarg_, icamera, opath);
158 if ((c == 1) || (c == -1)) {
160 usage(argv[0], NULL, icamera, opath);
161 std::cerr <<
"ERROR: " << std::endl;
162 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
172 int main(
int argc,
const char **argv)
175 bool opt_display =
true;
176 bool opt_click =
true;
177 bool opt_save =
false;
178 unsigned int opt_icamera = 0;
179 std::string opt_opath =
"I%04d.pgm";
184 if (getOptions(argc, argv, opt_display, opt_click, opt_save, opt_opath, opt_icamera) ==
false) {
188 std::cout <<
"Use device : " << opt_icamera << std::endl;
193 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
197 #if defined(VISP_HAVE_X11)
199 #elif defined(VISP_HAVE_GDI)
201 #elif defined(VISP_HAVE_OPENCV)
204 std::cout <<
"No image viewer is available..." << std::endl;
212 static unsigned int frame = 0;
213 char buf[FILENAME_MAX];
214 sprintf(buf, opt_opath.c_str(), frame++);
215 std::string filename(buf);
216 std::cout <<
"Write: " << filename << std::endl;
223 if (opt_click && opt_display) {
227 static unsigned int cpt = 0;
246 std::cout <<
"You do not have PointGrey FlyCapture SDK enabled..." << std::endl;
247 std::cout <<
"Tip:" << std::endl;
248 std::cout <<
"- Install FlyCapture SDK, configure again ViSP using cmake and build again this example" << std::endl;