Expand description
§Object Detection
§Cascade Classifier for Object Detection
The object detector described below has been initially proposed by Paul Viola Viola01 and improved by Rainer Lienhart Lienhart02 .
First, a classifier (namely a cascade of boosted classifiers working with haar-like features) is trained with a few hundred sample views of a particular object (i.e., a face or a car), called positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary images of the same size.
After a classifier is trained, it can be applied to a region of interest (of the same size as used during the training) in an input image. The classifier outputs a “1” if the region is likely to show the object (i.e., face/car), and “0” otherwise. To search for the object in the whole image one can move the search window across the image and check every location using the classifier. The classifier is designed so that it can be easily “resized” in order to be able to find the objects of interest at different sizes, which is more efficient than resizing the image itself. So, to find an object of an unknown size in the image the scan procedure should be done several times at different scales.
The word “cascade” in the classifier name means that the resultant classifier consists of several simpler classifiers (stages) that are applied subsequently to a region of interest until at some stage the candidate is rejected or all the stages are passed. The word “boosted” means that the classifiers at every stage of the cascade are complex themselves and they are built out of basic classifiers using one of four different boosting techniques (weighted voting). Currently Discrete Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are supported. The basic classifiers are decision-tree classifiers with at least 2 leaves. Haar-like features are the input to the basic classifiers, and are calculated as described below. The current algorithm uses the following Haar-like features:
The feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within the region of interest and the scale (this scale is not the same as the scale used at the detection stage, though these two scales are multiplied). For example, in the case of the third line feature (2c) the response is calculated as the difference between the sum of image pixels under the rectangle covering the whole feature (including the two white stripes and the black stripe in the middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to compensate for the differences in the size of areas. The sums of pixel values over a rectangular regions are calculated rapidly using integral images (see below and the integral description).
Check [tutorial_cascade_classifier] “the corresponding tutorial” for more details.
The following reference is for the detection part only. There is a separate application called opencv_traincascade that can train a cascade of boosted classifiers from a set of samples.
Note: In the new C++ interface it is also possible to use LBP (local binary pattern) features in addition to Haar-like features. .. [Viola01] Paul Viola and Michael J. Jones. Rapid Object Detection using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is available online at https://github.com/SvHey/thesis/blob/master/Literature/ObjectDetection/violaJones_CVPR2001.pdf
§HOG (Histogram of Oriented Gradients) descriptor and object detector
§Barcode detection and decoding
§QRCode detection and encoding
§DNN-based face detection and recognition
Check [tutorial_dnn_face] “the corresponding tutorial” for more details.
§Common functions and classes
§ArUco markers and boards detection for robust camera pose estimation
ArUco Marker Detection
Square fiducial markers (also known as Augmented Reality Markers) are useful for easy,
fast and robust camera pose estimation.
The main functionality of ArucoDetector class is detection of markers in an image. If the markers are grouped
as a board, then you can try to recover the missing markers with ArucoDetector::refineDetectedMarkers().
ArUco markers can also be used for advanced chessboard corner finding. To do this, group the markers in the
CharucoBoard and find the corners of the chessboard with the CharucoDetector::detectBoard().
The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado [Aruco2014](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_Aruco2014).
Markers can also be detected based on the AprilTag 2 [wang2016iros](https://docs.opencv.org/4.11.0/d0/de3/citelist.html#CITEREF_wang2016iros) fiducial detection method.
§See also
Aruco2014 This code has been originally developed by Sergio Garrido-Jurado as a project for Google Summer of Code 2015 (GSoC 15).
Modules§
Structs§
- The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
- Board of ArUco markers
- @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
- ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard.
- struct for detection region of interest (ROI)
- struct DetectorParameters is used by ArucoDetector
- Dictionary is a set of unique ArUco markers of the same size
- DNN-based face detector
- DNN-based face recognizer
- Planar board with grid arrangement of markers
- Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.
- QR code encoder parameters.
- struct RefineParameters is used by ArucoDetector
- This class is used for grouping object candidates detected by Cascade Classifier, HOG etc.
Enums§
- Definition of distance used for calculating the distance between two face features
- Predefined markers dictionaries/sets
Constants§
- Tag and corners detection based on the AprilTag 2 approach wang2016iros
- ArUco approach and refine the corners locations using the contour-points line fitting
- Tag and corners detection based on the ArUco approach
- ArUco approach and refine the corners locations using corner subpixel accuracy
- 4x4 bits, minimum hamming distance between any two codes = 4, 50 codes
- 4x4 bits, minimum hamming distance between any two codes = 3, 100 codes
- 4x4 bits, minimum hamming distance between any two codes = 3, 250 codes
- 4x4 bits, minimum hamming distance between any two codes = 2, 1000 codes
- 5x5 bits, minimum hamming distance between any two codes = 8, 50 codes
- 5x5 bits, minimum hamming distance between any two codes = 7, 100 codes
- 5x5 bits, minimum hamming distance between any two codes = 6, 250 codes
- 5x5 bits, minimum hamming distance between any two codes = 5, 1000 codes
- 6x6 bits, minimum hamming distance between any two codes = 13, 50 codes
- 6x6 bits, minimum hamming distance between any two codes = 12, 100 codes
- 6x6 bits, minimum hamming distance between any two codes = 11, 250 codes
- 6x6 bits, minimum hamming distance between any two codes = 9, 1000 codes
- 7x7 bits, minimum hamming distance between any two codes = 19, 50 codes
- 7x7 bits, minimum hamming distance between any two codes = 18, 100 codes
- 7x7 bits, minimum hamming distance between any two codes = 17, 250 codes
- 7x7 bits, minimum hamming distance between any two codes = 14, 1000 codes
- 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
- 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
- 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
- 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
- 6x6 bits, minimum hamming distance between any two codes = 12, 250 codes
- 6x6 bits, minimum hamming distance between any two codes = 3, 1024 codes
- Default nlevels value.
- Default histogramNormType
Traits§
- Mutable methods for crate::objdetect::ArucoDetector
- Constant methods for crate::objdetect::ArucoDetector
- Mutable methods for crate::objdetect::BarcodeDetector
- Constant methods for crate::objdetect::BarcodeDetector
- Mutable methods for crate::objdetect::BaseCascadeClassifier
- Constant methods for crate::objdetect::BaseCascadeClassifier
- Mutable methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
- Constant methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
- Mutable methods for crate::objdetect::Board
- Constant methods for crate::objdetect::Board
- Mutable methods for crate::objdetect::CascadeClassifier
- Constant methods for crate::objdetect::CascadeClassifier
- Mutable methods for crate::objdetect::CharucoBoard
- Constant methods for crate::objdetect::CharucoBoard
- Mutable methods for crate::objdetect::CharucoDetector
- Constant methods for crate::objdetect::CharucoDetector
- Mutable methods for crate::objdetect::CharucoParameters
- Constant methods for crate::objdetect::CharucoParameters
- Mutable methods for crate::objdetect::DetectionBasedTracker
- Constant methods for crate::objdetect::DetectionBasedTracker
- Mutable methods for crate::objdetect::DetectionBasedTracker_ExtObject
- Constant methods for crate::objdetect::DetectionBasedTracker_ExtObject
- Mutable methods for crate::objdetect::DetectionBasedTracker_IDetector
- Constant methods for crate::objdetect::DetectionBasedTracker_IDetector
- Mutable methods for crate::objdetect::DetectionBasedTracker_Parameters
- Constant methods for crate::objdetect::DetectionBasedTracker_Parameters
- Mutable methods for crate::objdetect::DetectionROI
- Constant methods for crate::objdetect::DetectionROI
- Mutable methods for crate::objdetect::DetectorParameters
- Constant methods for crate::objdetect::DetectorParameters
- Mutable methods for crate::objdetect::Dictionary
- Constant methods for crate::objdetect::Dictionary
- Mutable methods for crate::objdetect::FaceDetectorYN
- Constant methods for crate::objdetect::FaceDetectorYN
- Mutable methods for crate::objdetect::FaceRecognizerSF
- Constant methods for crate::objdetect::FaceRecognizerSF
- Mutable methods for crate::objdetect::GraphicalCodeDetector
- Constant methods for crate::objdetect::GraphicalCodeDetector
- Mutable methods for crate::objdetect::GridBoard
- Constant methods for crate::objdetect::GridBoard
- Mutable methods for crate::objdetect::HOGDescriptor
- Constant methods for crate::objdetect::HOGDescriptor
- Mutable methods for crate::objdetect::QRCodeDetectorAruco
- Constant methods for crate::objdetect::QRCodeDetectorAruco
- Mutable methods for crate::objdetect::QRCodeDetector
- Constant methods for crate::objdetect::QRCodeDetector
- Mutable methods for crate::objdetect::QRCodeEncoder
- Constant methods for crate::objdetect::QRCodeEncoder
- Mutable methods for crate::objdetect::SimilarRects
- Constant methods for crate::objdetect::SimilarRects
Functions§
- Draws a set of Charuco corners
- Draws a set of Charuco corners
- Draw a set of detected ChArUco Diamond markers
- Draw a set of detected ChArUco Diamond markers
- Draw detected markers in image
- Draw detected markers in image
- Extend base dictionary by new nMarkers
- Extend base dictionary by new nMarkers
- Generate a canonical marker image
- Generate a canonical marker image
- Returns one of the predefined dictionaries defined in PredefinedDictionaryType
- Returns one of the predefined dictionaries referenced by DICT_*.
- Groups the object candidate rectangles.
- Groups the object candidate rectangles.
- Groups the object candidate rectangles.
- @overload
- Groups the object candidate rectangles.
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- @overload
- Groups the object candidate rectangles.
- @overload