ViSP  2.8.0
vpVideoReader.h
1 /****************************************************************************
2  *
3  * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Read videos and sequences of images .
36  *
37  * Authors:
38  * Nicolas Melchior
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
48 #ifndef vpVideoReader_H
49 #define vpVideoReader_H
50 
51 #include <string>
52 
53 #include <visp/vpDiskGrabber.h>
54 #include <visp/vpFFMPEG.h>
55 
152 class VISP_EXPORT vpVideoReader : public vpFrameGrabber
153 {
154  private:
156  vpDiskGrabber *imSequence;
157 #ifdef VISP_HAVE_FFMPEG
158  vpFFMPEG *ffmpeg;
160 #endif
161  typedef enum
163  {
164  FORMAT_PGM,
165  FORMAT_PPM,
166  FORMAT_JPEG,
167  FORMAT_PNG,
168  // Formats supported by opencv
169  FORMAT_TIFF,
170  FORMAT_BMP,
171  FORMAT_DIB,
172  FORMAT_PBM,
173  FORMAT_RASTER,
174  FORMAT_JPEG2000,
175  // Video format
176  FORMAT_AVI,
177  FORMAT_MPEG,
178  FORMAT_MOV,
179  FORMAT_OGV,
180  FORMAT_UNKNOWN
181  } vpVideoFormatType;
182 
184  vpVideoFormatType formatType;
185 
187  char fileName[FILENAME_MAX];
189  bool initFileName;
191  bool isOpen;
193  long frameCount;
195  long firstFrame;
197  long lastFrame;
198  bool firstFrameIndexIsSet;
199  bool lastFrameIndexIsSet;
200 
201  public:
202  vpVideoReader();
203  ~vpVideoReader();
204 
205  void acquire(vpImage< vpRGBa > &I);
207  void close(){;}
208 
212  inline bool end() {
213  if (frameCount > lastFrame )
214  return true;
215  return false;
216  }
217  bool getFrame(vpImage<vpRGBa> &I, long frame);
218  bool getFrame(vpImage<unsigned char> &I, long frame);
219  double getFramerate() const;
220 
228  inline long getFrameIndex() const { return frameCount;}
229 
235  inline long getLastFrameIndex() const {return lastFrame;}
236  void open (vpImage< vpRGBa > &I);
237  void open (vpImage< unsigned char > &I);
238 
246  inline void resetFrameCounter() {frameCount = firstFrame;}
247  void setFileName(const char *filename);
248  void setFileName(const std::string &filename);
257  inline void setFirstFrameIndex(const long firstFrame) {
258  this->firstFrameIndexIsSet = true;
259  this->firstFrame = firstFrame;
260  }
268  inline void setLastFrameIndex(const long lastFrame) {
269  this->lastFrameIndexIsSet = true;
270  this->lastFrame = lastFrame;
271  }
272 
273  private:
274  vpVideoFormatType getFormat(const char *filename);
275  static std::string getExtension(const std::string &filename);
276  void findFirstFrameIndex();
277  void findLastFrameIndex();
278 };
279 
280 #endif
void setFirstFrameIndex(const long firstFrame)
long getFrameIndex() const
long getLastFrameIndex() const
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
virtual void open(vpImage< unsigned char > &I)=0
void resetFrameCounter()
void setLastFrameIndex(const long lastFrame)
This class interfaces the FFmpeg library to enable video stream reading or writing.
Definition: vpFFMPEG.h:149
Class to grab (ie. read) images from the disk.
Base class for all video devices. It is designed to provide a front end to video sources.
virtual void acquire(vpImage< unsigned char > &I)=0