Detectors

class stonesoup.detector.base.Detector(sensor: SensorDataReader)[source]

Bases: DetectionReader

Detector base class

A Detector processes SensorData to generate Detection data.

Parameters:

sensor (SensorDataReader) – Source of sensor data

sensor: SensorDataReader

Source of sensor data

TensorFlow

class stonesoup.detector.tensorflow.TensorFlowBoxObjectDetector(sensor: SensorDataReader, model_path: Path, labels_path: Path, run_async: bool = False)[source]

Bases: _VideoAsyncBoxDetector

A box object detector that generates detections of objects in the form of bounding boxes from image/video frames using a TensorFlow object detection model. Both TensorFlow 1 and TensorFlow 2 compatible models are supported.

The detections generated by the box detector have the form of bounding boxes that capture the area of the frame where an object is detected. Each bounding box is represented by a vector of the form [x, y, w, h], where x, y denote the relative coordinates of the top-left corner, while w, h denote the relative width and height of the bounding box.

Additionally, each detection carries the following meta-data fields:

  • raw_box: The raw bounding box, as generated by TensorFlow.

  • class: A dict with keys id and name relating to the id and name of the detection class.

  • score: A float in the range (0, 1] indicating the detector’s confidence.

Important

Use of this class requires that TensorFlow 2 and the TensorFlow Object Detection API are installed. A quick guide on how to set these up can be found here.

Parameters:
  • sensor (SensorDataReader) – Source of sensor data

  • model_path (pathlib.Path) – Path to saved_model directory. This is the directory that contains the saved_model.pb file.

  • labels_path (pathlib.Path) – Path to label map (*.pbtxt file). This is the file that contains mapping of object/class ids to meaningful names

  • run_async (bool, optional) – If set to True, the detector will digest frames from the reader asynchronously and only perform detection on the last frame digested. This is suitable when the detector is applied to readers generating a live feed (e.g. FFmpegVideoStreamReader), where real-time processing is paramount. Defaults to False

model_path: Path

Path to saved_model directory. This is the directory that contains the saved_model.pb file.

labels_path: Path

Path to label map (*.pbtxt file). This is the file that contains mapping of object/class ids to meaningful names

TensorNets

class stonesoup.detector.tensornets.Networks(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

TensorNet pre-trained networks, supported by TensorNetsObjectDetector

See TensorNets documentation for more information on these networks.

YOLOv2VOC

YOLOv2 trained against PASCAL VOC dataset

YOLOv2COCO

YOLOv2 tranined against COCO dataset

TinyYOLOv2VOC

TinyYOLOv2 trained against PASCAL VOC dataset

TinyYOLOv2COCO

TinyYOLOv2 trained against COCO dataset

YOLOv3VOC

YOLOv3 trained against PASCAL VOC dataset

YOLOv3COCO

YOLOv3 tranined against COCO dataset

class stonesoup.detector.tensornets.TensorNetsBoxObjectDetector(sensor: SensorDataReader, net: Networks, run_async: bool = False)[source]

Bases: _VideoAsyncBoxDetector

TensorNets Object Detection class

This uses pre-trained networks from TensorNets for object detection in video frames. Supported networks are listed in Networks.

Parameters:
  • sensor (SensorDataReader) – Source of sensor data

  • net (Networks) – TensorNet network to use for object detection

  • run_async (bool, optional) – If set to True, the detector will digest frames from the reader asynchronously and only perform detection on the last frame digested. This is suitable when the detector is applied to readers generating a live feed (e.g. FFmpegVideoStreamReader), where real-time processing is paramount. Defaults to False

net: Networks

TensorNet network to use for object detection