46 #include <visp3/core/vpConfig.h>
47 #include <visp3/core/vpImage.h>
48 #include <visp3/core/vpTime.h>
49 #include <visp3/gui/vpDisplayGDI.h>
50 #include <visp3/gui/vpDisplayOpenCV.h>
51 #include <visp3/io/vpImageIo.h>
52 #include <visp3/io/vpParseArgv.h>
53 #include <visp3/sensor/vp1394CMUGrabber.h>
58 #define GETOPTARGS "dhn:o:"
60 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath);
61 bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath);
73 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
76 Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\
77 it using GDI or OpenCV if GDI is not available.\n\
80 %s [-d] [-n] [-o] [-h] \n",
86 Turn off the display.\n\
89 Number of frames to acquire. \n\
92 Filename for image saving. \n\
94 The %%d is for the image numbering.\n\
99 nframes, opath.c_str());
101 fprintf(stderr,
"ERROR: \n");
102 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
121 bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath)
132 nframes = (
unsigned int)atoi(optarg_);
139 usage(argv[0],
nullptr, nframes, opath);
144 usage(argv[0], optarg_, nframes, opath);
150 if ((c == 1) || (c == -1)) {
152 usage(argv[0],
nullptr, nframes, opath);
153 std::cerr <<
"ERROR: " << std::endl;
154 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
167 #if defined(VISP_HAVE_CMU1394)
168 int main(
int argc,
const char **argv)
170 bool opt_display =
true;
171 unsigned nframes = 50;
185 std::string opath =
"C:/temp/I%04d.ppm";
188 std::string opath =
"C:/temp/I%04d.pgm";
192 if (getOptions(argc, argv, opt_display, nframes, save, opath) ==
false) {
198 unsigned short gain_min, gain_max;
200 std::cout <<
"Gain range [" << gain_min <<
", " << gain_max <<
"]" << std::endl;
201 unsigned short shutter_min, shutter_max;
203 std::cout <<
"Shutter range [" << shutter_min <<
", " << shutter_max <<
"]" << std::endl;
205 std::cout <<
"Actual framerate: " << g.
getFramerate() << std::endl;
209 std::cout <<
"Image size: width : " << I.
getWidth() <<
" height: " << I.
getHeight() << std::endl;
211 #if (defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI))
214 #if defined(HAVE_OPENCV_HIGHGUI)
216 #elif defined(VISP_HAVE_GDI)
220 display.init(I, 100, 100,
"Current image");
225 double tbegin = 0, ttotal = 0;
230 for (
unsigned i = 0; i < nframes; i++) {
234 #if (defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI))
245 char buf[FILENAME_MAX];
246 snprintf(buf, FILENAME_MAX, opath.c_str(), i);
247 std::string filename(buf);
248 std::cout <<
"Write: " << filename << std::endl;
252 double tloop = tend - tbegin;
254 std::cout <<
"loop time: " << tloop <<
" ms" << std::endl;
257 std::cout <<
"Mean loop time: " << ttotal / nframes <<
" ms" << std::endl;
258 std::cout <<
"Mean frequency: " << 1000. / (ttotal / nframes) <<
" fps" << std::endl;
262 std::cout <<
"Catch an exception: " << e << std::endl;
269 std::cout <<
"This example requires CMU 1394 Digital Camera SDK. " << std::endl;
270 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
271 std::cout <<
"- Install CMU 1394 SDK, configure again ViSP using cmake and build again this example" << std::endl;
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void getGainMinMax(unsigned short &min, unsigned short &max)
void setVideoMode(unsigned long format, unsigned long mode)
void acquire(vpImage< unsigned char > &I)
void setFramerate(unsigned long fps)
void getShutterMinMax(unsigned short &min, unsigned short &max)
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...
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)
error that can be emitted by ViSP classes.
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.
VISP_EXPORT double measureTimeMs()