ocvu.video module¶
Video object
-
class
ocvu.video.
Video
(filepath, grayscale=False)[source]¶ Bases:
object
OpenCV Video.
-
fourcc
¶ 4-character code of codec.
-
fps
¶ Frames per second.
-
frame_number
¶ Number of the frame that will be read next.
-
frames
¶ Returns an iterator with all frames.
-
generate_background_model
(step=None, end=None, mse_min=50)[source]¶ Generates a background model using the median.
Only sufficiently different frames are considered, using the mean squared error method.
Parameters: - step – Step to iterate through the video. Default is video FPS rate.
- end – Last frame to consider. Default is 2/3 of video length.
- mse_min – The minimum error at wich the frame is selected. The lower the error, the more similar the two images are.
-
nframes
¶ Returns the total number of frames.
-
read_frame
(number=None, grayscale=False)[source]¶ Reads the current frame and returns it. You can also ask for a specific frame. Returns a Frame object.
Parameters: - number (int) – Number of the frame desired. If None, reads the current one.
- grayscale (bool) – Convert the frame read to grayscale.
-
show_frame
(number=None, window=None, resize=False)[source]¶ Shows frame number in an OpenCV window. Returns the frame read.
-
size
¶ Returns the size of the video frames: (width, height).
-