sksurgeryimage.acquire.video_source module

Module for video source acquisition. Classes capture data from a video source into a numpy array.

class sksurgeryimage.acquire.video_source.TimestampedVideoSource(source_num_or_file, dims=None)[source]

Bases: object

Capture and store data from camera/file source. Augments the cv2.VideoCapture() to provide passing of camera dimensions in constructor, and storage of frame data.

grab()[source]

Call the cv2.VideoCapture grab function and get a timestamp.

isOpened()[source]

Call the cv2.VideoCapture isOpened function.

read()[source]

Do a grab(), then retrieve() operation.

release()[source]

Release the cv2.VideoCapture source.

retrieve()[source]

Call the cv2.VideoCapture retrieve function and store the returned frame.

set_resolution(width: int, height: int)[source]

Set the resolution of the input source.

Parameters:
  • width (int) – Width
  • height (int) – Height
Raises:

ValueError – If resolution is not supported.

class sksurgeryimage.acquire.video_source.VideoSourceWrapper[source]

Bases: object

Wrapper for multiple TimestampedVideoSource objects.

add_camera(camera_number, dims=None)[source]

Create VideoCapture object from camera and add it to the list of sources.

Parameters:
  • camera_number – integer camera number
  • dims – (width, height) as integer numbers of pixels
add_file(filename, dims=None)[source]

Create videoCapture object from file and add it to the list of sources.

Parameters:
  • filename – a string containing a valid file path
  • dims – (width, height) as integer numbers of pixels
add_source(camera_num_or_file, dims=None)[source]
Add a video source (camera or file) to the list of sources.
Parameters:
  • camera_num_or_file – either an integer camera number or filename
  • dims – (width, height) as integer numbers of pixels
are_all_sources_open()[source]

Check all input sources are active/open.

get_next_frames()[source]

Do a grab() operation for each source, followed by a retrieve().

grab()[source]

Perform a grab() operation for each source

release_all_sources()[source]

Close all camera/file sources.

retrieve()[source]

Perform a retrieve operation for each source. Should only be run after a grab() operation.

:returns list of views on frames