Main Content

vision.PeopleDetector

(Removed) Detect upright people using HOG features

vision.PeopleDetector function has been removed. Use the peopleDetectorACF function to detect people, instead.

Description

The people detector object detects people in an input image using the Histogram of Oriented Gradient (HOG) features and a trained Support Vector Machine (SVM) classifier. The object detects unoccluded people in an upright position.

To detect people in an image:

  1. Create the vision.PeopleDetector object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

peopleDetector = vision.PeopleDetector returns a people detector object, peopleDetector, that tracks a set of points in a video.

example

peopleDetector = vision.PeopleDetector(model) creates a people detector object and sets the ClassificationModel property to model.

peopleDetector = vision.PeopleDetector(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, peopleDetector = vision.PeopleDetector('ClassificationModel','UprightPeople_128x64')

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Name of classification model, specified as 'UprightPeople_128x64' or 'UprightPeople_96x48'. The pixel dimensions indicate the image size used for training.

The images used to train the models include background pixels around the person. Therefore, the actual size of a detected person is smaller than the training image size.

People classification threshold, specified as a nonnegative scalar value. Use this threshold to control the classification of individual image subregions during multiscale detection. The threshold controls whether a subregion gets classified as a person. You can increase this value when there are many false detections. The higher the threshold value, the more stringent the requirements are for the classification. Vary the threshold over a range of values to find the optimum value for your data set. Typical values range from 0 to 4.

Tunable: Yes

Smallest region containing a person, specified in pixels as a two-element vector, [height width]. Set this property to the minimum size region containing a person. You can reduce computation time when you set this property. To do so, set this property to a value larger than the image size used to train the classification model. When you do not specify this property, the detector sets it to the image size used to train the classification model.

Tunable: Yes

Largest region that contains a person, specified in pixels as a two-element vector, [height width]. Set this property to the largest region containing a person. You can reduce computation time when you set this property. To do so, set this property to a value smaller than the size of the input image. When you do not specify this property, the detector sets it to the input image size. This property is tunable.

Multiscale object detection scaling, specified as a value greater than 1.0001. The scale factor incrementally scales the detection resolution between MinSize and MaxSize. You can set the scale factor to an ideal value using:

size(I)/(size(I)-0.5)

The object calculates the detection resolution at each increment.

round(TrainingSize*(ScaleFactorN))

In this case, the TrainingSize is [128 64] for the 'UprightPeople_128x64' model and [96 48] for the 'UprightPeople_96x48' model. N is the increment. Decreasing the scale factor can increase the detection accuracy. However, doing so increases the computation time. This property is tunable.

Detection window stride in pixels, specified as a scalar or a two-element vector, [x y]. The detector uses the window stride to slide the detection window across the image. When you specify this value as a vector, the first and second elements are the stride size in the x and y directions. When you specify this value as a scalar, the stride is the same for both x and y. Decreasing the window stride can increase the detection accuracy. However, doing so increases computation time. Increasing the window stride beyond [8 8] can lead to a greater number of missed detections. This property is tunable.

Merge detection control, specified as true or false. This property controls whether similar detections are merged. Set this property to true to merge bounding boxes using a mean-shift based algorithm. Set this property to false to output the unmerged bounding boxes.

For more flexibility and control of merging parameters, you can use the selectStrongestBbox function in place of the MergeDetections algorithm. To do this, set the MergeDetections property to false. See the Tracking Pedestrians from a Moving Car example, which shows the use of the people detector and the selectStrongestBbox function.

Use region of interest, specified as true or false. Set this property to true to detect objects within a rectangular region of interest within the input image.

Usage

Description

bboxes = peopleDetector(I) performs multiscale object detection on the input image, I and returns an M-by-4 matrix defining M bounding boxes. M represents the number of detected people. Each row of the output matrix, BBOXES, contains a four-element vector, [x y width height]. This vector specifies, in pixels, the upper-left corner and size, of a bounding box. When no people are detected, the object returns an empty vector. The input image, I, must be a grayscale or truecolor (RGB) image.

example

[bboxes, scores] = peopleDetector(I) additionally returns a confidence value for the detections.

[___] = peopleDetector(I,roi)detects people within the rectangular search region, roi.

Input Arguments

expand all

Input image, specified as grayscale or truecolor (RGB).

Rectangular region of interest within image I, specified as a four-element vector, [x y width height].

Classification model, specified as 'UprightPeople_128x64' or 'UprightPeople_96x48'.

Output Arguments

expand all

People detector object, returned as an object. The detector detects people in an input image using the Histogram of Oriented Gradient (HOG) features and a trained SVM classifier. The object detects unoccluded people in an upright position.

Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

  1. Create a people detector and load the input image.

    peopleDetector = vision.PeopleDetector;
    I = imread('visionteam1.jpg');
  2. Detect people using the people detector object.

    [bboxes,scores] = peopleDetector(I);
  3. Annotate detected people.

    I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
    figure, imshow(I)
    title('Detected people and detection scores');

    Figure contains an axes object. The axes object with title Detected people and detection scores contains an object of type image.

References

[1] Dalal, N. and B. Triggs. “Histograms of Oriented Gradients for Human Detection,”Proceedings of IEEE Conference on Computer Vision and Pattern Recognition, June 2005, pp. 886-893.

Extended Capabilities

Version History

Introduced in R2012b

expand all

R2024b: vision.PeopleDetector function has been removed

vision.PeopleDetector function has been removed. Use the peopleDetectorACF function to detect people, instead.