43#include <visp3/core/vpConfig.h>
45#if defined(VISP_HAVE_FLYCAPTURE)
47#include <visp3/core/vpImage.h>
48#include <visp3/core/vpImageConvert.h>
49#include <visp3/gui/vpDisplayFactory.h>
50#include <visp3/io/vpImageIo.h>
51#include <visp3/io/vpParseArgv.h>
52#include <visp3/sensor/vpFlyCaptureGrabber.h>
54#define GETOPTARGS "cdhi:n:o:"
56#ifdef ENABLE_VISP_NAMESPACE
70void usage(
const char *name,
const char *badparam,
unsigned int icamera, std::string &opath)
73Acquire 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\
98icamera, opath.c_str());
101 fprintf(stderr,
"ERROR: \n");
102 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
122bool getOptions(
int argc,
const char **argv,
bool &display,
bool &click,
bool &save, std::string &opath,
123 unsigned int &icamera)
137 icamera =
static_cast<unsigned int>(atoi(optarg_));
144 usage(argv[0],
nullptr, icamera, opath);
148 usage(argv[0], optarg_, icamera, opath);
153 if ((c == 1) || (c == -1)) {
155 usage(argv[0],
nullptr, icamera, opath);
156 std::cerr <<
"ERROR: " << std::endl;
157 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
167int main(
int argc,
const char **argv)
169#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
170 std::shared_ptr<vpDisplay> display;
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;
196#if defined(VISP_HAVE_DISPLAY)
197#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
203 std::cout <<
"No image viewer is available..." << std::endl;
211 static unsigned int frame = 0;
212 char buf[FILENAME_MAX];
213 snprintf(buf, FILENAME_MAX, opt_opath.c_str(), frame++);
215 std::cout <<
"Write: " <<
filename << std::endl;
222 if (opt_click && opt_display) {
227 static unsigned int cpt = 0;
232#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
233 if (display !=
nullptr) {
243#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
244 if (display !=
nullptr) {
248 std::cout <<
"Catch an exception: " <<
e.getStringMessage() << std::endl;
256 std::cout <<
"You do not have PointGrey FlyCapture SDK enabled..." << std::endl;
257 std::cout <<
"Tip:" << std::endl;
258 std::cout <<
"- Install FlyCapture SDK, configure again ViSP using cmake and build again this example" << std::endl;
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.
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)
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.