ViSP  2.9.0
tutorial-grabber-video.cpp
1 
2 #include <visp/vpDisplayX.h>
3 #include <visp/vpVideoReader.h>
4 
5 int main()
6 {
7 #ifdef VISP_HAVE_FFMPEG
8  try {
10 
11  vpVideoReader g;
12  g.setFileName("./video.mpg");
13  g.open(I);
14 
15  std::cout << "video framerate: " << g.getFramerate() << "Hz" << std::endl;
16  std::cout << "video dimension: " << I.getWidth() << " " << I.getHeight() << std::endl;
17 
18 #ifdef VISP_HAVE_X11
19  vpDisplayX d(I);
20 #else
21  std::cout << "No image viewer is available..." << std::endl;
22 #endif
23  vpDisplay::setTitle(I, "Video grabber");
24  while (! g.end() ) {
25  double t = vpTime::measureTimeMs();
26  g.acquire(I);
29  if (vpDisplay::getClick(I, false)) break;
30  vpTime::wait(t, 1000. / g.getFramerate());
31  }
32  }
33  catch(vpException e) {
34  std::cout << "Catch an exception: " << e << std::endl;
35  }
36 #endif
37 }
unsigned int getWidth() const
Definition: vpImage.h:159
Define the X11 console to display images.
Definition: vpDisplayX.h:152
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
error that can be emited by ViSP classes.
Definition: vpException.h:76
static double measureTimeMs()
Definition: vpTime.cpp:86
static int wait(double t0, double t)
Definition: vpTime.cpp:149
static void flush(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:1994
void open(vpImage< vpRGBa > &I)
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
virtual void setTitle(const char *title)=0
void acquire(vpImage< vpRGBa > &I)
void setFileName(const char *filename)
unsigned int getHeight() const
Definition: vpImage.h:150
double getFramerate() const
virtual bool getClick(bool blocking=true)=0