Skip to main content

EyesOnItSDK

The main class for the EyesOnIt SDK. This class contains the methods required to use the SDK.

Methods

add_stream

This method allows you to add a stream to EyesOnIt which you can then monitor. When a stream is added to EyesOnIt, it is ready to be monitored, but monitoring must be initiated manually with the monitor_stream method below.

Signature

def add_stream(stream_url: str,
name: str,
regions: List[EOIRegion],
object_size: int,
object_descriptions: List[EOIObjectDescription],
alerting: EOIAlerting,
motion_detection: EOIEfficientDetection = EOIEfficientDetection(),
bounding_box: EOIBoundingBox = EOIBoundingBox(),
frame_rate: int = 5)

Parameters

NameTypeDescription
stream_urlstringthe RTSP URL for the stream including credentials required to connect to the stream
namestringa friendly name for the stream used in the EyesOnIt Web UI and in alerts
regionsList[EOIRegion]an list of rectangle detection regions
object_sizeintthe estimated object size in pixels
object_descriptionsList[EOIObjectDescription]an list of object descriptions describing objects to detect
alertingEOIAlertingthe alerting settings for this stream
motion_detectionEOIMotionDetectionthe motion detection settings for this stream
bounding_boxEOIBoundingBoxthe common object detection settings for this stream
frame_rateint (optional)the frame rate for this stream. Set

Return

Type: EOIResponse - the response object providing a success flag and message

Code Sample

import time
from EyesOnIt import EyesOnItSDK, EOIObjectDescription, EOIRegion, EOIAlerting, EOIMotionDetection, EOIBoundingBox

object_one = EOIObjectDescription(text='person', background_prompt=False, threshold=90)
object_two = EOIObjectDescription(text='trees', background_prompt=True)
object_descriptions = [object_one, object_two]

region_one = EOIRegion(top_left_x=4, top_left_y=9, width=500, height=300)
regions = [region_one]

alerting_settings = EOIAlerting(alert_seconds_count=2, reset_seconds_count=60)

motion_detection_settings = EOIMotionDetection(periodic_check_enabled=True, periodic_check_seconds=1)

bounding_box_settings = EOIBoundingBox(bounding_box_enabled=False)

app = EyesOnItSDK('http://127.0.0.1:8000')

result = app.add_stream(stream_url='rtsp://192.168.1.54/live0',
name='Outside Camera',
frame_rate=5,
regions=regions,
object_size=200,
object_descriptions=object_descriptions,
alerting=alerting_settings,
efficient_detection=motion_detection_settings,
bounding_box=bounding_box_settings)

remove_stream

This method removes a stream from EyesOnIt which was previously added with the add_stream method. When a stream is removed from EyesOnIt the license for that stream will be free to use for another stream after 24 hours.

Signature

def remove_stream(stream_url: str)

Parameters

NameTypeDescription
stream_urlstringthe URL of the stream to remove. This URL must exactly match the stream_url provided to the add_stream method.

Return

Type: EOIResponse - the response object providing a success flag and message

monitor_stream

This method monitors a stream which was previously added to EyesOnIt with the add_stream method. When a stream is being monitored, EyesOnIt processes the stream and generates alerts according to the add_stream parameters.

Signature

def monitor_stream(stream_url: str, duration_seconds: float = None):

Parameters

NameTypeDescription
stream_urlstringthe URL of the stream to monitor. This value must exactly match the stream URL provided to the add_stream method
duration_secondsfloatan option parameter indicating the duration in seconds to monitor the stream. If provided, EyesOnIt will monitor the stream for duration_seconds and then automatically stop monitoring. If not provided, the stream is monitored until monitoring is manually terminated by calling stop_monitoring or remove_stream.

Return

Type: EOIResponse - the response object providing a success flag and message

stop_monitoring

This method stops monitoring of a stream which was previously added to EyesOnIt and monitored with the add_stream and monitor_stream methods.

Signature

def stop_monitoring(stream_url: str)

Parameters

NameTypeDescription
stream_urlstringthe URL of the stream to stop monitoring. This value must exactly match the stream URL provided to the add_stream method

Return

Type: EOIResponse - the response object providing a success flag and message

get_preview_video_frame

This method gets a video frame from a stream that has not been added to EyesOnIt.

Signature

def get_preview_video_frame(stream_url: str)

Parameters

NameTypeDescription
stream_urlstringthe RTSP URL of the stream from which to get a video frame

Return

Type: EOIResponse - the response object providing a success flag and message. If successful, the frame is returned as a PIL.Image.Image object in the image attibrite of the message.

Code Sample

result = app.get_preview_video_frame(stream_url='rtsp://192.168.1.54/live0')
image_from_stream = result.message['image']
image_from_stream.save('my_video_frame.jpg')

get_video_frame

This method gets a video frame from a stream that has been added to EyesOnIt and is being monitored. To get a video frame from a stream that is not being monitored, call monitor_stream to monitor the stream temporarily, then call GetVideoFrame, then call stop_monitoring.

Signature

def get_video_frame(stream_url: str)

Parameters

NameTypeDescription
stream_urlstringthe RTSP URL of the stream from which to get a video frame. The stream must be in the monitoring state.

Return

Type: EOIResponse - the response object providing a success flag and message. If successful, the frame is returned as a PIL.Image.Image object in the image attibrite of the message.

Code Sample

result = app.get_video_frame(stream_url='rtsp://192.168.1.54/live0')
image_from_stream = result.message['image']
image_from_stream.save('my_video_frame.jpg')

process_image

This method uses the EyeOnIt Large Vision Model to process a single image from a file.

Signature

def process_image(regions: List[EOIRegion], 
object_size: int,
object_descriptions: List[EOIObjectDescription],
image)

Parameters

NameTypeDescription
regionsList[EOIRegion]the list of regions to use for processing
object_sizeintthe object size in pixels for processing
object_descriptionsList[EOIObjectDescription]the list of object descriptions to use for processing
imagestringthe file path of the image to process

Return

Type: EOIResponse - the response object providing a success flag and message. If successful, the message contains an object with a map of object descriptions to their confidence levels.

get_streams_info

This method gets information about each stream that is currently added to EyesOnIt

Signature

def get_streams_info()

Parameters

This method does not have any parameters

Return

Type: EOIResponse - the response object providing a success flag and other details. If the call is successful, the stream info is contained in the message property of the EOIResponse object as an array of JSON objects.

get_last_detection_info

This method gets information about the last detection for the specified stream

Signature

def get_last_detection_info(self, stream_url: str):

Parameters

This method does not have any parameters

Parameters

NameTypeDescription
stream_urlstringthe RTSP URL for the stream from which to get the last detection information. This URL must exactly match the URL provided to the add_stream method

Return

Type: EOIResponse - the response object providing a success flag and other details. If the call is successful, the detection info is contained in the message property of the EOIResponse object.