Struct ObjectDetection
pub struct ObjectDetection(/* private fields */);Expand description
Object Detection functionality.
Implementations§
§impl ObjectDetection
impl ObjectDetection
pub fn get_detections(&mut self) -> Vec<BoxPrediction>
pub fn get_detections(&mut self) -> Vec<BoxPrediction>
Obtain the object detections from the most recently processed frame.
Note that the algorithm comes with a built-in threshold: boxes with confidences lower than that value won’t be produced at all by this function.
pub fn has_box_moved(
&self,
prediction: &BoxPrediction,
timeout_seconds: f32,
) -> Result<bool, Error>
pub fn has_box_moved( &self, prediction: &BoxPrediction, timeout_seconds: f32, ) -> Result<bool, Error>
Check if a box has moved significantly since its initial detection.
This function should only be used for boxes from the most recent video
frame. This function only accepts boxes of particular classes, depending
on the exact product and platform. For boxes of other classes, it will
return ErrorCode::InvalidBox.
The function returns
falseif the box has not moved since its initial detection, or if it has not moved sincetimeout_seconds.trueif the box has moved
This function should not be called directly after restoring from a previous state.
This function should not be called with boxes obtained directly after
VideoIntelligence::single_image calls.
§Errors
Error::InvalidBoxError::InvalidHasMovedTimeout
pub fn reset_tracker(&mut self)
pub fn reset_tracker(&mut self)
This function is only available if the library was built with tracking support.
This resets the internal tracker state and resets all tracker ids and face identifications if applicable. It is recommended to call this whenever two consecutive frames are too different from each other, such as when switching to a different camera input or when the camera abruptly moved.
pub fn set_confidence_threshold(
&mut self,
class_id: DetectionClass,
threshold: f32,
) -> Result<(), Error>
pub fn set_confidence_threshold( &mut self, class_id: DetectionClass, threshold: f32, ) -> Result<(), Error>
Set the confidence threshold for a particular class.
Boxes with a confidence lower than the supplied threshold will not be
returned by get_detections.
It is not necessary to call this function because the algorithm comes
with sensible built-in default thresholds. These can be queried using
get_confidence_threshold before any calls to this function are made.
Confidence values have been tuned so that sensible thresholds range from 0.5 to 1.0. The supplied threshold must be between 0.5 and 1.0.
The effect of this function is persistent until changed again by another
call to this function.
The effect of this function will be visible after the next call to
VideoIntelligence::process_frame or VideoIntelligence::single_image.
Calling get_detections again right after setting the threshold will
not change the resulting detections.
§Errors
Error::InvalidArgument
pub fn get_confidence_threshold(
&self,
class_id: DetectionClass,
) -> Result<f32, Error>
pub fn get_confidence_threshold( &self, class_id: DetectionClass, ) -> Result<f32, Error>
Get the confidence threshold for a particular class.
This function queries the current confidence threshold for a class.
See set_confidence_threshold for more information.
§Errors
Error::InvalidArgument
pub fn detector_version(&self) -> u32
pub fn detector_version(&self) -> u32
Returns a version number of the object detector neural network.