robotic_sdk.data_ingestion package
Submodules
robotic_sdk.data_ingestion.data_iterator module
- class robotic_sdk.data_ingestion.data_iterator.FrameIterator(video_s3_path, local_dir='/tmp/videos/video-stream/', start=0, end=None, freq=1, dsize=(640, 480))
Bases:
objectA class to iterate over frames of a video file downloaded from an S3 bucket.
- __init__(video_s3_path, local_dir='/tmp/videos/video-stream/', start=0, end=None, freq=1, dsize=(640, 480))
Initializes the FrameIterator with the given parameters and downloads the video file.
- Parameters:
video_s3_path (str) – The S3 path to the video file.
local_dir (str, optional) – The local directory to download the video file to.
start (int, optional) – Starting frame number. Defaults to 0.
end (int, optional) – Ending frame number. Defaults to None.
freq (int, optional) – Frequency of frames to be iterated. Defaults to 1.
dsize (tuple, optional) – Desired size of the frames. Defaults to (640, 480).
- download()
Downloads the video file from the S3 bucket to the local directory.
- get_frame()
Retrieves the next frame from the video file.
- Returns:
The next frame in the video, resized to the desired size. None: If the end of the video is reached or the frame number is out of range.
- Return type:
numpy.ndarray
robotic_sdk.data_ingestion.data_loader module
- robotic_sdk.data_ingestion.data_loader.download_video_file(s3_path, local_dir)
Downloads a video file from an S3 bucket to a local directory.
- Parameters:
s3_path (str) – The S3 path to the video file.
local_dir (str) – The local directory to download the video file to.
- Returns:
The local path to the downloaded video file.
- Return type:
str
robotic_sdk.data_ingestion.data_stream module
- class robotic_sdk.data_ingestion.data_stream.Stream(video_s3_path, local_dir)
Bases:
objectClass to handle video streaming from an S3 bucket.
- __init__(video_s3_path, local_dir)
Initializes the Stream object with the S3 path and local directory.
- Parameters:
video_s3_path (str) – The S3 path to the video file.
local_dir (str) – The local directory to download the video file to.
- download()
Downloads the video file from the S3 bucket to the local directory.
- get_frame()
Gets the last frame of the video stream.
- Returns:
Base64 encoded string of the last frame.
- Return type:
str
- is_streaming()
- start_streaming()
Starts the streaming thread.
- stop_streaming()
Stops the streaming thread.
- stream()
Streams the video file, encoding each frame to a Base64 string.