DetectionZones

Struct DetectionZones 

pub struct DetectionZones(/* private fields */);
Expand description

Detection zone functionality.

Includes the motion detection functionality for the size of the motion grid.

Implementations§

§

impl DetectionZones

pub fn add_zone( &mut self, coordinates: Vec<(f32, f32)>, classes: Vec<DetectionClass>, apply_to_video_search: bool, ) -> Result<ZoneID, Error>

Specify a detection zone polygon for a group of classes.

The zone can be used to verify whether a bounding-box is inside or outside of it using the is_box_in_zone function. It can also be used internally by the Plumerai library to improve detection quality. A single detection zone can be used for one or more classes.

§Arguments
  • coordinates: A vector of (x, y) coordinates specifying the polygon of the detection zone in normalized coordinates, between 0 and 1. The code assumes that the first coordinate is also the final coordinate of the polygon: it should not be given by the user. The polygon must be simple (not complex): it can’t have holes or self-intersections. It is allowed to be both concave or convex.
  • classes: A vector of classes that the zone applies to. Must contain at least one class.
  • apply_to_video_search: When true, this zone is used to gate per-track sampling and full-frame blackout in the VLM video search pipeline. Pass false to keep the zone for detection-time queries only (e.g. notifications) and have video search behave as if the zone were not set.
§Errors
  • Error::InvalidZoneClass
  • Error::InvalidZoneGeometry
  • Error::MaximumDetectionZonesReached

pub fn remove_zone(&mut self, zone_id: ZoneID) -> Result<(), Error>

Remove an existing detection zone.

§Errors
  • Error::InvalidZoneID

pub fn is_box_in_zone( &self, zone_id: &ZoneID, prediction: &BoxPrediction, box_shrink_factor: f32, ) -> Result<bool, Error>

Determines whether a box prediction is within a detection zone.

The box_shrink_factor parameter controls how much overlap is required. Before the zone check the bounding box is shrunk towards its centre by the given factor: at 0.0 (default) the full box is used, so even if only a very small corner of the box touches the zone this will return true; at 1.0 the box is reduced to its centre point, so the centre must be inside the zone for this to return true. Values in between require proportionally more overlap.

§Errors
  • Error::InvalidZoneID
  • Error::InvalidZoneClass
  • Error::InvalidZoneGeometry
  • Error::InvalidBox if box_shrink_factor is outside [0, 1]

pub fn has_track_left_zone( &self, zone_id: &ZoneID, track_id: &TrackID, box_shrink_factor: f32, ) -> Result<bool, Error>

Determines whether a tracked box prediction has left a detection zone.

For a tracked box to be considered as having left a zone, it must have its origin completely or partially within the zone, and currently be completely outside the zone. The origin is defined as the location of the detected box at the start of the track (or when reset_track_origin was last called). If the tracked box left the zone before, but has now returned to it, this will not be considered as having left the zone.

The origin of the track can be reset using reset_track_origin.

§Arguments
  • box_shrink_factor: A factor in [0, 1] that shrinks the bounding box towards its centre before each zone check. See is_box_in_zone for details. The same factor is applied to both the current position and the track origin.
§Errors
  • Error::InvalidZoneID
  • Error::InvalidZoneClass
  • Error::InvalidZoneGeometry
  • Error::InvalidBox if the track ID is invalid or box_shrink_factor is outside [0, 1]

pub fn has_track_arrived_in_zone( &self, zone_id: &ZoneID, track_id: &TrackID, box_shrink_factor: f32, ) -> Result<bool, Error>

Determines whether a tracked box prediction has arrived in a detection zone.

For a tracked box to be considered as having arrived in a zone, it must currently be completely or partially inside the zone and have its origin completely outside the zone. The origin is defined as the location of the detected box at the start of the track (or when reset_track_origin was last called). If the tracked box originated in the zone, left the zone, and has now arrived back into the zone, it will not be considered as having arrived in the zone.

§Arguments
  • box_shrink_factor: A factor in [0, 1] that shrinks the bounding box towards its centre before each zone check. See is_box_in_zone for details. The same factor is applied to both the current position and the track origin.
§Errors
  • Error::InvalidZoneID
  • Error::InvalidZoneClass
  • Error::InvalidZoneGeometry
  • Error::InvalidBox if the track ID is invalid or box_shrink_factor is outside [0, 1]

pub fn reset_track_origin(&mut self, track_id: &TrackID) -> Result<(), Error>

Resets the origin of a track.

The origin of the track will be set to its current position, i.e. the position it had in the most recently processed frame.

The origin of a track is used by has_track_left_zone and has_track_arrived_in_zone. When a track starts in a zone, leaves it and later re-enters, has_track_arrived_in_zone will not return true because the track originated in the zone. To change this behavior, the origin can be reset after the track leaves the zone (for example, after a timeout period outside the zone). This way, when the track re-enters, it will be treated as having newly arrived in the zone.

§Errors
  • Error::InvalidBox if the track ID is invalid

pub fn get_motion_grid_in_zone(&self, zone_id: &ZoneID) -> Result<Grid, Error>

Get the motion detection grid, limited to a specific detection zone.

This function retrieves the motion detection grid similar to MotionDetection::get_grid but sets all values outside the specified detection zone to zero.

§Errors
  • Error::MotionGridNotYetReady
  • Error::InvalidZoneID

Trait Implementations§

§

impl Debug for DetectionZones

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.