53 #include <visp/vpConfig.h>
54 #include <visp/vp1394CMUGrabber.h>
55 #include <visp/vpImage.h>
56 #include <visp/vpImageIo.h>
57 #include <visp/vpDisplayGDI.h>
58 #include <visp/vpDisplayOpenCV.h>
59 #include <visp/vpParseArgv.h>
60 #include <visp/vpTime.h>
65 #define GETOPTARGS "dhn:o:"
67 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath);
68 bool getOptions(
int argc,
const char **argv,
bool &display,
69 unsigned int &nframes,
bool &save, std::string &opath);
81 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
84 Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\
85 it using GDI or OpenCV if GDI is not available.\n\
88 %s [-d] [-n] [-o] [-h] \n", name);
93 Turn off the display.\n\
96 Number of frames to acquire. \n\
99 Filename for image saving. \n\
101 The %%d is for the image numbering.\n\
105 \n", nframes, opath.c_str());
107 fprintf(stderr,
"ERROR: \n" );
108 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
127 bool getOptions(
int argc,
const char **argv,
bool &display,
128 unsigned int &nframes,
bool &save, std::string &opath)
135 case 'd': display =
false;
break;
137 nframes = (
unsigned int)atoi(optarg_);
break;
140 opath = optarg_;
break;
141 case 'h': usage(argv[0], NULL, nframes, opath);
return false;
break;
144 usage(argv[0], optarg_, nframes, opath);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0], NULL, nframes, opath);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
167 #if defined(VISP_HAVE_CMU1394)
169 main(
int argc,
const char ** argv)
171 bool opt_display =
true;
172 unsigned nframes = 50;
186 std::string opath =
"C:/temp/I%04d.ppm";
189 std::string opath =
"C:/temp/I%04d.pgm";
193 if (getOptions(argc, argv, opt_display, nframes, save, opath) ==
false) {
199 unsigned short gain_min, gain_max;
201 std::cout <<
"Gain range [" << gain_min <<
", " << gain_max <<
"]" << std::endl;
202 unsigned short shutter_min, shutter_max;
204 std::cout <<
"Shutter range [" << shutter_min <<
", " << shutter_max <<
"]" << std::endl;
206 std::cout <<
"Actual framerate: " << g.
getFramerate() << std::endl;
210 std::cout <<
"Image size: width : " << I.
getWidth() <<
" height: "
213 #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
216 #if defined VISP_HAVE_OPENCV
218 #elif defined VISP_HAVE_GDI
222 display.
init(I,100,100,
"DirectShow Framegrabber");
227 double tbegin=0, tend=0, tloop=0, ttotal=0;
232 for (
unsigned i = 0; i < nframes; i++) {
236 #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
247 char buf[FILENAME_MAX];
248 sprintf(buf, opath.c_str(), i);
249 std::string filename(buf);
250 std::cout <<
"Write: " << filename << std::endl;
254 tloop = tend - tbegin;
256 std::cout <<
"loop time: " << tloop <<
" ms" << std::endl;
259 std::cout <<
"Mean loop time: " << ttotal / nframes <<
" ms" << std::endl;
260 std::cout <<
"Mean frequency: " << 1000./(ttotal / nframes) <<
" fps" << std::endl;
263 std::cout <<
"Catch an exception: " << e << std::endl;
270 std::cout <<
"This example requires CMU 1394 Digital Camera SDK. " << std::endl;
static void write(const vpImage< unsigned char > &I, const char *filename)
void setVideoMode(unsigned long format, unsigned long mode)
unsigned int getWidth() const
Display for windows using GDI (available on any windows 32 platform).
error that can be emited by ViSP classes.
static double measureTimeMs()
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void getGainMinMax(unsigned short &min, unsigned short &max)
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void setFramerate(unsigned long fps)
void acquire(vpImage< unsigned char > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void getShutterMinMax(unsigned short &min, unsigned short &max)
unsigned int getHeight() const
virtual bool getClick(bool blocking=true)=0