tinesight.client#

Classes

TinesightClient(x509_key_path, x509_cert_path)

Client for invoking the Tinesight API from a device.

class tinesight.client.TinesightClient(x509_key_path: Path | str, x509_cert_path: Path | str)#

Client for invoking the Tinesight API from a device.

To use this class, a device must be registered with a signed certificate using the TinesightRegistrar.

Examples:
>>> result = TinesightClient(my_key_path, my_cert_path).classify(my_image_bytes)
>>> print(result.json)
>>> {'class': 'deer', 'probability': 0.98}
classify(image: str | Path | bytes) Response#

Invokes the classification model for the specified image

Args:

image: Can be a file path (str or Path) or raw image bytes

Returns:

requests.Response containing classification results

classify_video_stream(video_source: str | int = 0, frame_skip: int = 10, probability_threshold: float = 0.55, window_name: str = 'Tinesight Classification') None#

Continuously classify frames from a video stream and display results.

Captures video from a source (camera, RTSP stream, etc.), classifies frames at regular intervals, and displays the video with classification annotations. Uses asyncio for non-blocking classification to keep video smooth. Press Ctrl+C to stop.

Args:

video_source: Video source - can be device index (0 for default camera), frame_skip: Classify every Nth frame (default: 10). Higher values = faster but less frequent updates probability_threshold: Minimum confidence threshold to display classification (default: 0.55) window_name: Name of the display window

Examples:
>>> client = TinesightClient(key_path, cert_path)
>>> # Local camera
>>> client.classify_video_stream(0)
>>> # With custom threshold
>>> client.classify_video_stream(0, probability_threshold=0.75)
detect(image: str | Path | bytes) Response#

Invokes the object detection model for the specified image

Returns a list of detections, each containing a class label, probability, and bounding box coordinates [x1, y1, x2, y2].

Args:

image: Can be a file path (str or Path) or raw image bytes

Returns:

requests.Response containing detection results

Examples:
>>> result = TinesightClient(key, cert).detect("photo.jpg")
>>> print(result.json())
>>> [{'class': 'deer', 'probability': 0.95, 'bbox': [100, 200, 300, 400]}]
detect_video_stream(video_source: str | int = 0, frame_skip: int = 10, probability_threshold: float = 0.55, window_name: str = 'Tinesight Detection') None#

Continuously detect objects in frames from a video stream and display results.

Captures video from a source (camera, RTSP stream, etc.), runs object detection at regular intervals, and displays the video with bounding box annotations. Uses asyncio for non-blocking detection to keep video smooth. Press Ctrl+C to stop.

Args:

video_source: Video source - can be device index (0 for default camera), frame_skip: Detect every Nth frame (default: 10). Higher values = faster but less frequent updates probability_threshold: Minimum confidence threshold to display detections (default: 0.55) window_name: Name of the display window

Examples:
>>> client = TinesightClient(key_path, cert_path)
>>> client.detect_video_stream(0)
>>> client.detect_video_stream(0, probability_threshold=0.75)