ON THIS PAGE

  • Events
  • Out of the box Events
  • Custom Events

Events

Out of the box Events

The robothubsupport three basic use cases
  • Send one image
  • Send one image with additional images zipped and send as an attachment
  • Send a video
module

robothub.events

variable
function
send_image_event(image: Union [ np.ndarray , bytes ], title: str, device_id: str = None, metadata: Optional [ dict ] = None, tags: List [ str ] = None, mjpeg_quality = 98, encode = False) -> Optional[str]: Optional[str]
Send a single image frame event to RH.

:param image: The image to send.
:param title: The title of the event.
:param device_id: The device ID to associate with the event.
:param metadata: A dictionary of metadata to associate with the event.
:param tags: A list of tags to associate with the event.
:param mjpeg_quality: The JPEG quality to use when encoding.
:param encode: Whether to encode the image as a JPEG before sending.
:return: The event ID. None if the event failed to send.
function
send_frame_event_with_zipped_images(cv_frame: np.ndarray, files: list, title: str, device_id: str, tags: List [ str ] = None, metadata: Optional [ dict ] = None, encode: bool = False, mjpeg_quality = 98) -> Optional[str]: Optional[str]
Send a collection of images as a single event to RH.

:param cv_frame: The main image frame to send.
:param files: A list of images to zip and send.
:param title: The title of the event.
:param device_id: The device ID to associate with the event.
:param tags: A list of tags to associate with the event.
:param metadata: A dictionary of metadata to associate with the event.
:param encode: Whether to encode the images as JPEGs before sending.
:param mjpeg_quality: The JPEG quality to use when encoding.
:return: The event ID. None if the event failed to send.
function
send_video_event(video: bytes | str, title: str, metadata: Optional [ dict ] = None) -> Optional[str]: Optional[str]
Send a video event to RH. The video can be a path to a video file or a bytes object.

:param video: Path to a video file or a bytes object.
:param title: Title of the video event.
:param metadata: Overlay metadata to be displayed on the video.
:return: The event ID. None if the event failed to send.

Custom Events

You can use the low level API to build and send a custom Event. Example:
Python
1import robothub as rh
2event: FutureEvent = rh.EVENTS.prepare()
3event.set_tags(["video", "interesting situation"])
4event.add_video(video_as_bytes, filename=video_file_name)
5event.set_title(f"Video Event")
6event.add_file(support_file.getvalue(), name='metadata.zip', filename='metadata.zip')
7rh.EVENTS.upload(event)
where support_file.getvalue() returns bytesrepresentation of a zipfile.ZipFile object
class

robothub.robothub_core_wrapper.events.FutureEvent

variable
id
ID of the Event
variable
folder_path
Path to the folder of the Event in the App's container. Added frames, files & videos are stored in this folder.
method
variable
title
Title of the Event in the Cloud. Set to "Event" + UUID by default.
method
add_video(self, _bytes: bytes | bytearray, name: str | None = None, metadata: dict | None = None, filename: str | None = None, camera_serial: str | None = None)
Adds a video to the Event.

@param _bytes: Bytes of the encoded video. Must be H264 format.
@type _bytes: bytes | bytearray
@param name: Optional - Name of the video
@type name: str | NoneType
@param metadata: Optional - Metadata to be overlayed over the video. List length must be equal to number of frames in the video.
@type metadata: list
@param filename: Optional - can define name of the video file on Host.
@type filename: str | NoneType
@param camera_serial: Optional - Serial number (MxID) of camera that took the video
@type camera_serial: str
method
add_frame(self, _bytes, camera_serial: str | None = None, name: str | None = None, metadata: dict | None = None, filename: str | None = None)
Adds a frame to the Event.

@param _bytes: Bytes of the encoded frame
@type _bytes: bytes | bytearray
@param camera_serial: Optional - Serial number (MxID) of camera that took the frame
@type camera_serial: str
@param name: Optional - Name of the frame
@type name: str | NoneType
@param metadata: Optional - Metadata to be overlayed over the frame
@type metadata: list
@param filename: Optional - can define name of the frame file on Host.
@type filename: str | NoneType
method
add_file(self, _bytes, name: str | None = None, filename: str | None = None)
Adds a file to the Event.

@param _bytes: Bytes of the file.
@type _bytes: bytes | bytearray
@param name: Optional - Name of the file in the cloud
@type name: str | NoneType
@param filename: Optional - can define name of the file saved on Host.
@type filename: str | NoneType
method
add_existing_file(self, filename: Path | str, copy: bool = True, name: str | None = None)
Adds an existing file to the Event.

@param filename: Path to the file to be added.
@type filename: Path | str
@param copy: If True, the file will be copied to the Event folder. If False, the file will be moved to the Event folder.
@type copy: bool
@param name: Optional - Name of the file in the cloud
@type name: str | NoneType
method
set_title(self, title)
Sets the title of the Event.

@param title: Title for the Event
@type title: str | NoneType
method
set_metadata(self, metadata: dict)
Sets the metadata of the Event.

@param metadata: Dictionary containing the metadata
@type metadata: dict
method
add_tag(self, tag: str)
Adds a tag to the Event.

Cannot add more than 10 tags to one Event.

@param tag: The tag string
@type tag: str
method
add_tags(self, tags: List [ str ])
Adds multiple tags to the Event.

Cannot add more than 10 tags to one Event.

@param tags: A list of tags
@type tags: List[str]
method
set_tags(self, tags: List [ str ])
Sets the tags of the Event.

An Event cannot have more than 10 tags.

@param tags: A list of tags
@type tags: List[str]
property
keep_after_upload
Decides whether Event should be kept after upload, C{False} by default.
method
keep_after_upload.setter(self, value: bool)
Sets the keep after upload property.

Example usage:

>>> self.keep_after_upload = True
property
no_upload_by_default
If set to True, Event will not be uploaded. C{False} by default.
method
no_upload_by_default.setter(self, value: bool)
Sets the keep after upload property.

Example usage:

>>> self.keep_after_upload = True
property
keep_when_space_low
Decides whether Event should be kept when storage space is low, C{False} by default.
method
keep_when_space_low.setter(self, value: bool)
Sets the keep when space low property.

Example usage:

>>> self.keep_when_space_low = True