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§
- Aruco
Detector - The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
- Barcode
Detector - Base
Cascade Classifier - Base
Cascade Classifier_ Mask Generator - Board
- Board of ArUco markers
- Cascade
Classifier - @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 - ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard.
- Charuco
Detector - Charuco
Parameters - Detection
Based Tracker - Detection
Based Tracker_ ExtObject - Detection
Based Tracker_ IDetector - Detection
Based Tracker_ Parameters - DetectionROI
- struct for detection region of interest (ROI)
- Detector
Parameters - struct DetectorParameters is used by ArucoDetector
- Dictionary
- Dictionary is a set of unique ArUco markers of the same size
- Face
DetectorYN - DNN-based face detector
- Face
RecognizerSF - DNN-based face recognizer
- Graphical
Code Detector - Grid
Board - Planar board with grid arrangement of markers
- HOGDescriptor
- Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.
- QRCode
Detector - QRCode
Detector Aruco - QRCode
Detector Aruco_ Params - QRCode
Encoder - QRCode
Encoder_ Params - QR code encoder parameters.
- Refine
Parameters - struct RefineParameters is used by ArucoDetector
- Similar
Rects - This class is used for grouping object candidates detected by Cascade Classifier, HOG etc.
Enums§
- Corner
Refine Method - Detection
Based Tracker_ Object Status - Face
RecognizerSF_ DisType - Definition of distance used for calculating the distance between two face features
- HOGDescriptor_
Descriptor Storage Format - HOGDescriptor_
Histogram Norm Type - Predefined
Dictionary Type - Predefined markers dictionaries/sets
- QRCode
Encoder_ Correction Level - QRCode
Encoder_ ECIEncodings - QRCode
Encoder_ Encode Mode
Constants§
- CASCADE_
DO_ CANNY_ PRUNING - CASCADE_
DO_ ROUGH_ SEARCH - CASCADE_
FIND_ BIGGEST_ OBJECT - CASCADE_
SCALE_ IMAGE - CORNER_
REFINE_ APRILTAG - Tag and corners detection based on the AprilTag 2 approach wang2016iros
- CORNER_
REFINE_ CONTOUR - ArUco approach and refine the corners locations using the contour-points line fitting
- CORNER_
REFINE_ NONE - Tag and corners detection based on the ArUco approach
- CORNER_
REFINE_ SUBPIX - ArUco approach and refine the corners locations using corner subpixel accuracy
- DICT_
4X4_ 50 - 4x4 bits, minimum hamming distance between any two codes = 4, 50 codes
- DICT_
4X4_ 100 - 4x4 bits, minimum hamming distance between any two codes = 3, 100 codes
- DICT_
4X4_ 250 - 4x4 bits, minimum hamming distance between any two codes = 3, 250 codes
- DICT_
4X4_ 1000 - 4x4 bits, minimum hamming distance between any two codes = 2, 1000 codes
- DICT_
5X5_ 50 - 5x5 bits, minimum hamming distance between any two codes = 8, 50 codes
- DICT_
5X5_ 100 - 5x5 bits, minimum hamming distance between any two codes = 7, 100 codes
- DICT_
5X5_ 250 - 5x5 bits, minimum hamming distance between any two codes = 6, 250 codes
- DICT_
5X5_ 1000 - 5x5 bits, minimum hamming distance between any two codes = 5, 1000 codes
- DICT_
6X6_ 50 - 6x6 bits, minimum hamming distance between any two codes = 13, 50 codes
- DICT_
6X6_ 100 - 6x6 bits, minimum hamming distance between any two codes = 12, 100 codes
- DICT_
6X6_ 250 - 6x6 bits, minimum hamming distance between any two codes = 11, 250 codes
- DICT_
6X6_ 1000 - 6x6 bits, minimum hamming distance between any two codes = 9, 1000 codes
- DICT_
7X7_ 50 - 7x7 bits, minimum hamming distance between any two codes = 19, 50 codes
- DICT_
7X7_ 100 - 7x7 bits, minimum hamming distance between any two codes = 18, 100 codes
- DICT_
7X7_ 250 - 7x7 bits, minimum hamming distance between any two codes = 17, 250 codes
- DICT_
7X7_ 1000 - 7x7 bits, minimum hamming distance between any two codes = 14, 1000 codes
- DICT_
APRILTAG_ 16h5 - 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
- DICT_
APRILTAG_ 25h9 - 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
- DICT_
APRILTAG_ 36h10 - 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
- DICT_
APRILTAG_ 36h11 - 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
- DICT_
ARUCO_ MIP_ 36h12 - 6x6 bits, minimum hamming distance between any two codes = 12, 250 codes
- DICT_
ARUCO_ ORIGINAL - 6x6 bits, minimum hamming distance between any two codes = 3, 1024 codes
- Detection
Based Tracker_ DETECTED - Detection
Based Tracker_ DETECTED_ NOT_ SHOWN_ YET - Detection
Based Tracker_ DETECTED_ TEMPORARY_ LOST - Detection
Based Tracker_ WRONG_ OBJECT - Face
RecognizerSF_ FR_ COSINE - Face
RecognizerSF_ FR_ NORM_ L2 - HOGDescriptor_
DEFAULT_ NLEVELS - Default nlevels value.
- HOGDescriptor_
DESCR_ FORMAT_ COL_ BY_ COL - HOGDescriptor_
DESCR_ FORMAT_ ROW_ BY_ ROW - HOGDescriptor_
L2Hys - Default histogramNormType
- QRCode
Encoder_ CORRECT_ LEVEL_ H - QRCode
Encoder_ CORRECT_ LEVEL_ L - QRCode
Encoder_ CORRECT_ LEVEL_ M - QRCode
Encoder_ CORRECT_ LEVEL_ Q - QRCode
Encoder_ ECI_ UTF8 - QRCode
Encoder_ MODE_ ALPHANUMERIC - QRCode
Encoder_ MODE_ AUTO - QRCode
Encoder_ MODE_ BYTE - QRCode
Encoder_ MODE_ ECI - QRCode
Encoder_ MODE_ KANJI - QRCode
Encoder_ MODE_ NUMERIC - QRCode
Encoder_ MODE_ STRUCTURED_ APPEND
Traits§
- Aruco
Detector Trait - Mutable methods for crate::objdetect::ArucoDetector
- Aruco
Detector Trait Const - Constant methods for crate::objdetect::ArucoDetector
- Barcode
Detector Trait - Mutable methods for crate::objdetect::BarcodeDetector
- Barcode
Detector Trait Const - Constant methods for crate::objdetect::BarcodeDetector
- Base
Cascade Classifier Trait - Mutable methods for crate::objdetect::BaseCascadeClassifier
- Base
Cascade Classifier Trait Const - Constant methods for crate::objdetect::BaseCascadeClassifier
- Base
Cascade Classifier_ Mask Generator Trait - Mutable methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
- Base
Cascade Classifier_ Mask Generator Trait Const - Constant methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
- Board
Trait - Mutable methods for crate::objdetect::Board
- Board
Trait Const - Constant methods for crate::objdetect::Board
- Cascade
Classifier Trait - Mutable methods for crate::objdetect::CascadeClassifier
- Cascade
Classifier Trait Const - Constant methods for crate::objdetect::CascadeClassifier
- Charuco
Board Trait - Mutable methods for crate::objdetect::CharucoBoard
- Charuco
Board Trait Const - Constant methods for crate::objdetect::CharucoBoard
- Charuco
Detector Trait - Mutable methods for crate::objdetect::CharucoDetector
- Charuco
Detector Trait Const - Constant methods for crate::objdetect::CharucoDetector
- Charuco
Parameters Trait - Mutable methods for crate::objdetect::CharucoParameters
- Charuco
Parameters Trait Const - Constant methods for crate::objdetect::CharucoParameters
- Detection
Based Tracker Trait - Mutable methods for crate::objdetect::DetectionBasedTracker
- Detection
Based Tracker Trait Const - Constant methods for crate::objdetect::DetectionBasedTracker
- Detection
Based Tracker_ ExtObject Trait - Mutable methods for crate::objdetect::DetectionBasedTracker_ExtObject
- Detection
Based Tracker_ ExtObject Trait Const - Constant methods for crate::objdetect::DetectionBasedTracker_ExtObject
- Detection
Based Tracker_ IDetector Trait - Mutable methods for crate::objdetect::DetectionBasedTracker_IDetector
- Detection
Based Tracker_ IDetector Trait Const - Constant methods for crate::objdetect::DetectionBasedTracker_IDetector
- Detection
Based Tracker_ Parameters Trait - Mutable methods for crate::objdetect::DetectionBasedTracker_Parameters
- Detection
Based Tracker_ Parameters Trait Const - Constant methods for crate::objdetect::DetectionBasedTracker_Parameters
- DetectionROI
Trait - Mutable methods for crate::objdetect::DetectionROI
- DetectionROI
Trait Const - Constant methods for crate::objdetect::DetectionROI
- Detector
Parameters Trait - Mutable methods for crate::objdetect::DetectorParameters
- Detector
Parameters Trait Const - Constant methods for crate::objdetect::DetectorParameters
- Dictionary
Trait - Mutable methods for crate::objdetect::Dictionary
- Dictionary
Trait Const - Constant methods for crate::objdetect::Dictionary
- Face
DetectorYN Trait - Mutable methods for crate::objdetect::FaceDetectorYN
- Face
DetectorYN Trait Const - Constant methods for crate::objdetect::FaceDetectorYN
- Face
RecognizerSF Trait - Mutable methods for crate::objdetect::FaceRecognizerSF
- Face
RecognizerSF Trait Const - Constant methods for crate::objdetect::FaceRecognizerSF
- Graphical
Code Detector Trait - Mutable methods for crate::objdetect::GraphicalCodeDetector
- Graphical
Code Detector Trait Const - Constant methods for crate::objdetect::GraphicalCodeDetector
- Grid
Board Trait - Mutable methods for crate::objdetect::GridBoard
- Grid
Board Trait Const - Constant methods for crate::objdetect::GridBoard
- HOGDescriptor
Trait - Mutable methods for crate::objdetect::HOGDescriptor
- HOGDescriptor
Trait Const - Constant methods for crate::objdetect::HOGDescriptor
- QRCode
Detector Aruco Trait - Mutable methods for crate::objdetect::QRCodeDetectorAruco
- QRCode
Detector Aruco Trait Const - Constant methods for crate::objdetect::QRCodeDetectorAruco
- QRCode
Detector Trait - Mutable methods for crate::objdetect::QRCodeDetector
- QRCode
Detector Trait Const - Constant methods for crate::objdetect::QRCodeDetector
- QRCode
Encoder Trait - Mutable methods for crate::objdetect::QRCodeEncoder
- QRCode
Encoder Trait Const - Constant methods for crate::objdetect::QRCodeEncoder
- Similar
Rects Trait - Mutable methods for crate::objdetect::SimilarRects
- Similar
Rects Trait Const - Constant methods for crate::objdetect::SimilarRects
Functions§
- create_
face_ detection_ mask_ generator - draw_
detected_ corners_ charuco - Draws a set of Charuco corners
- draw_
detected_ corners_ charuco_ def - Draws a set of Charuco corners
- draw_
detected_ diamonds - Draw a set of detected ChArUco Diamond markers
- draw_
detected_ diamonds_ def - Draw a set of detected ChArUco Diamond markers
- draw_
detected_ markers - Draw detected markers in image
- draw_
detected_ markers_ def - Draw detected markers in image
- extend_
dictionary - Extend base dictionary by new nMarkers
- extend_
dictionary_ def - Extend base dictionary by new nMarkers
- generate_
image_ marker - Generate a canonical marker image
- generate_
image_ marker_ def - Generate a canonical marker image
- get_
predefined_ dictionary - Returns one of the predefined dictionaries defined in PredefinedDictionaryType
- get_
predefined_ dictionary_ i32 - Returns one of the predefined dictionaries referenced by DICT_*.
- group_
rectangles - Groups the object candidate rectangles.
- group_
rectangles_ def - Groups the object candidate rectangles.
- group_
rectangles_ levels - Groups the object candidate rectangles.
- group_
rectangles_ levels_ def - @overload
- group_
rectangles_ levelweights - Groups the object candidate rectangles.
- group_
rectangles_ meanshift - This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- group_
rectangles_ meanshift_ def - @overload
- group_
rectangles_ weights - Groups the object candidate rectangles.
- group_
rectangles_ weights_ def - @overload