Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tutorial-grabber-1394-writer.cpp
1 
2 #include <visp3/sensor/vp1394TwoGrabber.h>
3 #include <visp3/gui/vpDisplayX.h>
4 #include <visp3/core/vpImage.h>
5 #include <visp3/io/vpVideoWriter.h>
6 
7 int main(int argc, char **)
8 {
9 #ifdef VISP_HAVE_DC1394
10  try {
11  bool save = false;
12  if(argc == 2) {
13  save = true;
14  }
15 
16  vpImage<unsigned char> I; // Create a gray level image container
17  bool reset = true; // Enable bus reset during construction (default)
18  vp1394TwoGrabber g(reset); // Create a grabber based on libdc1394-2.x third party lib
19 
21  g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_60);
22  g.open(I);
23 
24  std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl;
25 
26 #ifdef VISP_HAVE_X11
27  vpDisplayX d(I);
28 #else
29  std::cout << "No image viewer is available..." << std::endl;
30 #endif
31 
32  vpVideoWriter writer;
33  writer.setFileName("./I%04d.pgm");
34  if (save)
35  writer.open(I);
36 
37  while(1) {
38  g.acquire(I);
39 
40  if (save)
41  writer.saveFrame(I);
42 
45 
46  if (vpDisplay::getClick(I, false))
47  break;
48  }
49 
50  if (save)
51  writer.close();
52 
53  }
54  catch(vpException &e) {
55  std::cout << "Catch an exception: " << e << std::endl;
56  }
57 #else
58  (void)argc;
59 #endif
60 
61  return 0;
62 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getWidth() const
Definition: vpImage.h:226
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:153
error that can be emited by ViSP classes.
Definition: vpException.h:73
static void flush(const vpImage< unsigned char > &I)
static void display(const vpImage< unsigned char > &I)
Class that enables to write easily a video file or a sequence of images.
void saveFrame(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const char *filename)
unsigned int getHeight() const
Definition: vpImage.h:175
Class for firewire ieee1394 video devices using libdc1394-2.x api.