Detections Module¶
The detections module provides functionality for detecting objects in imagery and managing detection data.
Core Classes¶
Collection of detection points from a detection algorithm or manual creation. |
A Detector contains pixel rows and columns plus timestamps, frame numbers, or both. Multiple
detections may share the same temporal value. Styling and labeling metadata are stored with the collection.
Detection Algorithms¶
VISTA provides several detection algorithms:
Threshold Detection: Simple intensity-based detection
CFAR Detection: Constant False Alarm Rate detection for adaptive thresholding
See Object Detection for detailed information on each algorithm.
Basic Usage¶
Creating a Detector¶
import numpy as np
from vista.detections.detector import Detector
from vista.sensors.sensor import Sensor
sensor = Sensor(name="My Sensor")
detector = Detector(
name="My Detector",
frames=np.array([0, 0, 1]),
rows=np.array([20.5, 45.0, 22.0]),
columns=np.array([30.5, 70.0, 33.5]),
sensor=sensor,
)
Running a Detection Algorithm¶
Algorithms process arrays and return data rather than constructing VISTA objects. For example, SimpleThreshold
processes one two-dimensional image:
from vista.algorithms.detectors.threshold import SimpleThreshold
algorithm = SimpleThreshold(threshold=10.0, min_area=2, max_area=25)
rows, columns = algorithm(imagery.images[0])
The GUI’s algorithm dialog runs the selected frames and stores the returned positions in a Detector. See
Object Detection for GUI workflows and CSV fields.
Slicing and Copying¶
first_ten = detector[:10]
duplicate = detector.copy()
Module Reference¶
- class vista.detections.detector.Detector(*, times=None, frames=None, name, rows, columns, sensor, description='', color='r', marker='o', marker_size=10, line_thickness=2, visible=True, complete=False, labels=<factory>, label_times=<factory>, labelers=<factory>)[source]¶
Bases:
TemporalDataCollection of detection points from a detection algorithm or manual creation.
A Detector represents a set of detected objects or points of interest across multiple frames. Unlike Tracks, detections are unassociated points without temporal continuity. Each detection point can have its own set of labels.
- Parameters:
name (str) – Unique identifier for this detector
rows (NDArray[np.float64]) – Row (vertical) pixel coordinates for each detection
columns (NDArray[np.float64]) – Column (horizontal) pixel coordinates for each detection
sensor (Sensor) – Sensor object associated with these detections
description (str, optional) – Description of detection algorithm or method, by default “”
- marker¶
Marker style (‘o’, ‘s’, ‘t’, ‘d’, ‘+’, ‘x’, ‘star’), by default ‘o’ (circle)
- Type:
str, optional
- labels¶
List of label sets, one set per detection point, by default empty list
Notes
Detections are unassociated points (unlike tracks which represent trajectories)
Multiple detections can exist at the same frame
Labels are per-detection, allowing individual detection categorization
Detection coordinates are always in pixel space (row/column)
- rows: NDArray[float64]¶
- columns: NDArray[float64]¶
- get_geodetic_coords()[source]¶
Get geodetic coordinates for all detection points, computing and caching if needed.
Projects each detection point using its own frame’s sensor geometry, so the result represents the true geographic location. The result is cached so subsequent calls return immediately.
- Returns:
(longitudes, latitudes) in degrees, or None if the sensor cannot geolocate.
- Return type:
tuple[NDArray[np.float64], NDArray[np.float64]] or None
- get_pen(width=None, **kwargs)[source]¶
Get cached PyQtGraph pen object, creating only if parameters changed.
- Parameters:
width (int, optional) – Line width override, uses self.line_thickness if None
- Returns:
PyQtGraph pen object
- Return type:
pg.mkPen
- classmethod from_dataframe(df, sensor, imagery=None, name=None)[source]¶
Create Detector from pandas DataFrame.
- Parameters:
df (pd.DataFrame) – DataFrame containing detection data. “Detector”, “Rows”, and “Columns” are required columns, along with either “Times” or “Frames”.
sensor (Sensor) – Sensor object for these detections.
imagery (Imagery, optional) – Imagery used to convert times and frames.
name (str, optional) – Detector name, by default taken from df[“Detector”]
- Returns:
New Detector object
- Return type:
- Raises:
ValueError – If temporal columns are missing or time-to-frame mapping cannot be performed.
Notes
Optional styling columns: “Color”, “Marker”, “Marker Size”, “Line Thickness”, “Visible”, “Labels”
Labels should be comma-separated strings in the “Labels” column.
- copy()[source]¶
Create a deep copy of this detector object.
- Returns:
New Detector object with copied arrays and styling attributes
- Return type:
- __init__(*, times=None, frames=None, name, rows, columns, sensor, description='', color='r', marker='o', marker_size=10, line_thickness=2, visible=True, complete=False, labels=<factory>, label_times=<factory>, labelers=<factory>)¶