[][src]Trait opencv::hub_prelude::CascadeClassifier

pub trait CascadeClassifier: AlgorithmTrait {
    pub fn as_raw_CascadeClassifier(&self) -> *const c_void;
pub fn as_raw_mut_CascadeClassifier(&mut self) -> *mut c_void; pub fn set_max_object_size(&mut self, max_object_size: Size) -> Result<()> { ... }
pub fn get_max_object_size(&self) -> Result<Size> { ... }
pub fn set_min_object_size(&mut self, min_size: Size) -> Result<()> { ... }
pub fn get_min_object_size(&self) -> Result<Size> { ... }
pub fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()> { ... }
pub fn get_scale_factor(&self) -> Result<f64> { ... }
pub fn set_min_neighbors(&mut self, min_neighbors: i32) -> Result<()> { ... }
pub fn get_min_neighbors(&self) -> Result<i32> { ... }
pub fn set_find_largest_object(
        &mut self,
        find_largest_object: bool
    ) -> Result<()> { ... }
pub fn get_find_largest_object(&mut self) -> Result<bool> { ... }
pub fn set_max_num_objects(&mut self, max_num_objects: i32) -> Result<()> { ... }
pub fn get_max_num_objects(&self) -> Result<i32> { ... }
pub fn get_classifier_size(&self) -> Result<Size> { ... }
pub fn detect_multi_scale(
        &mut self,
        image: &dyn ToInputArray,
        objects: &mut dyn ToOutputArray,
        stream: &mut Stream
    ) -> Result<()> { ... }
pub fn convert(
        &mut self,
        gpu_objects: &mut dyn ToOutputArray,
        objects: &mut Vector<Rect>
    ) -> Result<()> { ... } }

Cascade classifier class used for object detection. Supports HAAR and LBP cascades. :

Note:

  • A cascade classifier example can be found at opencv_source_code/samples/gpu/cascadeclassifier.cpp
  • A Nvidea API specific cascade classifier example can be found at opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp

Required methods

Loading content...

Provided methods

pub fn set_max_object_size(&mut self, max_object_size: Size) -> Result<()>[src]

Maximum possible object size. Objects larger than that are ignored. Used for second signature and supported only for LBP cascades.

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

pub fn set_min_object_size(&mut self, min_size: Size) -> Result<()>[src]

Minimum possible object size. Objects smaller than that are ignored.

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

pub fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()>[src]

Parameter specifying how much the image size is reduced at each image scale.

pub fn get_scale_factor(&self) -> Result<f64>[src]

pub fn set_min_neighbors(&mut self, min_neighbors: i32) -> Result<()>[src]

Parameter specifying how many neighbors each candidate rectangle should have to retain it.

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

pub fn set_find_largest_object(
    &mut self,
    find_largest_object: bool
) -> Result<()>
[src]

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

pub fn set_max_num_objects(&mut self, max_num_objects: i32) -> Result<()>[src]

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

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

pub fn detect_multi_scale(
    &mut self,
    image: &dyn ToInputArray,
    objects: &mut dyn ToOutputArray,
    stream: &mut Stream
) -> Result<()>
[src]

Detects objects of different sizes in the input image.

Parameters

  • image: Matrix of type CV_8U containing an image where objects should be detected.
  • objects: Buffer to store detected objects (rectangles).
  • stream: CUDA stream.

To get final array of detected objects use CascadeClassifier::convert method.

   Ptr<cuda::CascadeClassifier> cascade_gpu = cuda::CascadeClassifier::create(...);
 
   Mat image_cpu = imread(...)
   GpuMat image_gpu(image_cpu);
 
   GpuMat objbuf;
   cascade_gpu->detectMultiScale(image_gpu, objbuf);
 
   std::vector<Rect> faces;
   cascade_gpu->convert(objbuf, faces);
 
   for(int i = 0; i < detections_num; ++i)
       cv::rectangle(image_cpu, faces[i], Scalar(255));
 
   imshow("Faces", image_cpu);

See also

CascadeClassifier::detectMultiScale

C++ default parameters

  • stream: Stream::Null()

pub fn convert(
    &mut self,
    gpu_objects: &mut dyn ToOutputArray,
    objects: &mut Vector<Rect>
) -> Result<()>
[src]

Converts objects array from internal representation to standard vector.

Parameters

  • gpu_objects: Objects array in internal representation.
  • objects: Resulting array.
Loading content...

Implementations

impl<'_> dyn CascadeClassifier + '_[src]

pub fn create(filename: &str) -> Result<Ptr<dyn CascadeClassifier>>[src]

Loads the classifier from a file. Cascade type is detected automatically by constructor parameter.

Parameters

  • filename: Name of the file from which the classifier is loaded. Only the old haar classifier (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/

pub fn create_1(file: &FileStorage) -> Result<Ptr<dyn CascadeClassifier>>[src]

Loads the classifier from a file. Cascade type is detected automatically by constructor parameter.

Parameters

  • filename: Name of the file from which the classifier is loaded. Only the old haar classifier (trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new type of OpenCV XML cascade supported for LBP. The working haar models can be found at opencv_folder/data/haarcascades_cuda/

Overloaded parameters

Implementors

Loading content...