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 #ifdef ENABLE_VISP_NAMESPACE
65 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath);
66 bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath);
78 void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
81 Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\
82 it using GDI or OpenCV if GDI is not available.\n\
85 %s [-d] [-n] [-o] [-h] \n",
91 Turn off the display.\n\
94 Number of frames to acquire. \n\
97 Filename for image saving. \n\
99 The %%d is for the image numbering.\n\
104 nframes, opath.c_str());
106 fprintf(stderr,
"ERROR: \n");
107 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
126 bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath)
137 nframes = (
unsigned int)atoi(optarg_);
144 usage(argv[0],
nullptr, nframes, opath);
149 usage(argv[0], optarg_, nframes, opath);
155 if ((c == 1) || (c == -1)) {
157 usage(argv[0],
nullptr, nframes, opath);
158 std::cerr <<
"ERROR: " << std::endl;
159 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
172 #if defined(VISP_HAVE_CMU1394)
173 int main(
int argc,
const char **argv)
175 bool opt_display =
true;
176 unsigned nframes = 50;
190 std::string opath =
"C:/temp/I%04d.ppm";
193 std::string opath =
"C:/temp/I%04d.pgm";
197 if (getOptions(argc, argv, opt_display, nframes, save, opath) ==
false) {
203 unsigned short gain_min, gain_max;
205 std::cout <<
"Gain range [" << gain_min <<
", " << gain_max <<
"]" << std::endl;
206 unsigned short shutter_min, shutter_max;
208 std::cout <<
"Shutter range [" << shutter_min <<
", " << shutter_max <<
"]" << std::endl;
210 std::cout <<
"Actual framerate: " << g.
getFramerate() << std::endl;
214 std::cout <<
"Image size: width : " << I.
getWidth() <<
" height: " << I.
getHeight() << std::endl;
216 #if (defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI))
219 #if defined(HAVE_OPENCV_HIGHGUI)
221 #elif defined(VISP_HAVE_GDI)
225 display.init(I, 100, 100,
"Current image");
230 double tbegin = 0, ttotal = 0;
235 for (
unsigned i = 0; i < nframes; i++) {
239 #if (defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI))
250 char buf[FILENAME_MAX];
251 snprintf(buf, FILENAME_MAX, opath.c_str(), i);
252 std::string filename(buf);
253 std::cout <<
"Write: " << filename << std::endl;
257 double tloop = tend - tbegin;
259 std::cout <<
"loop time: " << tloop <<
" ms" << std::endl;
262 std::cout <<
"Mean loop time: " << ttotal / nframes <<
" ms" << std::endl;
263 std::cout <<
"Mean frequency: " << 1000. / (ttotal / nframes) <<
" fps" << std::endl;
267 std::cout <<
"Catch an exception: " << e << std::endl;
274 std::cout <<
"This example requires CMU 1394 Digital Camera SDK. " << std::endl;
275 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
276 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)
VISP_EXPORT double measureTimeMs()