ViSP  2.8.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
9 
10  vpVideoReader g;
11  g.setFileName("./video.mpg");
12  g.open(I);
13 
14  std::cout << "video framerate: " << g.getFramerate() << "Hz" << std::endl;
15  std::cout << "video dimension: " << I.getWidth() << " " << I.getHeight() << std::endl;
16 
17 #ifdef VISP_HAVE_X11
18  vpDisplayX d(I);
19 #else
20  std::cout << "No image viewer is available..." << std::endl;
21 #endif
22  vpDisplay::setTitle(I, "Video grabber");
23  while (! g.end() ) {
24  double t = vpTime::measureTimeMs();
25  g.acquire(I);
28  if (vpDisplay::getClick(I, false)) break;
29  vpTime::wait(t, 1000. / g.getFramerate());
30  }
31 #endif
32 }
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...
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:1991
void open(vpImage< vpRGBa > &I)
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:203
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