towhee.functional.mixins.computer_vision.ComputerVisionMixin¶
- class towhee.functional.mixins.computer_vision.ComputerVisionMixin[source]¶
Bases:
object
Mixin for computer vision problems.
Methods
Produce a CV2 imshow window.
Read images from a camera.
Load a video as a DataCollection.
Encode a video; with audio if provided.
- image_imshow(title='image')[source]¶
Produce a CV2 imshow window.
- Parameters:
title (str, optional) – The title for the image. Defaults to ‘image’.
- classmethod read_camera(device_id=0, limit=-1)[source]¶
Read images from a camera.
- Parameters:
device_id (int, optional) – The camera device ID. Defaults to 0.
limit (int, optional) – The amount of images to capture. Defaults to -1.
- Returns:
Collection with images.
- Return type:
- classmethod read_video(path, format='rgb24')[source]¶
Load a video as a DataCollection.
- Parameters:
path (str) – The path of the video.
format (str, optional) – The color format of video. Defaults to ‘rgb24’.
- Returns:
DataCollection with the video.
- Return type:
- to_video(output_path, codec=None, rate=None, width=None, height=None, format=None, template=None, audio_src=None)[source]¶
Encode a video; with audio if provided.
- Parameters:
output_path (str) – Path to output the video to.
codec (str, optional) – Which codec to use for encoding. Defaults to None.
rate (int, optional) – The framrate of the video. Defaults to None.
width (int, optional) – The width of the video image. Defaults to None.
height (int, optional) – The height of the video image. Defaults to None.
format (str, optional) – The color format of the video. Defaults to None.
template (str, optional) – The template video stream of the ouput video stream. Defaults to None.
audio_src (str, optional) – Audio path to include in video. Defaults to None.