Trait opencv::prelude::CascadeClassifier
source · pub trait CascadeClassifier: AlgorithmTrait + CascadeClassifierConst {
// Required method
fn as_raw_mut_CascadeClassifier(&mut self) -> *mut c_void;
// Provided methods
fn set_max_object_size(&mut self, max_object_size: Size) -> Result<()> { ... }
fn set_min_object_size(&mut self, min_size: Size) -> Result<()> { ... }
fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()> { ... }
fn set_min_neighbors(&mut self, min_neighbors: i32) -> Result<()> { ... }
fn set_find_largest_object(
&mut self,
find_largest_object: bool
) -> Result<()> { ... }
fn get_find_largest_object(&mut self) -> Result<bool> { ... }
fn set_max_num_objects(&mut self, max_num_objects: i32) -> Result<()> { ... }
fn detect_multi_scale(
&mut self,
image: &dyn ToInputArray,
objects: &mut dyn ToOutputArray,
stream: &mut Stream
) -> Result<()> { ... }
fn convert(
&mut self,
gpu_objects: &mut dyn ToOutputArray,
objects: &mut Vector<Rect>
) -> Result<()> { ... }
}
Expand description
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§
fn as_raw_mut_CascadeClassifier(&mut self) -> *mut c_void
Provided Methods§
sourcefn set_max_object_size(&mut self, max_object_size: Size) -> Result<()>
fn set_max_object_size(&mut self, max_object_size: Size) -> Result<()>
Maximum possible object size. Objects larger than that are ignored. Used for second signature and supported only for LBP cascades.
sourcefn set_min_object_size(&mut self, min_size: Size) -> Result<()>
fn set_min_object_size(&mut self, min_size: Size) -> Result<()>
Minimum possible object size. Objects smaller than that are ignored.
sourcefn set_scale_factor(&mut self, scale_factor: f64) -> Result<()>
fn set_scale_factor(&mut self, scale_factor: f64) -> Result<()>
Parameter specifying how much the image size is reduced at each image scale.
sourcefn set_min_neighbors(&mut self, min_neighbors: i32) -> Result<()>
fn set_min_neighbors(&mut self, min_neighbors: i32) -> Result<()>
Parameter specifying how many neighbors each candidate rectangle should have to retain it.
fn set_find_largest_object(&mut self, find_largest_object: bool) -> Result<()>
fn get_find_largest_object(&mut self) -> Result<bool>
fn set_max_num_objects(&mut self, max_num_objects: i32) -> Result<()>
sourcefn detect_multi_scale(
&mut self,
image: &dyn ToInputArray,
objects: &mut dyn ToOutputArray,
stream: &mut Stream
) -> Result<()>
fn detect_multi_scale( &mut self, image: &dyn ToInputArray, objects: &mut dyn ToOutputArray, stream: &mut Stream ) -> Result<()>
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()
sourcefn convert(
&mut self,
gpu_objects: &mut dyn ToOutputArray,
objects: &mut Vector<Rect>
) -> Result<()>
fn convert( &mut self, gpu_objects: &mut dyn ToOutputArray, objects: &mut Vector<Rect> ) -> Result<()>
Converts objects array from internal representation to standard vector.
Parameters
- gpu_objects: Objects array in internal representation.
- objects: Resulting array.
Implementations§
source§impl dyn CascadeClassifier + '_
impl dyn CascadeClassifier + '_
sourcepub fn create(filename: &str) -> Result<Ptr<dyn CascadeClassifier>>
pub fn create(filename: &str) -> Result<Ptr<dyn CascadeClassifier>>
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/
sourcepub fn create_1(file: &FileStorage) -> Result<Ptr<dyn CascadeClassifier>>
pub fn create_1(file: &FileStorage) -> Result<Ptr<dyn CascadeClassifier>>
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/