videoflow.producers package¶
This package contains a collection of producers that implement the videoflow.core.node.ProducerNode
interface
Submodules¶
videoflow.producers.basic module¶
-
class
videoflow.producers.basic.
IntProducer
(start_value: int = 0, end_value: int = None, wait_time_in_seconds: float = 0, fps=-1)¶ Bases:
videoflow.core.node.ProducerNode
Each time the
next
method is called, produces the next integer in the sequence betweenstart_value
andend_value
.If
wait_time_in_seconds
is greater than zero, it sleeps for the specified amount of seconds each timenext()
is called.If
fps
is given a value greater than 0,fps
overrides the value ofwait_time_in_seconds
-
next
()¶ - Returns:
next: an integer
-
videoflow.producers.video module¶
-
class
videoflow.producers.video.
ImageFolderReader
¶ Bases:
videoflow.core.node.ProducerNode
Reads from a folder of images and returns them one by one. Passes through images in alphabetical order.
-
close
()¶ This method is called by the task running after finishing doing all consuming, processing or producing because of and end signal receival. Should be used to close any resources that were opened by the open() method, such as files, tensorflow sessions, etc.
-
next
() → numpy.core.multiarray.array¶ Returns next produced element.
Raises
StopIteration
after the last element has been produced and a call to self.next happens.
-
open
()¶ This method is called by the task runner before doing any consuming, processing or producing. Should be used to open any resources that will be needed during the life of the task, such as opening files, tensorflow sessions, etc.
-
-
class
videoflow.producers.video.
ImageProducer
(image_path: str)¶ Bases:
videoflow.core.node.ProducerNode
Reads a single image and produces it
-
close
()¶ This method is called by the task running after finishing doing all consuming, processing or producing because of and end signal receival. Should be used to close any resources that were opened by the open() method, such as files, tensorflow sessions, etc.
-
next
() → numpy.core.multiarray.array¶ Returns image in RGB format.
-
open
()¶ This method is called by the task runner before doing any consuming, processing or producing. Should be used to open any resources that will be needed during the life of the task, such as opening files, tensorflow sessions, etc.
-
-
class
videoflow.producers.video.
VideoDeviceReader
(device_id: int, nb_frames: int = -1, nb_retries=0)¶ Bases:
videoflow.producers.video.VideostreamReader
Opens a video capture object and returns subsequent frames from the video device each time
next
is called.- Arguments:
device_id: id of the video device connected to the computer
nb_frames: number of frames to process. -1 means all of them
-
class
videoflow.producers.video.
VideoFileReader
(video_file: str, nb_frames=-1)¶ Bases:
videoflow.producers.video.VideostreamReader
Opens a video capture object and returns subsequent frames from the video file each time
next
is called.- Arguments:
video_file: path to video file
nb_frames: number of frames to process. -1 means all of them
-
class
videoflow.producers.video.
VideoFolderReader
¶ Bases:
videoflow.core.node.ProducerNode
Reads videos from a folder of videos and returns the frames of the videos one by one. Passes through videos in alphabetical order.
-
close
()¶ This method is called by the task running after finishing doing all consuming, processing or producing because of and end signal receival. Should be used to close any resources that were opened by the open() method, such as files, tensorflow sessions, etc.
-
next
() → numpy.core.multiarray.array¶ Returns next produced element.
Raises
StopIteration
after the last element has been produced and a call to self.next happens.
-
open
()¶ This method is called by the task runner before doing any consuming, processing or producing. Should be used to open any resources that will be needed during the life of the task, such as opening files, tensorflow sessions, etc.
-
-
class
videoflow.producers.video.
VideoUrlReader
(url: str, nb_frames: int = -1, nb_retries=0)¶ Bases:
videoflow.producers.video.VideostreamReader
Opens a video capture object and returns subsequent frames from the video url each time
next
is called.- Arguments:
device_id: id of the video device connected to the computer
nb_frames: number of frames to process. -1 means all of them
-
videoflow.producers.video.
VideofileReader
¶
-
class
videoflow.producers.video.
VideostreamReader
(url_or_deviceid, swap_channels=True, nb_frames=-1, nb_retries=0)¶ Bases:
videoflow.core.node.ProducerNode
Reader of video streams, using
cv2
- Arguments:
url_or_deviceid: (int or str) The url, filesystem path or id of the video stream.
swap_channels: if True, it will change channels from BGR to RGB
nb_frames: (int) The number of frames when to stop. -1 never stops
nb_retries: (int) If there are errors reading the stream, how many times to retry.
-
close
()¶ Releases the video stream object
-
next
()¶ - Returns:
frame no / index : integer value of the frame read
frame: np.array of shape (h, w, 3)
- Raises:
StopIteration: after it finishes reading the videofile or when it reaches the specified number of frames to process, or if it reaches the number of retries wihout success.
-
open
()¶ Opens the video stream