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[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