Main Content

peopleDetector

Detect people using pretrained deep learning object detector

Since R2024b

    Description

    The peopleDetector object creates a deep learning object detector, trained on the COCO data set, to detect people in an image of arbitrary size.

    Creation

    Description

    detector = peopleDetector returns a deep learning-based people detector object that is pretrained on the COCO data set for people detection.

    detector = peopleDetector(name) returns a deep learning-based people detector object of the specified model name that is pretrained on the COCO data set.

    example

    detector = peopleDetector(___,Name=Value) sets the InputSize property of the detector using name-value arguments in addition to any combination of arguments from previous syntaxes.

    Note

    This functionality requires Deep Learning Toolbox™ and the Computer Vision Toolbox™ Model for RTMDet Object Detection. You can install the Computer Vision Toolbox Model for RTMDet Object Detection from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    Input Arguments

    expand all

    Name of the pretrained people detector model trained on the COCO data set, specified as one of these values.

    • "tiny-network" — This pretrained people detector deep learning model has the fewest filters and fewest convolutional layers. Use the "tiny-network" model when you have few available computational resources and require the fastest performance in terms of speed and real-time inference.

    • "small-network" — Use "small-network" for a higher level of accuracy than "tiny-network" when moderate computational resources are available.

    • "medium-network" — Use "medium-network" for a higher level of accuracy than "small-network" when more computational resources, such as GPU hardware, are available.

    • "large-network" — This pretrained people detector deep learning model has the largest number of filters and convolutional layers. Use the "large-network" network for the highest level accuracy in people detection at the expense of computational cost and speed.

    Data Types: char | string

    Properties

    expand all

    This property is read-only.

    Name for the people detector, stored as a character vector. By default, this property value is set to the value of the name input argument.

    This property is read-only.

    Name of the object class to be detected, stored as a cell array of character vector. By default, the value is 'person'.

    Image size to be used for inference, stored as a two-element row vector of integers of the form [H W]. H and W correspond to the height and width of the input image, respectively.

    By default, the InputSize property value is set to the network's input size [640 640], which is the size of the training images.

    To set a custom value for this property, specify the property and its value as a name,value pair when creating the object. For example, InputSize=[224 224] sets the InputSize property to [224 224].

    The detect function resizes the test image to the dimensions specified by the InputSize property before performing the detections. If the resolution of the person class to be detected is too small in the test image, increase the InputSize property value for better detection accuracy. However, increasing the InputSize property value will also increase the computational cost.

    Object Functions

    detectDetect people using pretrained deep learning-based people detector

    Examples

    collapse all

    Load the "large-network" pretrained deep learning-based people detector model.

    detector = peopleDetector("large-network");

    Read an image into the workspace.

    I = imread("occlusion.png");

    Detect all the people in the image regardless of their scale, orientation, or occlusion level.

    [bboxes,scores] = detect(detector,I);

    Annotate the detected people with bounding boxes, and display their detection scores.

    detectedImg = insertObjectAnnotation(I,"rectangle",bboxes,scores);
    figure
    imshow(detectedImg)

    Version History

    Introduced in R2024b