49 #include <visp3/core/vpConfig.h> 50 #include <visp3/core/vpImage.h> 51 #include <visp3/core/vpTime.h> 52 #include <visp3/gui/vpDisplayGDI.h> 53 #include <visp3/gui/vpDisplayOpenCV.h> 54 #include <visp3/io/vpImageIo.h> 55 #include <visp3/io/vpParseArgv.h> 56 #include <visp3/sensor/vp1394CMUGrabber.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,
unsigned int &nframes,
bool &save, std::string &opath);
76 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
79 Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\ 80 it using GDI or OpenCV if GDI is not available.\n\ 83 %s [-d] [-n] [-o] [-h] \n", name);
88 Turn off the display.\n\ 91 Number of frames to acquire. \n\ 94 Filename for image saving. \n\ 96 The %%d is for the image numbering.\n\ 100 \n", nframes, opath.c_str());
102 fprintf(stderr,
"ERROR: \n");
103 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
122 bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath)
133 nframes = (
unsigned int)atoi(optarg_);
140 usage(argv[0], NULL, nframes, opath);
145 usage(argv[0], optarg_, nframes, opath);
151 if ((c == 1) || (c == -1)) {
153 usage(argv[0], NULL, nframes, opath);
154 std::cerr <<
"ERROR: " << std::endl;
155 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
168 #if defined(VISP_HAVE_CMU1394) 169 int 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: " << I.
getHeight() << std::endl;
212 #if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 215 #if defined VISP_HAVE_OPENCV 217 #elif defined VISP_HAVE_GDI 221 display.
init(I, 100, 100,
"DirectShow Framegrabber");
226 double tbegin = 0, ttotal = 0;
231 for (
unsigned i = 0; i < nframes; i++) {
235 #if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 246 char buf[FILENAME_MAX];
247 sprintf(buf, opath.c_str(), i);
248 std::string filename(buf);
249 std::cout <<
"Write: " << filename << std::endl;
253 double tloop = tend - tbegin;
255 std::cout <<
"loop time: " << tloop <<
" ms" << std::endl;
258 std::cout <<
"Mean loop time: " << ttotal / nframes <<
" ms" << std::endl;
259 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;
void setVideoMode(unsigned long format, unsigned long mode)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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)
VISP_EXPORT double measureTimeMs()
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static void write(const vpImage< unsigned char > &I, const std::string &filename)
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. Thus to enable this class OpenC...
void getShutterMinMax(unsigned short &min, unsigned short &max)
unsigned int getHeight() const
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")