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:"
70 void usage(
const char *name,
const char *badparam,
unsigned int icamera, std::string &opath)
73 Acquire and display images using PointGrey FlyCapture SDK.\n\
76 %s [-c] [-d] [-i <camera index>] [-o <output image filename>] [-h] \n",
82 Disable mouse click and acquire only 10 images.\n\
85 Turn off the display.\n\
88 Camera index to connect (0 for the first one). \n\
91 Filename for image saving. \n\
93 The %%d is for the image numbering.\n\
98 icamera, opath.c_str());
101 fprintf(stderr,
"ERROR: \n");
102 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
122 bool getOptions(
int argc,
const char **argv,
bool &display,
bool &click,
bool &save, std::string &opath,
123 unsigned int &icamera)
137 icamera = (
unsigned int)atoi(optarg_);
144 usage(argv[0],
nullptr, icamera, opath);
149 usage(argv[0], optarg_, icamera, opath);
155 if ((c == 1) || (c == -1)) {
157 usage(argv[0],
nullptr, icamera, opath);
158 std::cerr <<
"ERROR: " << std::endl;
159 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
169 int main(
int argc,
const char **argv)
172 bool opt_display =
true;
173 bool opt_click =
true;
174 bool opt_save =
false;
175 unsigned int opt_icamera = 0;
176 std::string opt_opath =
"I%04d.pgm";
181 if (getOptions(argc, argv, opt_display, opt_click, opt_save, opt_opath, opt_icamera) ==
false) {
185 std::cout <<
"Use device : " << opt_icamera << std::endl;
190 std::cout <<
"Image size : " << I.
getWidth() <<
" " << I.
getHeight() << std::endl;
194 #if defined(VISP_HAVE_X11)
196 #elif defined(VISP_HAVE_GDI)
198 #elif defined(HAVE_OPENCV_HIGHGUI)
201 std::cout <<
"No image viewer is available..." << std::endl;
209 static unsigned int frame = 0;
210 char buf[FILENAME_MAX];
211 snprintf(buf, FILENAME_MAX, opt_opath.c_str(), frame++);
212 std::string filename(buf);
213 std::cout <<
"Write: " << filename << std::endl;
220 if (opt_click && opt_display) {
224 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;
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...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
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)
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.