44#include <visp3/core/vpConfig.h>
45#include <visp3/core/vpImage.h>
46#include <visp3/core/vpTime.h>
47#include <visp3/gui/vpDisplayFactory.h>
48#include <visp3/io/vpImageIo.h>
49#include <visp3/io/vpParseArgv.h>
50#include <visp3/sensor/vp1394CMUGrabber.h>
55#define GETOPTARGS "dhn:o:"
57#ifdef ENABLE_VISP_NAMESPACE
62void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath);
63bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath);
75void usage(
const char *name,
const char *badparam,
unsigned &nframes, std::string &opath)
78Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\
79it using GDI or OpenCV if GDI is not available.\n\
82 %s [-d] [-n] [-o] [-h] \n",
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\
101nframes, opath.c_str());
103 fprintf(stderr,
"ERROR: \n");
104 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
123bool getOptions(
int argc,
const char **argv,
bool &display,
unsigned int &nframes,
bool &save, std::string &opath)
134 nframes =
static_cast<unsigned int>(atoi(optarg_));
141 usage(argv[0],
nullptr, nframes, opath);
145 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)
168int 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(VISP_HAVE_DISPLAY)
215#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
221 display->init(I, 100, 100,
"Current image");
227 double tbegin = 0, ttotal = 0;
232 for (
unsigned i = 0;
i < nframes;
i++) {
236#if defined(VISP_HAVE_DISPLAY)
247 char buf[FILENAME_MAX];
248 snprintf(buf, FILENAME_MAX, opath.c_str(), i);
250 std::cout <<
"Write: " <<
filename << std::endl;
254 double 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;
262#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
263 if (display !=
nullptr) {
270 std::cout <<
"Catch an exception: " <<
e << std::endl;
271#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
272 if (display !=
nullptr) {
282 std::cout <<
"This example requires CMU 1394 Digital Camera SDK. " << std::endl;
283 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
284 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)
Class that defines generic functionalities for display.
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)
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
VISP_EXPORT double measureTimeMs()