cgv
video_reader.h
1 #pragma once
2 
3 #include <cgv/base/base.h>
4 #include <cgv/data/data_view.h>
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace media {
11  namespace video {
12 
13 class CGV_API video_reader;
14 
16 class CGV_API abst_video_reader : public cgv::base::base
17 {
18 public:
19  friend class video_reader;
21  virtual abst_video_reader* clone() const = 0;
23  virtual const std::string& get_last_error() const = 0;
25  virtual const char* get_supported_extensions() const = 0;
27  virtual bool open(const std::string& file_name, cgv::data::data_format& df, float& fps) = 0;
29  virtual bool read_frame(const cgv::data::data_view& dv) = 0;
31  virtual bool close() = 0;
32 
33 };
34 
36 class CGV_API video_reader : public cgv::base::base
37 {
38 protected:
44  float fps;
46  std::string last_error;
48  bool set_void(const std::string& property, const std::string& type, const void* value);
50  bool get_void(const std::string& property, const std::string& type, void* value);
51 public:
54  video_reader(cgv::data::data_format& image_format);
56  ~video_reader();
58  std::string get_type_name() const;
60  static const std::string& get_supported_extensions(char sep = ';');
62  static std::string construct_filter_string();
64  std::string get_property_declarations();
66  const std::string& get_last_error() const;
68  bool open(const std::string& file_name);
70  const cgv::data::data_format& get_image_format() const;
72  float get_fps() const;
77  bool read_frame(cgv::data::data_view& dv);
80  bool read_frame(const cgv::data::data_view& dv);
82  bool close();
83 };
84 
85  }
86  }
87 }
88 
89 #include <cgv/config/lib_end.h>
cgv::media::video::video_reader::last_error
std::string last_error
store the last error not resulting from video writer implementations
Definition: video_reader.h:46
cgv::media::video::video_reader::rd
abst_video_reader * rd
store a pointer to the chosen reader
Definition: video_reader.h:42
cgv::media::video::abst_video_reader::open
virtual bool open(const std::string &file_name, cgv::data::data_format &df, float &fps)=0
open the file and read the header in order to determine the image format and the fps
cgv::media::video::abst_video_reader::read_frame
virtual bool read_frame(const cgv::data::data_view &dv)=0
read a frame and return whether this was successful
cgv::media::video::video_reader
the video reader chooses a specific reader automatically based on the extension of the given file nam...
Definition: video_reader.h:37
cgv::media::video::abst_video_reader::get_supported_extensions
virtual const char * get_supported_extensions() const =0
return a string containing a colon separated list of extensions that can be read with this reader
cgv::data::data_view
Definition: data_view.h:155
cgv::media::video::abst_video_reader
abstract interface for a video reader
Definition: video_reader.h:17
cgv::media::video::video_reader::image_format_ptr
cgv::data::data_format * image_format_ptr
store the image format
Definition: video_reader.h:40
cgv::data::data_format
Definition: data_format.h:18
cgv::media::video::video_reader::fps
float fps
store the fps of the opened video file
Definition: video_reader.h:44
cgv::base::base
Definition: base.h:57
cgv::media::video::abst_video_reader::close
virtual bool close()=0
close the video file
cgv::media::video::abst_video_reader::get_last_error
virtual const std::string & get_last_error() const =0
return a reference to the last error message
cgv::media::video::abst_video_reader::clone
virtual abst_video_reader * clone() const =0
construct a copy of the video reader
cgv::type::info::get_type_name
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition: type_id.cxx:117
cgv
the cgv namespace
Definition: vr_calib.cxx:9