Package pyvision :: Package types :: Module Video :: Class VideoFromImages
[hide private]
[frames] | no frames]

Class VideoFromImages

source code

    object --+    
             |    
VideoInterface --+
                 |
                VideoFromImages

This class allows the user to treat a directory of images as a video. It is assumed that the files in the directory are named as follows: {prefix}{num}.{ext} where prefix is any string that is constant for all the files, ext is the file extension/type like jpg, png, etc. num is a zero-padded number like 0001, 0002, ...

note: the amount of padded zeros is the minimum required based on the length (num frames) in the video, unless a specific padding is specified. So if you only had 120 frames, then it would be 001, 002,...120.

We assume the frames are sequential with no gaps, and start at number startnum (with appropriate padding).

Instance Methods [hide private]
 
__init__(self, dirname, numframes, prefix='frame', ext='jpg', pad=None, startnum=1, size=None)
The file names are of the format {prefix}{zero-padded num}.
source code
 
query(self)
Must be overridden to implement the specific frame-grabbing required by different video sources.
source code
 
__iter__(self)
Return an iterator for this video
source code

Inherited from VideoInterface: grab, next, play, resize

Inherited from VideoInterface (private): _pauseAndPlay

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dirname, numframes, prefix='frame', ext='jpg', pad=None, startnum=1, size=None)
(Constructor)

source code 

The file names are of the format {prefix}{zero-padded num}.{ext}, the amount of zero-padding is determined automatically based on numframes. If there is additional zero-padding required, put it in the prefix. Example: a directory with images: vid_t1_s1_f001.jpg, ..., vid_t1_s1_f999.jpg would have prefix="vid_t1_s1_f", startnum=1, numframes=999, ext="jpg"

Parameters:
  • dirname - directory where the images comprising the video exist
  • numframes - the number of frames in the video...0 to numframes will be read. specify None to read all images in directory, in which case you must specify a value for the pad parameter.
  • prefix - a string which remains as a constant prefix to all frames in video
  • ext - the extension of the images, like jpg, png, etc. Do not include the dot.
  • pad - the padding (like string.zfill(x)) used on the sequential numbering of the input files. Specify None, and the padding will be determined based on length of numframes. (So if numframes = 1234, then pad=4, 0001,0002,...1234)
  • startnum - the starting number of the first frame, defaults to 1
  • size - the optional width,height to resize the input frames
Overrides: object.__init__

query(self)

source code 

Must be overridden to implement the specific frame-grabbing required by different video sources.

Overrides: VideoInterface.query
(inherited documentation)

__iter__(self)

source code 

Return an iterator for this video

Overrides: VideoInterface.__iter__