ViSP  2.9.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 - 2014 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 
157 class VISP_EXPORT vpVideoReader : public vpFrameGrabber
158 {
159  private:
161  vpDiskGrabber *imSequence;
162 #ifdef VISP_HAVE_FFMPEG
163  vpFFMPEG *ffmpeg;
165 #endif
166  typedef enum
168  {
169  FORMAT_PGM,
170  FORMAT_PPM,
171  FORMAT_JPEG,
172  FORMAT_PNG,
173  // Formats supported by opencv
174  FORMAT_TIFF,
175  FORMAT_BMP,
176  FORMAT_DIB,
177  FORMAT_PBM,
178  FORMAT_RASTER,
179  FORMAT_JPEG2000,
180  // Video format
181  FORMAT_AVI,
182  FORMAT_MPEG,
183  FORMAT_MOV,
184  FORMAT_OGV,
185  FORMAT_UNKNOWN
186  } vpVideoFormatType;
187 
189  vpVideoFormatType formatType;
190 
192  char fileName[FILENAME_MAX];
194  bool initFileName;
196  bool isOpen;
198  long frameCount;
200  long firstFrame;
202  long lastFrame;
203  bool firstFrameIndexIsSet;
204  bool lastFrameIndexIsSet;
205 
206  public:
207  vpVideoReader();
208  ~vpVideoReader();
209 
210  void acquire(vpImage< vpRGBa > &I);
212  void close(){;}
213 
217  inline bool end() {
218  if (frameCount > lastFrame )
219  return true;
220  return false;
221  }
222  bool getFrame(vpImage<vpRGBa> &I, long frame);
223  bool getFrame(vpImage<unsigned char> &I, long frame);
224  double getFramerate() const;
225 
233  inline long getFrameIndex() const { return frameCount;}
234 
240  inline long getLastFrameIndex() const {return lastFrame;}
241  void open (vpImage< vpRGBa > &I);
242  void open (vpImage< unsigned char > &I);
243 
251  inline void resetFrameCounter() {frameCount = firstFrame;}
252  void setFileName(const char *filename);
253  void setFileName(const std::string &filename);
262  inline void setFirstFrameIndex(const long first_frame) {
263  this->firstFrameIndexIsSet = true;
264  this->firstFrame = first_frame;
265  }
273  inline void setLastFrameIndex(const long last_frame) {
274  this->lastFrameIndexIsSet = true;
275  this->lastFrame = last_frame;
276  }
277 
278  private:
279  vpVideoFormatType getFormat(const char *filename);
280  static std::string getExtension(const std::string &filename);
281  void findFirstFrameIndex();
282  void findLastFrameIndex();
283 };
284 
285 #endif
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()
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.
void setLastFrameIndex(const long last_frame)
void setFirstFrameIndex(const long first_frame)
virtual void acquire(vpImage< unsigned char > &I)=0