MATLAB File Help: cv.HOGDescriptor | Index |
Histogram of Oriented Gaussian (HOG) descriptor and detector
The class implements Histogram of Oriented Gradients object detector [Dalal2005].
The basic usage is the following for computing HOG descriptors:
hog = cv.HOGDescriptor();
descriptors = hog.compute(im);
This computes descriptors in a "dense" setting; Each row is a feature
vector computed from a window of size WinSize
slided across the input
image gradient. Each vector element is a histogram of gradient
orientations (quantized into NBins
directions). The histogram is
collected within a "cell" of pixels of size CellSize
, and locally
normalized (see HistogramNormType
and L2HysThreshold
) over larger
spatial "block" regions of size BlockSize
overlapped according to
BlockStride
. See cv.HOGDescriptor.getDescriptorSize.
If you need to compute descriptors for a set of certain "sparse"
keypoints (for example SIFT or SURF keypoints), use the Locations
option of the compute method:
keypoints = cv.FAST(im);
descriptors = hog.compute(im, 'Locations', {keypoints.pt});
The next step in object recognition using HOG descriptors is to feed the descriptors computed from positive and negative images into a linear SVM classifier trained to classify whether a window is an object or not. This trained SVM model is represented by a set of coefficients for each element in the feature vector. This vector is assigned to the cv.HOGDescriptor.SvmDetector property.
Alternatively, you can use the default built-in people detector which is accessible by name as:
% detect and localize upright people in images
hog.SVMDetector = 'DefaultPeopleDetector';
boxes = hog.detectMultiScale(im);
In this case, there is no need to train an SVM model.
Either way, you simply call the detect methods which use the saved
coefficients on the input feature-vector to compute a weighted sum. If
the sum is greater than a user-specified threshold HitThreshold
, then
it is classified an object (a pedestrian in the case of the builtin
detectors).
The cv.HOGDescriptor.detectMultiScale method detects at multiple scales
(see NLevels
and Scale
) and directly returns the bounding boxes. The
cv.HOGDescriptor.detect method returns a list of top-left corner points,
where the detected object size is the same as the detector's window
size.
[Dalal2005]:
Navneet Dalal and Bill Triggs. "Histogram of oriented gradients for human detection". CVPR 2005. http://lear.inrialpes.fr/pubs/2005/DT05/
Superclasses | handle |
Sealed | false |
Construct on load | false |
HOGDescriptor | Create a new or load an existing HOG descriptor and detector |
BlockSize | Block size |
BlockStride | Block stride of a grid |
CellSize | Cell size of a grid |
DerivAperture | Derivative of aperture |
GammaCorrection | Gamma correction |
HistogramNormType | Histogram normalization method |
L2HysThreshold | L2 Hysterisis threshold |
NBins | Number of bins |
NLevels | Number of levels |
SignedGradient | Signed gradient |
SvmDetector | Coefficients for the linear SVM classifier. |
WinSigma | Window sigma |
WinSize | Window size |
id | Object ID |
addlistener | Add listener for event. | |
checkDetectorSize | Checks the size of the detector is valid | |
compute | Returns HOG block descriptors computed for the whole image | |
computeGradient | Computes gradient | |
delete | Destructor | |
detect | Performs object detection without a multi-scale window | |
detectMultiScale | Performs object detection with a multi-scale window | |
detectMultiScaleROI | Evaluate specified ROI and return confidence value for each location in multiple scales | |
detectROI | Evaluate specified ROI and return confidence value for each location | |
eq | == (EQ) Test handle equality. | |
findobj | Find objects matching specified conditions. | |
findprop | Find property of MATLAB handle object. | |
ge | >= (GE) Greater than or equal relation for handles. | |
getDescriptorSize | Returns the number of coefficients required for the classification | |
getWinSigma | Get window sigma | |
groupRectangles | Groups the object candidate rectangles | |
gt | > (GT) Greater than relation for handles. | |
Sealed | isvalid | Test handle validity. |
le | <= (LE) Less than or equal relation for handles. | |
load | Loads a HOG descriptor config from a file | |
lt | < (LT) Less than relation for handles. | |
ne | ~= (NE) Not equal relation for handles. | |
notify | Notify listeners of event. | |
readALTModel | Read model from SVMlight format | |
save | Saves a HOG descriptor config to a file |