45 #include <visp3/core/vpConfig.h>
47 #if defined(VISP_HAVE_FLYCAPTURE)
49 #include <visp3/core/vpImage.h>
50 #include <visp3/core/vpImageConvert.h>
51 #include <visp3/gui/vpDisplayGDI.h>
52 #include <visp3/gui/vpDisplayOpenCV.h>
53 #include <visp3/gui/vpDisplayX.h>
54 #include <visp3/io/vpImageIo.h>
55 #include <visp3/io/vpParseArgv.h>
56 #include <visp3/sensor/vpFlyCaptureGrabber.h>
58 #define GETOPTARGS "cdhi:n:o:"
60 #ifdef ENABLE_VISP_NAMESPACE
74 void usage(
const char *name,
const char *badparam,
unsigned int icamera, std::string &opath)
77 Acquire and display images using PointGrey FlyCapture SDK.\n\
80 %s [-c] [-d] [-i <camera index>] [-o <output image filename>] [-h] \n",
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\
102 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,
bool &save, std::string &opath,
127 unsigned int &icamera)
141 icamera = (
unsigned int)atoi(optarg_);
148 usage(argv[0],
nullptr, icamera, opath);
153 usage(argv[0], optarg_, icamera, opath);
159 if ((c == 1) || (c == -1)) {
161 usage(argv[0],
nullptr, icamera, opath);
162 std::cerr <<
"ERROR: " << std::endl;
163 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
173 int main(
int argc,
const char **argv)
176 bool opt_display =
true;
177 bool opt_click =
true;
178 bool opt_save =
false;
179 unsigned int opt_icamera = 0;
180 std::string opt_opath =
"I%04d.pgm";
185 if (getOptions(argc, argv, opt_display, opt_click, opt_save, opt_opath, opt_icamera) ==
false) {
189 std::cout <<
"Use device : " << opt_icamera << std::endl;
194 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
198 #if defined(VISP_HAVE_X11)
199 display =
new vpDisplayX(I);
200 #elif defined(VISP_HAVE_GDI)
202 #elif defined(HAVE_OPENCV_HIGHGUI)
205 std::cout <<
"No image viewer is available..." << std::endl;
213 static unsigned int frame = 0;
214 char buf[FILENAME_MAX];
215 snprintf(buf, FILENAME_MAX, opt_opath.c_str(), frame++);
216 std::string filename(buf);
217 std::cout <<
"Write: " << filename << std::endl;
224 if (opt_click && opt_display) {
229 static unsigned int cpt = 0;
250 std::cout <<
"You do not have PointGrey FlyCapture SDK enabled..." << std::endl;
251 std::cout <<
"Tip:" << std::endl;
252 std::cout <<
"- Install FlyCapture SDK, configure again ViSP using cmake and build again this example" << std::endl;
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
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 displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
const std::string & getStringMessage() const
void setCameraIndex(unsigned int index)
static unsigned int getCameraSerial(unsigned int index)
void open(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)
unsigned int getCameraIndex() const
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)