pub trait CascadeClassifierTrait: CascadeClassifierTraitConst {
    // Required method
    fn as_raw_mut_CascadeClassifier(&mut self) -> *mut c_void;

    // Provided methods
    fn cc(&mut self) -> Ptr<dyn BaseCascadeClassifier> { ... }
    fn set_cc(&mut self, val: Ptr<dyn BaseCascadeClassifier>) { ... }
    fn load(&mut self, filename: &str) -> Result<bool> { ... }
    fn read(&mut self, node: &FileNode) -> Result<bool> { ... }
    fn detect_multi_scale(
        &mut self,
        image: &dyn ToInputArray,
        objects: &mut Vector<Rect>,
        scale_factor: f64,
        min_neighbors: i32,
        flags: i32,
        min_size: Size,
        max_size: Size
    ) -> Result<()> { ... }
    fn detect_multi_scale2(
        &mut self,
        image: &dyn ToInputArray,
        objects: &mut Vector<Rect>,
        num_detections: &mut Vector<i32>,
        scale_factor: f64,
        min_neighbors: i32,
        flags: i32,
        min_size: Size,
        max_size: Size
    ) -> Result<()> { ... }
    fn detect_multi_scale3(
        &mut self,
        image: &dyn ToInputArray,
        objects: &mut Vector<Rect>,
        reject_levels: &mut Vector<i32>,
        level_weights: &mut Vector<f64>,
        scale_factor: f64,
        min_neighbors: i32,
        flags: i32,
        min_size: Size,
        max_size: Size,
        output_reject_levels: bool
    ) -> Result<()> { ... }
    fn get_old_cascade(&mut self) -> Result<*mut c_void> { ... }
    fn set_mask_generator(
        &mut self,
        mask_generator: &Ptr<dyn BaseCascadeClassifier_MaskGenerator>
    ) -> Result<()> { ... }
    fn get_mask_generator(
        &mut self
    ) -> Result<Ptr<dyn BaseCascadeClassifier_MaskGenerator>> { ... }
}
Expand description

Required Methods§

Provided Methods§

source

fn cc(&mut self) -> Ptr<dyn BaseCascadeClassifier>

source

fn set_cc(&mut self, val: Ptr<dyn BaseCascadeClassifier>)

source

fn load(&mut self, filename: &str) -> Result<bool>

Loads a classifier from a file.

Parameters
  • filename: Name of the file from which the classifier is loaded. The file may contain an old HAAR classifier trained by the haartraining application or a new cascade classifier trained by the traincascade application.
source

fn read(&mut self, node: &FileNode) -> Result<bool>

Reads a classifier from a FileStorage node.

Note: The file may contain a new cascade classifier (trained by the traincascade application) only.

source

fn detect_multi_scale( &mut self, image: &dyn ToInputArray, objects: &mut Vector<Rect>, scale_factor: f64, min_neighbors: i32, flags: i32, min_size: Size, max_size: Size ) -> Result<()>

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Parameters
  • image: Matrix of the type CV_8U containing an image where objects are detected.
  • objects: Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
  • scaleFactor: Parameter specifying how much the image size is reduced at each image scale.
  • minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.
  • flags: Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
  • minSize: Minimum possible object size. Objects smaller than that are ignored.
  • maxSize: Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
C++ default parameters
  • scale_factor: 1.1
  • min_neighbors: 3
  • flags: 0
  • min_size: Size()
  • max_size: Size()
source

fn detect_multi_scale2( &mut self, image: &dyn ToInputArray, objects: &mut Vector<Rect>, num_detections: &mut Vector<i32>, scale_factor: f64, min_neighbors: i32, flags: i32, min_size: Size, max_size: Size ) -> Result<()>

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Parameters
  • image: Matrix of the type CV_8U containing an image where objects are detected.
  • objects: Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
  • scaleFactor: Parameter specifying how much the image size is reduced at each image scale.
  • minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.
  • flags: Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
  • minSize: Minimum possible object size. Objects smaller than that are ignored.
  • maxSize: Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
Overloaded parameters
  • image: Matrix of the type CV_8U containing an image where objects are detected.
  • objects: Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
  • numDetections: Vector of detection numbers for the corresponding objects. An object’s number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.
  • scaleFactor: Parameter specifying how much the image size is reduced at each image scale.
  • minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.
  • flags: Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
  • minSize: Minimum possible object size. Objects smaller than that are ignored.
  • maxSize: Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
C++ default parameters
  • scale_factor: 1.1
  • min_neighbors: 3
  • flags: 0
  • min_size: Size()
  • max_size: Size()
source

fn detect_multi_scale3( &mut self, image: &dyn ToInputArray, objects: &mut Vector<Rect>, reject_levels: &mut Vector<i32>, level_weights: &mut Vector<f64>, scale_factor: f64, min_neighbors: i32, flags: i32, min_size: Size, max_size: Size, output_reject_levels: bool ) -> Result<()>

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Parameters
  • image: Matrix of the type CV_8U containing an image where objects are detected.
  • objects: Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
  • scaleFactor: Parameter specifying how much the image size is reduced at each image scale.
  • minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.
  • flags: Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
  • minSize: Minimum possible object size. Objects smaller than that are ignored.
  • maxSize: Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
Overloaded parameters

This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter. For each resulting detection, levelWeights will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications.

A code sample on how to use it efficiently can be found below:

Mat img;
vector<double> weights;
vector<int> levels;
vector<Rect> detections;
CascadeClassifier model("/path/to/your/model.xml");
model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
C++ default parameters
  • scale_factor: 1.1
  • min_neighbors: 3
  • flags: 0
  • min_size: Size()
  • max_size: Size()
  • output_reject_levels: false
source

fn get_old_cascade(&mut self) -> Result<*mut c_void>

source

fn set_mask_generator( &mut self, mask_generator: &Ptr<dyn BaseCascadeClassifier_MaskGenerator> ) -> Result<()>

source

fn get_mask_generator( &mut self ) -> Result<Ptr<dyn BaseCascadeClassifier_MaskGenerator>>

Implementors§