Module objdetect

Source
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:

image

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§

prelude

Structs§

ArucoDetector
The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
BarcodeDetector
BaseCascadeClassifier
BaseCascadeClassifier_MaskGenerator
Board
Board of ArUco markers
CascadeClassifier
@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
CharucoBoard
ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard.
CharucoDetector
CharucoParameters
DetectionBasedTracker
DetectionBasedTracker_ExtObject
DetectionBasedTracker_IDetector
DetectionBasedTracker_Parameters
DetectionROI
struct for detection region of interest (ROI)
DetectorParameters
struct DetectorParameters is used by ArucoDetector
Dictionary
Dictionary is a set of unique ArUco markers of the same size
FaceDetectorYN
DNN-based face detector
FaceRecognizerSF
DNN-based face recognizer
GraphicalCodeDetector
GridBoard
Planar board with grid arrangement of markers
HOGDescriptor
Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.
QRCodeDetector
QRCodeDetectorAruco
QRCodeDetectorAruco_Params
QRCodeEncoder
QRCodeEncoder_Params
QR code encoder parameters.
RefineParameters
struct RefineParameters is used by ArucoDetector
SimilarRects
This class is used for grouping object candidates detected by Cascade Classifier, HOG etc.

Enums§

CornerRefineMethod
DetectionBasedTracker_ObjectStatus
FaceRecognizerSF_DisType
Definition of distance used for calculating the distance between two face features
HOGDescriptor_DescriptorStorageFormat
HOGDescriptor_HistogramNormType
PredefinedDictionaryType
Predefined markers dictionaries/sets
QRCodeEncoder_CorrectionLevel
QRCodeEncoder_ECIEncodings
QRCodeEncoder_EncodeMode

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
DetectionBasedTracker_DETECTED
DetectionBasedTracker_DETECTED_NOT_SHOWN_YET
DetectionBasedTracker_DETECTED_TEMPORARY_LOST
DetectionBasedTracker_WRONG_OBJECT
FaceRecognizerSF_FR_COSINE
FaceRecognizerSF_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
QRCodeEncoder_CORRECT_LEVEL_H
QRCodeEncoder_CORRECT_LEVEL_L
QRCodeEncoder_CORRECT_LEVEL_M
QRCodeEncoder_CORRECT_LEVEL_Q
QRCodeEncoder_ECI_UTF8
QRCodeEncoder_MODE_ALPHANUMERIC
QRCodeEncoder_MODE_AUTO
QRCodeEncoder_MODE_BYTE
QRCodeEncoder_MODE_ECI
QRCodeEncoder_MODE_KANJI
QRCodeEncoder_MODE_NUMERIC
QRCodeEncoder_MODE_STRUCTURED_APPEND

Traits§

ArucoDetectorTrait
Mutable methods for crate::objdetect::ArucoDetector
ArucoDetectorTraitConst
Constant methods for crate::objdetect::ArucoDetector
BarcodeDetectorTrait
Mutable methods for crate::objdetect::BarcodeDetector
BarcodeDetectorTraitConst
Constant methods for crate::objdetect::BarcodeDetector
BaseCascadeClassifierTrait
Mutable methods for crate::objdetect::BaseCascadeClassifier
BaseCascadeClassifierTraitConst
Constant methods for crate::objdetect::BaseCascadeClassifier
BaseCascadeClassifier_MaskGeneratorTrait
Mutable methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
BaseCascadeClassifier_MaskGeneratorTraitConst
Constant methods for crate::objdetect::BaseCascadeClassifier_MaskGenerator
BoardTrait
Mutable methods for crate::objdetect::Board
BoardTraitConst
Constant methods for crate::objdetect::Board
CascadeClassifierTrait
Mutable methods for crate::objdetect::CascadeClassifier
CascadeClassifierTraitConst
Constant methods for crate::objdetect::CascadeClassifier
CharucoBoardTrait
Mutable methods for crate::objdetect::CharucoBoard
CharucoBoardTraitConst
Constant methods for crate::objdetect::CharucoBoard
CharucoDetectorTrait
Mutable methods for crate::objdetect::CharucoDetector
CharucoDetectorTraitConst
Constant methods for crate::objdetect::CharucoDetector
CharucoParametersTrait
Mutable methods for crate::objdetect::CharucoParameters
CharucoParametersTraitConst
Constant methods for crate::objdetect::CharucoParameters
DetectionBasedTrackerTrait
Mutable methods for crate::objdetect::DetectionBasedTracker
DetectionBasedTrackerTraitConst
Constant methods for crate::objdetect::DetectionBasedTracker
DetectionBasedTracker_ExtObjectTrait
Mutable methods for crate::objdetect::DetectionBasedTracker_ExtObject
DetectionBasedTracker_ExtObjectTraitConst
Constant methods for crate::objdetect::DetectionBasedTracker_ExtObject
DetectionBasedTracker_IDetectorTrait
Mutable methods for crate::objdetect::DetectionBasedTracker_IDetector
DetectionBasedTracker_IDetectorTraitConst
Constant methods for crate::objdetect::DetectionBasedTracker_IDetector
DetectionBasedTracker_ParametersTrait
Mutable methods for crate::objdetect::DetectionBasedTracker_Parameters
DetectionBasedTracker_ParametersTraitConst
Constant methods for crate::objdetect::DetectionBasedTracker_Parameters
DetectionROITrait
Mutable methods for crate::objdetect::DetectionROI
DetectionROITraitConst
Constant methods for crate::objdetect::DetectionROI
DetectorParametersTrait
Mutable methods for crate::objdetect::DetectorParameters
DetectorParametersTraitConst
Constant methods for crate::objdetect::DetectorParameters
DictionaryTrait
Mutable methods for crate::objdetect::Dictionary
DictionaryTraitConst
Constant methods for crate::objdetect::Dictionary
FaceDetectorYNTrait
Mutable methods for crate::objdetect::FaceDetectorYN
FaceDetectorYNTraitConst
Constant methods for crate::objdetect::FaceDetectorYN
FaceRecognizerSFTrait
Mutable methods for crate::objdetect::FaceRecognizerSF
FaceRecognizerSFTraitConst
Constant methods for crate::objdetect::FaceRecognizerSF
GraphicalCodeDetectorTrait
Mutable methods for crate::objdetect::GraphicalCodeDetector
GraphicalCodeDetectorTraitConst
Constant methods for crate::objdetect::GraphicalCodeDetector
GridBoardTrait
Mutable methods for crate::objdetect::GridBoard
GridBoardTraitConst
Constant methods for crate::objdetect::GridBoard
HOGDescriptorTrait
Mutable methods for crate::objdetect::HOGDescriptor
HOGDescriptorTraitConst
Constant methods for crate::objdetect::HOGDescriptor
QRCodeDetectorArucoTrait
Mutable methods for crate::objdetect::QRCodeDetectorAruco
QRCodeDetectorArucoTraitConst
Constant methods for crate::objdetect::QRCodeDetectorAruco
QRCodeDetectorTrait
Mutable methods for crate::objdetect::QRCodeDetector
QRCodeDetectorTraitConst
Constant methods for crate::objdetect::QRCodeDetector
QRCodeEncoderTrait
Mutable methods for crate::objdetect::QRCodeEncoder
QRCodeEncoderTraitConst
Constant methods for crate::objdetect::QRCodeEncoder
SimilarRectsTrait
Mutable methods for crate::objdetect::SimilarRects
SimilarRectsTraitConst
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

Type Aliases§

DetectionBasedTracker_Object