stream
#
Module: stream.client
#
|
This obj is responsible to create a StreamClient. |
|
This obj. |
|
This callback is used to update the image inside of the ImageManager instance |
|
This callback is used to invoke vtk interaction events reading those events from the provided circular_queue instance |
Module: stream.constants
#
CQUEUE_EVENT_IDS(mouse_weel, mouse_move, mouse_ids, left_btn_press, left_btn_release, middle_btn_press, middle_btn_release, right_btn_press, right_btn_release) |
|
CQUEUE_INDEX_INFO(weel, x, y, ctrl, shift, user_timestamp) |
|
CQUEUE(dimension, event_ids, index_info) |
Module: stream.server
#
Module: stream.server.async_app
#
set() -> new empty set object set(iterable) -> new set object |
|
|
|
|
|
|
3 | LeftButtonPressEvent 4 | LeftButtonReleaseEvent 5 | MiddleButtonPressEvent 6 | MiddleButtonReleaseEvent 7 | RightButtonPressEvent 8 | RightButtonReleaseEvent |
|
Module: stream.server.main
#
|
This Obj it's responsible to create the VideoStream for the WebRTCServer |
|
This will create a streaming webserver running on the given port and host using RawArrays. |
|
This will create a streaming webserver running on the given port and host using SharedMemory. |
Module: stream.tools
#
|
This implements a abstract (generic) multidimensional buffer. |
|
This implements a multidimensional buffer with RawArray. |
|
This implements a generic multidimensional buffer with SharedMemory. |
|
This implements a generic circular queue which works with shared memory resources. |
|
This implements a MultiDimensional Queue which works with Arrays and RawArrays. |
|
This implements a MultiDimensional Queue which works with SharedMemory. |
|
This implements a abstract (generic) ImageBufferManager with the n-buffer technique. |
|
This implements an ImageBufferManager using RawArrays. |
|
This implements an ImageBufferManager using the SharedMemory approach. |
|
Implements a object with the same behavior of setInterval from Js |
|
A object that creates a timer that calls a function periodically. |
Monkey-patch multiprocessing.resource_tracker so SharedMemory won't be tracked |
Module: stream.widget
#
|
This Obj it's able execute the fury streaming system using the SharedMemory object from Python multiprocessing. |
|
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.
- __init__(showm, *, max_window_size=None, use_raw_array=True, whithout_iren_start=False, num_buffers=2)[source]#
A StreamClient extracts a framebuffer from the OpenGL context and writes into a shared memory resource.
- Parameters:
showm (ShowManager) –
max_window_size (tuple of ints, optional) – This allows resize events inside of the FURY window instance. Should be greater than the window size.
use_raw_array (bool, optional) – If False then FuryStreamClient will use SharedMemory instead of RawArrays. Notice that Python >=3.8 it’s a requirement to use SharedMemory)
whithout_iren_start (bool, optional) – Sometimes you can’t initiate the vtkInteractor instance.
num_buffers (int, optional) – Number of buffers to be used in the n-buffering technique.
- start(*, ms=0, use_asyncio=False)[source]#
Start the stream client.
- Parameters:
ms (float, 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_asyncio (bool, optional) – If False then the stream client will update the image using a threading technique.
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
- __init__(showm, *, max_queue_size=50, use_raw_array=True, whithout_iren_start=False)[source]#
Initialize the StreamInteraction obj.
- Parameters:
showm (ShowmManager) –
max_queue_size (int, optional) – maximum number of events to be stored.
use_raw_array (bool, optional) – If False then a CircularQueue will be created using SharedMemory instead of RawArrays. Notice that Python >=3.8 it’s requirement to use SharedMemory.
whithout_iren_start (bool, optional) – Set that to True if you can’t initiate the vtkInteractor instance.
callback_stream_client#
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_queue (CircularQueue) –
showm (ShowmManager) –
iren (vtkInteractor) –
render_after (bool, optional) – If the render method should be called after an dequeue
_CQUEUE_EVENT_IDs#
- fury.stream.constants._CQUEUE_EVENT_IDs()#
CQUEUE_EVENT_IDS(mouse_weel, mouse_move, mouse_ids, left_btn_press, left_btn_release, middle_btn_press, middle_btn_release, right_btn_press, right_btn_release)
_CQUEUE_INDEX_INFO#
- fury.stream.constants._CQUEUE_INDEX_INFO()#
CQUEUE_INDEX_INFO(weel, x, y, ctrl, shift, user_timestamp)
_CQUEUE#
- fury.stream.constants._CQUEUE()#
CQUEUE(dimension, event_ids, index_info)
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#
set_mouse#
set_mouse_click#
get_app#
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
- __init__(image_buffer_manager)[source]#
Initialize the RTCServer
- Parameters:
image_buffer_manager (ImageBufferManager) –
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_buffers (list of buffers) – A list of buffers with each one containing a frame.
info_buffer (buffer) – A buffer with the information about the current frame to be streamed and the respective sizes
queue_head_tail_buffer (buffer) – If buffer is passed than this Obj will read a a already created RawArray.
queue_buffer (buffer) – 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.
port (int, optional) – Port to be used by the aiohttp server
host (str, optional, default localhost) – host to be used by the aiohttp server
provides_mjpeg (bool, 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_webrtc (bool, default True) – If a WebRTC streaming should be available. http://host:port
ms_jpeg (float, 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_app (bool, 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_name (list of str) – A list of buffers with each one containing a frame.
info_buffer_name (str) – A buffer with the information about the current frame to be streamed and the respective sizes
queue_head_tail_buffer_name (str, optional) – If buffer is passed than this Obj will read a a already created RawArray.
buffer_name (str, 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.
port (int, optional) – Port to be used by the aiohttp server
host (str, optional, default localhost) – host to be used by the aiohttp server
provides_mjpeg (bool, 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_webrtc (bool, default True) – If a WebRTC streaming should be available. http://host:port
avoid_unlink_shared_mem (bool, default False) – If True, then this will apply a monkey-patch solution to a python>=3.8 core bug
ms_jpeg (float, 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_app (bool, default True) – This will run the aiohttp application. The False condition is used just to be able to test the server.
GenericMultiDimensionalBuffer
#
RawArrayMultiDimensionalBuffer
#
- class fury.stream.tools.RawArrayMultiDimensionalBuffer(max_size, *, dimension=4, buffer=None)[source]#
Bases:
GenericMultiDimensionalBuffer
This implements a multidimensional buffer with RawArray.
- __init__(max_size, *, dimension=4, buffer=None)[source]#
Stream system uses that to implement the CircularQueue with shared memory resources.
- Parameters:
max_size (int, optional) – If buffer_name or buffer was not passed then max_size it’s mandatory
dimension (int, default 8) –
buffer (buffer, optional) – If buffer is not passed to __init__ then the multidimensional buffer obj will create a new RawArray object to store the data If buffer is passed than this Obj will read a a already created RawArray
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.
- __init__(*, max_size=None, dimension=8, use_shared_mem=False, buffer=None, buffer_name=None)[source]#
Initialize the circular queue.
- Parameters:
max_size (int, optional) – If buffer_name or buffer was not passed then max_size it’s mandatory. This will be used to construct the multidimensional buffer
dimension (int, default 8) – This will be used to construct the multidimensional buffer
use_shared_mem (bool, default False) – If the multidimensional memory resource should create or read using SharedMemory or RawArrays
buffer (RawArray, optional) –
buffer_name (str, optional) –
- property head#
- 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.
- __init__(*, max_size=10, dimension=6, head_tail_buffer=None, buffer=None)[source]#
Stream system uses that to implement user interactions
- Parameters:
max_size (int, optional) – If buffer_name or buffer was not passed then max_size it’s mandatory. This will be used to construct the multidimensional buffer
dimension (int, default 8) – This will be used to construct the multidimensional buffer
head_tail_buffer (buffer, optional) – If buffer is not passed to __init__ then this obj will create a new RawArray to store head and tail position.
buffer (buffer, optional) – If buffer is not passed to __init__ then the multidimensional buffer obj will create a new RawArray to store the data
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.
- __init__(*, max_window_size=None, num_buffers=2, use_shared_mem=False)[source]#
Initialize the ImageBufferManager.
- property buffer_index#
- property next_buffer_index#
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.
- __init__(*, max_window_size=(100, 100), num_buffers=2, image_buffers=None, info_buffer=None)[source]#
Initialize the ImageBufferManager.
- Parameters:
max_window_size (tuple of ints, optional) – This allows resize events inside of the FURY window instance. Should be greater than the window size.
num_buffers (int, optional) – Number of buffers to be used in the n-buffering technique.
info_buffer (buffer, optional) – A buffer with the information about the current frame to be streamed and the respective sizes
image_buffers (list of buffers, optional) – A list of buffers with each one containing a frame.
IntervalTimerThreading
#
- class fury.stream.tools.IntervalTimerThreading(seconds, callback, *args, **kwargs)[source]#
Bases:
object
Implements a object with the same behavior of setInterval from Js
- __init__(seconds, callback, *args, **kwargs)[source]#
- Parameters:
seconds (float) – A positive float number. Represents the total amount of seconds between each call
callback (function) – The function to be called
*args (args) – args to be passed to callback
**kwargs (kwargs) – kwargs to be passed to callback
Examples
def callback(arr): arr += [len(arr)] arr = [] interval_timer = tools.IntervalTimer(1, callback, arr) interval_timer.start() time.sleep(5) interval_timer.stop() # len(arr) == 5
References
[1] https://stackoverflow.com/questions/3393612/run-certain-code-every-n-seconds
IntervalTimer
#
- class fury.stream.tools.IntervalTimer(seconds, callback, *args, **kwargs)[source]#
Bases:
object
A object that creates a timer that calls a function periodically.
- __init__(seconds, callback, *args, **kwargs)[source]#
- Parameters:
seconds (float) – A positive float number. Represents the total amount of seconds between each call
callback (function) – The function to be called
*args (args) – args to be passed to callback
**kwargs (kwargs) – kwargs to be passed to callback
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.
- __init__(showm, *, ms_stream=33, ms_interaction=33, host='localhost', port=None, encoding='mjpeg', ms_jpeg=33, queue_size=20)[source]#
Initialize the widget.
- Parameters:
showm (ShowmManager) –
ms_stream (float, optional) – time in mileseconds between each frame buffer update.
ms_interaction (float, optional) – time in mileseconds between each user interaction update.
host (str, optional) –
port (int, optional) –
encoding (str, optional) – If should use MJPEG streaming or WebRTC.
ms_jpeg (float, 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.
queue_size (int, optional) – maximum number of user interactions to be stored
- property command_string#
Return the command string to start the server
- Returns:
command_string
- Return type:
- start(*, use_asyncio=False)[source]#
Start the fury client and the interaction client and return the url
- Parameters:
use_asyncio (bool, optional) – If should use the asyncio version of the server. Default is False.
- property url#
Return the url to access the server