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;
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)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
void setCameraIndex(unsigned int index)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void open(vpImage< unsigned char > &I)
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
const std::string & getStringMessage() const
Send a reference (constant) related the error message (can be empty).
static unsigned int getCameraSerial(unsigned int index)
unsigned int getWidth() const