1 #ifndef CVD_DISKBUFFER2_H 2 #define CVD_DISKBUFFER2_H 10 #include <cvd/diskbuffer2_frame.h> 11 #include <cvd/image_io.h> 12 #include <cvd/localvideobuffer.h> 13 #include <cvd/videobufferflags.h> 24 std::vector<std::string>
globlist(
const std::string& gl);
36 using CVD::Exceptions::VideoBuffer::All::All;
48 BadFile(
const std::string&,
int);
54 BadImage(
const std::string& file,
const std::string& error);
106 virtual void seek_to(
double t);
112 end_of_buffer_behaviour = eob;
117 return frames_per_sec;
124 double time_per_frame, frames_per_sec;
126 std::vector<std::string> file_names;
133 template <
typename T>
136 , end_of_buffer_behaviour(eob)
138 frames_per_sec = fps;
142 time_per_frame = 1 / fps;
146 if(file_names.size() == 0)
151 im.open(names[0].c_str(), std::ios::in | std::ios::binary);
165 my_size = foo.
size();
172 template <
typename T>
183 std::ifstream im_file(file_names[next_frame].c_str(), std::ios::in | std::ios::binary);
190 img_load(foo, im_file);
201 if(next_frame > (
int)file_names.size() - 1)
203 switch(end_of_buffer_behaviour)
206 next_frame = file_names.size() - 1;
225 template <
typename T>
240 template <
typename T>
245 int frameno =
static_cast<int>((t - start_time) / time_per_frame + 0.5);
246 if(frameno < 0 || static_cast<unsigned int>(frameno) > (file_names.size() - 1))
248 next_frame = frameno;
OnEndOfBuffer
If it is a finite buffer (a video file, for example), what should happen when the end of the buffer i...
Definition: videobufferflags.h:14
An error occurred trying to open a file.
Definition: diskbuffer2.h:46
seek_to() was called for an invalid timestamp
Definition: diskbuffer2.h:70
All classes and functions are within the CVD namespace.
Definition: argb.h:6
ImageRef size() const
What is the size of this image?
Definition: image.h:557
Base class for all DiskBuffer2 exceptions.
Definition: diskbuffer2.h:34
Loop the buffer, so that the next time get_frame() is called it returns the first frame in the buffer...
Definition: videobufferflags.h:18
virtual ImageRef size()
The size of the VideoFrames returned by this buffer.
Definition: diskbuffer2.h:97
The file loaded was a different size from the first frame.
Definition: diskbuffer2.h:58
virtual double frame_rate()
What is the (expected) frame rate of this video buffer, in frames per second?
Definition: diskbuffer2.h:115
virtual void put_frame(VideoFrame< T > *f)
Tell the buffer that you are finished with this frame.
Definition: diskbuffer2.h:226
std::vector< std::string > globlist(const std::string &gl)
Make a list of strings from a UNIX-style pattern pathname expansion.
Definition: win32.cpp:41
virtual void on_end_of_buffer(VideoBufferFlags::OnEndOfBuffer eob)
What should the buffer do when it reaches the end of the list of files?
Definition: diskbuffer2.h:110
The semsntics of the videobuffer. See VideoFrame::type()
Definition: videobuffer.h:12
DiskBuffer2(const std::vector< std::string > &names, double fps, VideoBufferFlags::OnEndOfBuffer eob=VideoBufferFlags::RepeatLastFrame)
Construct a DiskBuffer2 from a vector of filenames.
Definition: diskbuffer2.h:134
Continue to return the final frame when get_frame() is called (with the same timestamp) ...
Definition: videobufferflags.h:16
Set the return value of frame_pending() to false and throw an EndOfBuffer exception if get_frame() is...
Definition: videobufferflags.h:17
Play a series of image files as a video stream.
Definition: diskbuffer2.h:86
An error occurred trying to read a file as an image.
Definition: diskbuffer2.h:52
Base class for a VideoBuffer which manages its own memory for each VideoFrame that it provides...
Definition: localvideobuffer.h:17
Definition: image_ref.h:29
The VideoBuffer was unable to successfully complete a VideoBuffer::put_frame() operation.
Definition: videobuffer.h:160
An empty list of filename strings was passed to the buffer.
Definition: diskbuffer2.h:40
Base class for all VideoBuffer exceptions.
Definition: videobuffer.h:153
A frame from a VideoBuffer.
Definition: videoframe.h:35
A frame from a DiskBuffer2.
Definition: diskbuffer2_frame.h:19
virtual bool frame_pending()
Is there another frame waiting in the buffer? By default, this always returns true, but if the VideoBufferFlags::OnEndOfBuffer setting is VideoBufferFlags::UnsetPending, this will return false after the last frame has been returned by get_frame()
Definition: diskbuffer2.h:102
A full image which manages its own data.
Definition: image.h:623
get_frame() was called when at the end of the buffer
Definition: diskbuffer2.h:64
virtual void seek_to(double t)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: diskbuffer2.h:241
Base class for all Image_IO exceptions.
Definition: load_and_save.h:27
virtual DiskBuffer2Frame< T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: diskbuffer2.h:173