ViSP  2.7.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 
123 class VISP_EXPORT vpVideoReader : public vpFrameGrabber
124 {
125  private:
127  vpDiskGrabber *imSequence;
128 #ifdef VISP_HAVE_FFMPEG
129  vpFFMPEG *ffmpeg;
131 #endif
132  typedef enum
134  {
135  FORMAT_PGM,
136  FORMAT_PPM,
137  FORMAT_JPEG,
138  FORMAT_PNG,
139  FORMAT_AVI,
140  FORMAT_MPEG,
141  FORMAT_MOV,
142  FORMAT_OGV,
143  FORMAT_UNKNOWN
144  } vpVideoFormatType;
145 
147  vpVideoFormatType formatType;
148 
150  char fileName[FILENAME_MAX];
152  bool initFileName;
154  bool isOpen;
156  long frameCount;
158  long firstFrame;
160  long lastFrame;
161 
162  public:
163  vpVideoReader();
164  ~vpVideoReader();
165 
166  void acquire(vpImage< vpRGBa > &I);
168  void close(){;}
169 
170  bool getFrame(vpImage<vpRGBa> &I, long frame);
171  bool getFrame(vpImage<unsigned char> &I, long frame);
179  inline long getFrameIndex() const { return frameCount;}
180 
186  inline long getLastFrameIndex() const {return lastFrame;}
187  void open (vpImage< vpRGBa > &I);
188  void open (vpImage< unsigned char > &I);
189 
197  inline void resetFrameCounter() {frameCount = firstFrame;}
198  void setFileName(const char *filename);
199  void setFileName(const std::string &filename);
206  inline void setFirstFrameIndex(const long firstFrame) {this->firstFrame = firstFrame;}
207 
208  private:
209  vpVideoFormatType getFormat(const char *filename);
210  static std::string getExtension(const std::string &filename);
211  void findLastFrameIndex();
212 };
213 
214 #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()
This class interfaces the FFmpeg library to enable the reading of video files.
Definition: vpFFMPEG.h:154
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