stream#

Module: stream.client#

FuryStreamClient(showm, *[, ...])

This obj is responsible to create a StreamClient.

FuryStreamInteraction(showm, *[, ...])

This obj.

callback_stream_client(stream_client)

This callback is used to update the image inside of the ImageManager instance

interaction_callback(circular_queue, showm, ...)

This callback is used to invoke vtk interaction events reading those events from the provided circular_queue instance

Module: stream.constants#

_CQUEUE_EVENT_IDs

_CQUEUE_INDEX_INFO

_CQUEUE

Module: stream.server#

Module: stream.server.async_app#

pcs

set() -> new empty set object set(iterable) -> new set object

set_weel(data, circular_queue)

set_mouse(data, circular_queue)

set_mouse_click(data, circular_queue)

3 | LeftButtonPressEvent 4 | LeftButtonReleaseEvent 5 | MiddleButtonPressEvent 6 | MiddleButtonReleaseEvent 7 | RightButtonPressEvent 8 | RightButtonReleaseEvent

get_app(*[, rtc_server, folder, ...])

Module: stream.server.main#

RTCServer(image_buffer_manager)

This Obj it's responsible to create the VideoStream for the WebRTCServer

web_server_raw_array(*[, image_buffers, ...])

This will create a streaming webserver running on the given port and host using RawArrays.

web_server(*[, image_buffer_names, ...])

This will create a streaming webserver running on the given port and host using SharedMemory.

Module: stream.tools#

GenericMultiDimensionalBuffer(*[, max_size, ...])

This implements a abstract (generic) multidimensional buffer.

RawArrayMultiDimensionalBuffer(max_size, *)

This implements a multidimensional buffer with RawArray.

SharedMemMultiDimensionalBuffer(max_size, *)

This implements a generic multidimensional buffer with SharedMemory.

GenericCircularQueue(*[, max_size, ...])

This implements a generic circular queue which works with shared memory resources.

ArrayCircularQueue(*[, max_size, dimension, ...])

This implements a MultiDimensional Queue which works with Arrays and RawArrays.

SharedMemCircularQueue(*[, max_size, ...])

This implements a MultiDimensional Queue which works with SharedMemory.

GenericImageBufferManager(*[, ...])

This implements a abstract (generic) ImageBufferManager with the n-buffer technique.

RawArrayImageBufferManager(*[, ...])

This implements an ImageBufferManager using RawArrays.

SharedMemImageBufferManager(*[, ...])

This implements an ImageBufferManager using the SharedMemory approach.

IntervalTimerThreading(seconds, callback, ...)

Implements a object with the same behavior of setInterval from Js

IntervalTimer(seconds, callback, *args, **kwargs)

A object that creates a timer that calls a function periodically.

remove_shm_from_resource_tracker()

Monkey-patch multiprocessing.resource_tracker so SharedMemory won't be tracked

Module: stream.widget#

Widget(showm, *[, ms_stream, ...])

This Obj it's able execute the fury streaming system using the SharedMemory object from Python multiprocessing.

check_port_is_available(host, port)

Check if a given port it's available

FuryStreamClient#

class fury.stream.client.FuryStreamClient(showm, *, max_window_size=None, use_raw_array=True, whithout_iren_start=False, num_buffers=2)[source]#

Bases: object

This obj is responsible to create a StreamClient.

cleanup()[source]#

Release the shared memory resources if necessary.

start(*, ms=0, use_asyncio=False)[source]#

Start the stream client.

Parameters:
msfloat, optional

positive number. This update the image buffer using a interval of ms milliseconds. If ms is 0 then the stream client will update the buffer after every Render event.

use_asynciobool, optional

If False then the stream client will update the image using a threading technique.

stop()[source]#

Stop the stream client.

FuryStreamInteraction#

class fury.stream.client.FuryStreamInteraction(showm, *, max_queue_size=50, use_raw_array=True, whithout_iren_start=False)[source]#

Bases: object

This obj. is responsible to manage the user interaction

cleanup()[source]#

Release the shared memory resources if necessary.

start(*, ms=3, use_asyncio=False)[source]#

Start the stream interaction client.

Parameters:
msfloat, optional

positive number greater than zero.

use_asynciobool, optional

If False then the interaction will be performed in a separate thread.

stop()[source]#

Stop the stream interaction client.

callback_stream_client#

fury.stream.client.callback_stream_client(stream_client)[source]#

This callback is used to update the image inside of the ImageManager instance

Parameters:
stream_clientStreamClient

interaction_callback#

fury.stream.client.interaction_callback(circular_queue, showm, iren, render_after)[source]#

This callback is used to invoke vtk interaction events reading those events from the provided circular_queue instance

Parameters:
circular_queueCircularQueue
showmShowmManager
irenvtkInteractor
render_afterbool, optional

If the render method should be called after an dequeue

_CQUEUE_EVENT_IDs#

fury.stream.constants._CQUEUE_EVENT_IDs#

_CQUEUE_INDEX_INFO#

fury.stream.constants._CQUEUE_INDEX_INFO#

_CQUEUE#

fury.stream.constants._CQUEUE#

pcs#

fury.stream.server.async_app.pcs#

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

set_weel#

fury.stream.server.async_app.set_weel(data, circular_queue)[source]#

set_mouse#

fury.stream.server.async_app.set_mouse(data, circular_queue)[source]#

set_mouse_click#

fury.stream.server.async_app.set_mouse_click(data, circular_queue)[source]#

3 | LeftButtonPressEvent 4 | LeftButtonReleaseEvent 5 | MiddleButtonPressEvent 6 | MiddleButtonReleaseEvent 7 | RightButtonPressEvent 8 | RightButtonReleaseEvent

get_app#

fury.stream.server.async_app.get_app(*, rtc_server=None, folder=None, circular_queue=None, image_buffer_manager=None, provides_mjpeg=False, broadcast=True)[source]#

RTCServer#

class fury.stream.server.main.RTCServer(image_buffer_manager)[source]#

Bases: object

This Obj it’s responsible to create the VideoStream for the WebRTCServer

async recv()[source]#

Return a VideoFrame to be used in the WebRTC Server

The frame will be created using the image stored in the shared memory

Returns:
frameVideoFrame
release()[source]#

Release the RTCServer

web_server_raw_array#

fury.stream.server.main.web_server_raw_array(*, image_buffers=None, info_buffer=None, queue_head_tail_buffer=None, queue_buffer=None, port=8000, host='localhost', provides_mjpeg=True, provides_webrtc=True, ms_jpeg=16, run_app=True)[source]#

This will create a streaming webserver running on the given port and host using RawArrays.

Parameters:
image_bufferslist of buffers

A list of buffers with each one containing a frame.

info_bufferbuffer

A buffer with the information about the current frame to be streamed and the respective sizes

queue_head_tail_bufferbuffer

If buffer is passed than this Obj will read a a already created RawArray.

queue_bufferbuffer

If queue_buffer is passed than this Obj will read a a already created RawArray containing the user interactions events stored in the queue_buffer.

portint, optional

Port to be used by the aiohttp server

hoststr, optional, default localhost

host to be used by the aiohttp server

provides_mjpegbool, default True

If a MJPEG streaming should be available. If True you can consume that through host:port/video/mjpeg or if you want to interact you can consume that through your browser http://host:port?encoding=mjpeg

provides_webrtcbool, default True

If a WebRTC streaming should be available. http://host:port

ms_jpegfloat, optional

This it’s used only if the MJPEG will be used. The ms_jpeg represents the amount of milliseconds between to consecutive calls of the jpeg encoding.

run_appbool, default True

This will run the aiohttp application. The False condition is used just to be able to test the server.

web_server#

fury.stream.server.main.web_server(*, image_buffer_names=None, info_buffer_name=None, queue_head_tail_buffer_name=None, queue_buffer_name=None, port=8000, host='localhost', provides_mjpeg=True, provides_webrtc=True, avoid_unlink_shared_mem=True, ms_jpeg=16, run_app=True)[source]#

This will create a streaming webserver running on the given port and host using SharedMemory.

Parameters:
image_buffers_namelist of str

A list of buffers with each one containing a frame.

info_buffer_namestr

A buffer with the information about the current frame to be streamed and the respective sizes

queue_head_tail_buffer_namestr, optional

If buffer is passed than this Obj will read a a already created RawArray.

buffer_namestr, optional

If queue_buffer is passed than this Obj will read a a already created RawArray containing the user interactions events stored in the queue_buffer.

portint, optional

Port to be used by the aiohttp server

hoststr, optional, default localhost

host to be used by the aiohttp server

provides_mjpegbool, default True

If a MJPEG streaming should be available. If True you can consume that through host:port/video/mjpeg or if you want to interact you can consume that through your browser http://host:port?encoding=mjpeg

provides_webrtcbool, default True

If a WebRTC streaming should be available. http://host:port

avoid_unlink_shared_membool, default False

If True, then this will apply a monkey-patch solution to a python>=3.8 core bug

ms_jpegfloat, optional

This it’s used only if the MJPEG will be used. The ms_jpeg represents the amount of milliseconds between to consecutive calls of the jpeg encoding.

run_appbool, default True

This will run the aiohttp application. The False condition is used just to be able to test the server.

GenericMultiDimensionalBuffer#

class fury.stream.tools.GenericMultiDimensionalBuffer(*, max_size=None, dimension=8)[source]#

Bases: ABC

This implements a abstract (generic) multidimensional buffer.

property buffer#
abstract cleanup()[source]#
abstract create_mem_resource()[source]#
get_start_end(idx)[source]#
abstract load_mem_resource()[source]#

RawArrayMultiDimensionalBuffer#

class fury.stream.tools.RawArrayMultiDimensionalBuffer(max_size, *, dimension=4, buffer=None)[source]#

Bases: GenericMultiDimensionalBuffer

This implements a multidimensional buffer with RawArray.

cleanup()[source]#
create_mem_resource()[source]#
load_mem_resource()[source]#

SharedMemMultiDimensionalBuffer#

class fury.stream.tools.SharedMemMultiDimensionalBuffer(max_size, *, dimension=4, buffer_name=None)[source]#

Bases: GenericMultiDimensionalBuffer

This implements a generic multidimensional buffer with SharedMemory.

cleanup()[source]#
create_mem_resource()[source]#
load_mem_resource()[source]#

GenericCircularQueue#

class fury.stream.tools.GenericCircularQueue(*, max_size=None, dimension=8, use_shared_mem=False, buffer=None, buffer_name=None)[source]#

Bases: ABC

This implements a generic circular queue which works with shared memory resources.

abstract cleanup()[source]#
abstract create_mem_resource()[source]#
abstract dequeue()[source]#
abstract enqueue(data)[source]#
property head#
abstract load_mem_resource()[source]#
set_head_tail(head, tail, lock=1)[source]#
property tail#

ArrayCircularQueue#

class fury.stream.tools.ArrayCircularQueue(*, max_size=10, dimension=6, head_tail_buffer=None, buffer=None)[source]#

Bases: GenericCircularQueue

This implements a MultiDimensional Queue which works with Arrays and RawArrays.

cleanup()[source]#
create_mem_resource()[source]#
dequeue()[source]#
enqueue(data)[source]#
load_mem_resource()[source]#

SharedMemCircularQueue#

class fury.stream.tools.SharedMemCircularQueue(*, max_size=10, dimension=6, head_tail_buffer_name=None, buffer_name=None)[source]#

Bases: GenericCircularQueue

This implements a MultiDimensional Queue which works with SharedMemory.

cleanup()[source]#
create_mem_resource()[source]#
dequeue()[source]#
enqueue(data)[source]#
is_unlocked()[source]#
load_mem_resource()[source]#
lock()[source]#
unlock()[source]#

GenericImageBufferManager#

class fury.stream.tools.GenericImageBufferManager(*, max_window_size=None, num_buffers=2, use_shared_mem=False)[source]#

Bases: ABC

This implements a abstract (generic) ImageBufferManager with the n-buffer technique.

async_get_jpeg(*, ms=33)[source]#
property buffer_index#
abstract cleanup()[source]#
abstract create_mem_resource()[source]#
get_current_frame()[source]#

Get the current frame from the buffer.

get_jpeg()[source]#

Returns a jpeg image from the buffer.

Returns:
bytes: jpeg image.
abstract load_mem_resource()[source]#
property next_buffer_index#
write_into(w, h, np_arr)[source]#

RawArrayImageBufferManager#

class fury.stream.tools.RawArrayImageBufferManager(*, max_window_size=(100, 100), num_buffers=2, image_buffers=None, info_buffer=None)[source]#

Bases: GenericImageBufferManager

This implements an ImageBufferManager using RawArrays.

cleanup()[source]#
create_mem_resource()[source]#
load_mem_resource()[source]#

SharedMemImageBufferManager#

class fury.stream.tools.SharedMemImageBufferManager(*, max_window_size=(100, 100), num_buffers=2, image_buffer_names=None, info_buffer_name=None)[source]#

Bases: GenericImageBufferManager

This implements an ImageBufferManager using the SharedMemory approach.

cleanup()[source]#

Release the resources used by the Shared Memory Manager

create_mem_resource()[source]#
load_mem_resource()[source]#

IntervalTimerThreading#

class fury.stream.tools.IntervalTimerThreading(seconds, callback, *args, **kwargs)[source]#

Bases: object

Implements a object with the same behavior of setInterval from Js

start()[source]#

Start the timer

stop()[source]#

Stop the timer

IntervalTimer#

class fury.stream.tools.IntervalTimer(seconds, callback, *args, **kwargs)[source]#

Bases: object

A object that creates a timer that calls a function periodically.

start()[source]#

Start the timer

stop()[source]#

Stop the timer

remove_shm_from_resource_tracker#

fury.stream.tools.remove_shm_from_resource_tracker()[source]#

Monkey-patch multiprocessing.resource_tracker so SharedMemory won’t be tracked

Notes

More details at: https://bugs.python.org/issue38119

Widget#

class fury.stream.widget.Widget(showm, *, ms_stream=33, ms_interaction=33, host='localhost', port=None, encoding='mjpeg', ms_jpeg=33, queue_size=20)[source]#

Bases: object

This Obj it’s able execute the fury streaming system using the SharedMemory object from Python multiprocessing.

cleanup()[source]#

Release the shared memory

property command_string#

Return the command string to start the server

Returns:
command_stringstr
display(*, height=150)[source]#

Start the server and display the url in an iframe

return_iframe(*, height=200)[source]#

Return the jupyter div iframe used to show the stream

run_command()[source]#

Evaluate the command string to start the server

start(*, use_asyncio=False)[source]#

Start the fury client and the interaction client and return the url

Parameters:
use_asynciobool, optional

If should use the asyncio version of the server. Default is False.

stop()[source]#

Stop the streaming server and release the shared memory

property url#

Return the url to access the server

check_port_is_available#

fury.stream.widget.check_port_is_available(host, port)[source]#

Check if a given port it’s available

Parameters:
hoststr
portint
Returns:
availablebool