[][src]Trait opencv::prelude::CascadeClassifierTrait

pub trait CascadeClassifierTrait {
    pub fn as_raw_CascadeClassifier(&self) -> *const c_void;
pub fn as_raw_mut_CascadeClassifier(&mut self) -> *mut c_void; pub fn cc(&mut self) -> Ptr<dyn BaseCascadeClassifier> { ... }
pub fn set_cc(&mut self, val: Ptr<dyn BaseCascadeClassifier>) { ... }
pub fn empty(&self) -> Result<bool> { ... }
pub fn load(&mut self, filename: &str) -> Result<bool> { ... }
pub fn read(&mut self, node: &FileNode) -> Result<bool> { ... }
pub 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<()> { ... }
pub 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<()> { ... }
pub 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<()> { ... }
pub fn is_old_format_cascade(&self) -> Result<bool> { ... }
pub fn get_original_window_size(&self) -> Result<Size> { ... }
pub fn get_feature_type(&self) -> Result<i32> { ... }
pub fn get_old_cascade(&mut self) -> Result<*mut c_void> { ... }
pub fn set_mask_generator(
        &mut self,
        mask_generator: &Ptr<dyn BaseCascadeClassifier_MaskGenerator>
    ) -> Result<()> { ... }
pub fn get_mask_generator(
        &mut self
    ) -> Result<Ptr<dyn BaseCascadeClassifier_MaskGenerator>> { ... } }

@example samples/cpp/facedetect.cpp This program demonstrates usage of the Cascade classifier class \image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254

Cascade classifier class for object detection.

Required methods

Loading content...

Provided methods

pub fn cc(&mut self) -> Ptr<dyn BaseCascadeClassifier>[src]

pub fn set_cc(&mut self, val: Ptr<dyn BaseCascadeClassifier>)[src]

pub fn empty(&self) -> Result<bool>[src]

Checks whether the classifier has been loaded.

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

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.

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

Reads a classifier from a FileStorage node.

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

pub 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<()>
[src]

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.

The function is parallelized with the TBB library.

Note:

  • (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py

C++ default parameters

  • scale_factor: 1.1
  • min_neighbors: 3
  • flags: 0
  • min_size: Size()
  • max_size: Size()

pub 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<()>
[src]

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.

The function is parallelized with the TBB library.

Note:

  • (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py

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()

pub 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<()>
[src]

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.

The function is parallelized with the TBB library.

Note:

  • (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py

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

pub fn is_old_format_cascade(&self) -> Result<bool>[src]

pub fn get_original_window_size(&self) -> Result<Size>[src]

pub fn get_feature_type(&self) -> Result<i32>[src]

pub fn get_old_cascade(&mut self) -> Result<*mut c_void>[src]

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

pub fn get_mask_generator(
    &mut self
) -> Result<Ptr<dyn BaseCascadeClassifier_MaskGenerator>>
[src]

Loading content...

Implementors

impl CascadeClassifierTrait for CascadeClassifier[src]

Loading content...