Cascade Classifier
- The classifier is an ensemble model using AdaBoost
- Multiple smaller models are created where each of them is weak in classification
- Combined, it becomes a strong classifier with a good rates of precision and recall
- Each of the Weak classifier is a binary classifier
- To train them , need some positive samples and negative samples.
- The positive samples, are provided as an image and bounding box in which the object lies perfectly in the box
cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
This is a class in the OpenCV library that allows you to load and apply pre-trained Haar Cascade classifiers.
objects = cascade.detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]])
- Image – gray scale image
- scaleFactor – how much the input image is reduced at each step during detection
- minNeighbors – minimum number of rectangle overlap
- Flags – control the behavior of object detection
- cv2.CASCADE_SCALE_IMAGE: It scales the image down and applies the classifier.
- cv2.CASCADE_FIND_BIGGEST_OBJECT: Detects only the largest object.
- cv2.CASCADE_DO_ROUGH_SEARCH: A faster but less accurate search.
- minSize (optional – default (0,0)- defines the minimum size of the object to be detected.
- example, (30, 30) ensures that only objects at least 30×30 pixels in size are detected.
maxSize (Optional, default = None):
#This defines the maximum size of the object to be detected.
The function returns a list (or array) of rectangles where each rectangle contains the coordinates (x, y) of the top-left corner and the width w and height h of the detected object:
- objects = [(x, y, w, h), (x, y, w, h), …]
Views: 1