scistag.mediastag.camera_cv2.CameraCv2¶
- class CameraCv2(source)[source]¶
Bases:
VideoSourceCameraA camera source wrapping OpenCV’s camera access capabilities
Initializer
- Parameters
source (int | str) – The camera source. When a number is passed it will be interpreted as “web cam” index, e.g. 0,
otherwise it will be handled as gstreamer pipeline definition.
Methods
Redirects the camera's data into a local or remote DataStag storage
Pauses the video
Returns the global name of a local camera
Returns the current image as np array
Returns a unique name for a local camera at given source IF the camera is also registered and is usable
Returns if a camera with given source was registered
Returns a unique name for a local camera at given source
Tries to fetch data from the camera
Initializes the camera. Could be executed in another thread, lock data
Forwards the new camera image into callback functions and/or database targets
Pauses the video
Redirects the camera's stream into the vault :type index:
int:param index: The internal indexSeeks to given video position :type position_s:
float:param position_s: The new desired position :rtype:float:return: The real new positionAssigns a filter which is assigned to every image received from the original video source.
Updates the current image
Starts the camera
Stops the camera thread
Tries to update the videos' progress
Attributes
Local camera, e.g.
Name definition of the local camera's type
__dict____doc____module____weakref__list of weak references to the object (if defined)
The camera's source as unique identifier
- _get_image_int(timestamp=None)¶
Returns the most recent image and it’s time stamp
- add_redirect(target, timeout_s=5.0)¶
Redirects the camera’s data into a local or remote DataStag storage
- Parameters
called.
- continue_video()¶
Pauses the video
- classmethod get_camera_name(index)¶
Returns the global name of a local camera
- get_image(timestamp=None, wait=False, timeout_s=2.0)¶
Returns the current image as np array
- Parameters
- Return type
- Returns
Updated timestamp, the image
- classmethod get_local_camera(source)¶
Returns a unique name for a local camera at given source IF the camera is also registered and is usable
- classmethod get_local_camera_exists(source)¶
Returns if a camera with given source was registered
- classmethod get_local_camera_name(source)¶
Returns a unique name for a local camera at given source
- handle_initialize_camera()[source]¶
- Initializes the camera. Could be executed in another thread, lock data
accordingly.
Overwrite this with your initialization code.
- handle_redirections()¶
Forwards the new camera image into callback functions and/or database targets
- pause()¶
Pauses the video
- redirect_to_vault(index)¶
Redirects the camera’s stream into the vault :type index:
int:param index: The internal index
- 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
- set_image(timestamp, image)¶
Updates the current image
- start()¶
Starts the camera
- Return type
- Returns
The camera object
- stop()¶
Stops the camera thread
- Return type
- Returns
The camera object
- update_progress()¶
Tries to update the videos’ progress
- Return type
- Returns
True if the progress was updated
- LOCAL_CAMERA_STREAM_IDENTIFIER = 'streams.cameras.camera_'¶
Local camera, e.g. a webcam connected to the hosting PC directly
- LOCAL_CAMERA_STREAM_IDENTIFIER_TYPE = '.type'¶
Name definition of the local camera’s type
- _lock¶
Access lock
- _remote_thread¶
The remote thread
- 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_update_timestamp¶
Timestamp of the last update
- position¶
The current position (in seconds)
- redirections¶
Targets the camera image shall be redirected to
- repeat¶
The movie’s repeat mode
- speed¶
The movie’s playback speed. 1.0 = 100%
- start_timestamp¶
Timestamp when the playback started or continued
- started¶
Defines if the remote thread was started
- 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