Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
tutorial-grabber-1394-writer.cpp
1 
2 #include <visp3/core/vpImage.h>
3 #include <visp3/gui/vpDisplayX.h>
4 #include <visp3/io/vpVideoWriter.h>
5 #include <visp3/sensor/vp1394TwoGrabber.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  } catch (const vpException &e) {
54  std::cout << "Catch an exception: " << e << std::endl;
55  }
56 #else
57  (void)argc;
58 #endif
59 
60  return 0;
61 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:134
error that can be emited by ViSP classes.
Definition: vpException.h:71
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)
unsigned int getHeight() const
Definition: vpImage.h:188
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void setFileName(const std::string &filename)
unsigned int getWidth() const
Definition: vpImage.h:246