Visual Servoing Platform version 3.5.0
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
7int 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
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}
Class for firewire ieee1394 video devices using libdc1394-2.x api.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:135
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 emited by ViSP classes.
Definition: vpException.h:72
unsigned int getWidth() const
Definition: vpImage.h:246
unsigned int getHeight() const
Definition: vpImage.h:188
Class that enables to write easily a video file or a sequence of images.
void saveFrame(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void open(vpImage< vpRGBa > &I)