scistag.mediastag.video_source_datastag.VideoSourceDataStag

class VideoSourceDataStag(connection, data_path)[source]

Bases: VideoSource

A video source which streams video data directly from a DataStag vault

Parameters
  • connection (DataStagConnection | None) – The connection from which the image is received. The local connection by default

  • data_path (str) – The data path within the connection

Methods

continue_video

Pauses the video

get_image

Returns the current image as np array

handle_datastag_image_changed

Called when ever the image changed

pause

Pauses the video

seek

Seeks to given video position :type position_s: float :param position_s: The new desired position :rtype: float :return: The real new position

set_filter

Assigns a filter which is assigned to every image received from the original video source.

start

Starts the video

stop

Stops the video

update_progress

Tries to update the videos' progress

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

_get_image_int(timestamp=None)[source]

Returns the current image as np array (internal function providing the raw data before filters etc. are applied) :type timestamp: float | None :param timestamp: The timestamp of the last image received :rtype: tuple[float, Image | None] :return: Updated timestamp, the image

continue_video()

Pauses the video

get_image(timestamp=None, wait=False, timeout_s=2.0)

Returns the current image as np array

Parameters
  • timestamp (float | None) – The timestamp of the last image received

  • wait (bool) – If set the function will wait for the next valid image

  • timeout_s (float) – The timeout in seconds before a TimeoutError exception will be raised. 2 seconds by default. If set to -1 the function will wait forever.

Return type

tuple[float, Image | None]

Returns

Updated timestamp, the image

handle_datastag_image_changed()[source]

Called when ever the image changed

pause()

Pauses the video

seek(position_s)

Seeks to given video position :type position_s: float :param position_s: The new desired position :rtype: float :return: The real new position

set_filter(image_filter)

Assigns a filter which is assigned to every image received from the original video source. For example call set_filter(Grayscale()) to convert the camera or video to grayscale. You can also assign an ImageFilterPipeline to combine multiple filters. :type image_filter: ImageFilter | None :param image_filter: The filter to assign or None to disable it

Return type

None

start()

Starts the video

stop()

Stops the video

update_progress()[source]

Tries to update the videos’ progress

Parameters
  • repeat – Defines if the video shall repeat when the end is reached

  • speed – The speed factor

Return type

bool

Returns

True if the progress was updated

auto_progress

If defined the get_image function is also allowed to update the video’s progress. Otherwise the managing control, e.g. the VideoPlayer is responsible to do so

duration

The video’s overall duration in seconds. 0 if a stream

fps

The videos frame per second count

image_filter: ImageFilter | None

A filter which shall be applied to every image received from the video before it’s returned

is_stream

Defines if the source is a continuous stream

last_raw_image: Image | None

The last raw image received internal

last_raw_image_timestamp: float

The last raw image’s time stamp

last_returned_image: Image | None

The last returned image (after applying filters etc.)

last_update_timestamp

Timestamp of the last update

position

The current position (in seconds)

repeat

The movie’s repeat mode

speed

The movie’s playback speed. 1.0 = 100%

start_timestamp

Timestamp when the playback started or continued

time_per_frame

The amount of seconds per frame (1/fps)

valid

Defines if there is a valid source

video_resolution

The video’s size in pixels