49 #include <visp3/core/vpConfig.h> 50 #include <visp3/sensor/vp1394CMUGrabber.h> 51 #include <visp3/core/vpImage.h> 52 #include <visp3/io/vpImageIo.h> 53 #include <visp3/gui/vpDisplayGDI.h> 54 #include <visp3/gui/vpDisplayOpenCV.h> 55 #include <visp3/io/vpParseArgv.h> 56 #include <visp3/core/vpTime.h> 61 #define GETOPTARGS "dhn:o:" 63 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath);
64 bool getOptions(
int argc,
const char **argv,
bool &display,
65 unsigned int &nframes,
bool &save, std::string &opath);
77 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
80 Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\ 81 it using GDI or OpenCV if GDI is not available.\n\ 84 %s [-d] [-n] [-o] [-h] \n", name);
89 Turn off the display.\n\ 92 Number of frames to acquire. \n\ 95 Filename for image saving. \n\ 97 The %%d is for the image numbering.\n\ 101 \n", nframes, opath.c_str());
103 fprintf(stderr,
"ERROR: \n" );
104 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
123 bool getOptions(
int argc,
const char **argv,
bool &display,
124 unsigned int &nframes,
bool &save, std::string &opath)
131 case 'd': display =
false;
break;
133 nframes = (
unsigned int)atoi(optarg_);
break;
136 opath = optarg_;
break;
137 case 'h': usage(argv[0], NULL, nframes, opath);
return false;
break;
140 usage(argv[0], optarg_, nframes, opath);
145 if ((c == 1) || (c == -1)) {
147 usage(argv[0], NULL, nframes, opath);
148 std::cerr <<
"ERROR: " << std::endl;
149 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
163 #if defined(VISP_HAVE_CMU1394) 165 main(
int argc,
const char ** argv)
167 bool opt_display =
true;
168 unsigned nframes = 50;
182 std::string opath =
"C:/temp/I%04d.ppm";
185 std::string opath =
"C:/temp/I%04d.pgm";
189 if (getOptions(argc, argv, opt_display, nframes, save, opath) ==
false) {
195 unsigned short gain_min, gain_max;
197 std::cout <<
"Gain range [" << gain_min <<
", " << gain_max <<
"]" << std::endl;
198 unsigned short shutter_min, shutter_max;
200 std::cout <<
"Shutter range [" << shutter_min <<
", " << shutter_max <<
"]" << std::endl;
202 std::cout <<
"Actual framerate: " << g.
getFramerate() << std::endl;
206 std::cout <<
"Image size: width : " << I.
getWidth() <<
" height: " 209 #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 212 #if defined VISP_HAVE_OPENCV 214 #elif defined VISP_HAVE_GDI 218 display.
init(I,100,100,
"DirectShow Framegrabber");
223 double tbegin=0, tend=0, tloop=0, ttotal=0;
228 for (
unsigned i = 0; i < nframes; i++) {
232 #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 243 char buf[FILENAME_MAX];
244 sprintf(buf, opath.c_str(), i);
245 std::string filename(buf);
246 std::cout <<
"Write: " << filename << std::endl;
250 tloop = tend - tbegin;
252 std::cout <<
"loop time: " << tloop <<
" ms" << std::endl;
255 std::cout <<
"Mean loop time: " << ttotal / nframes <<
" ms" << std::endl;
256 std::cout <<
"Mean frequency: " << 1000./(ttotal / nframes) <<
" fps" << std::endl;
259 std::cout <<
"Catch an exception: " << e << std::endl;
266 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 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)
VISP_EXPORT double measureTimeMs()
void getShutterMinMax(unsigned short &min, unsigned short &max)
unsigned int getHeight() const
virtual bool getClick(bool blocking=true)=0