vuba.Video.read
- Video.read(*args, **kwargs)[source]
Read single or multiple frames from the provided footage.
Note that reading multiple frames follows slice behaviour, whereby there is a ‘start’, ‘stop’ and ‘step’. However steps will only give a performance uplift for reading images stored as individual files (e.g. multiple pngs). If you are reading from videos, the read time will be the same as if you were reading all the frames between ‘start’ and ‘stop’. This is because it is faster to pass on frames that don’t match the step size, than it is to repeatedly locate the correct frames by index in the video file.
- Parameters
frames (* For multiple) –
- indexint
Index of frame in footage to read.
- grayscalebool
Whether to convert frame to grayscale.
frames –
- startint
Index of frame to start reading from.
- stopint
Index of frame to stop reading at.
- stepint
Step size.
- low_memorybool
Whether to import frames into RAM, default is True i.e. not to.
- grayscale
Whether to convert frames to grayscale.
- Return type
- Returns
For single frames –
- framendarray
Frame at the given index.
For multiple frames –
- framesFrames
Container that will either supply the frames from an ndarray or from a generator. Note that this container contains both a len and iter method. For the latter, a new generator is created upon calling the method if the frames have not been imported into memory. This is to maintain implementation parity with the in-memory container.
- Raises
ValueError – If the supplied indices are not within the available range of the selected footage, or if there is a missing required argument.
Examples
For example usage of this method please see example scripts located at
examples/reading
.