Main Content

rtmdetObjectDetector

Detect objects using RTMDet object detector

Since R2024b

Description

The rtmdetObjectDetector object creates an Real-Time Model for object Detection (RTMDet), which is a one-stage, real-time, anchor-free object detector, for detecting objects in an image of arbitrary size. Using this object, you can create a pretrained RTMDet object detector by using RTMDet deep learning networks trained on the COCO data set.

Creation

Description

detector = rtmdetObjectDetector creates a RTMDet object detector trained to detect 80 object classes from the COCO data set using a CSP-Darknet network.

detector = rtmdetObjectDetector(name) creates a pretrained RTMDet object detector by using the specified RTMDet deep learning network name trained on the COCO data set.

example

detector = rtmdetObjectDetector(___,Name=Value) sets the InputSize, and NormalizationStatistics properties of the detector using one or more 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 RTMDet deep learning network, created using CSP-DarkNet as the base network and trained on the COCO data set, specified as one of these values.

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

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

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

  • "large-network-coco" — Pretrained RTMDet-large deep learning network. This RTMDet network has the largest number of filters and convolutional layers. Use the RTMDet-large network for the highest level accuracy in object detection at the expense of computational cost and speed.

Tip

To improve accuracy and the performance of complex detection tasks, you can increase the pretrained model size at the expense of decreased inference speed, larger computation time, and greater memory requirements. Use RTMDet-tiny for real-time inference at the expense of detection accuracy. Use RTMDet-small for near-real-time applications due to fast inference. Use RTMDet-medium and RTMDet-large when sufficient computational resources are available for the largest accuracy, at the expense of lower computation speeds.

Data Types: char | string

Properties

expand all

This property is read-only.

Name for the object 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.

Names of 80 object classes in COCO data set stored as a cell array. The detector is pre-trained on the COCO data set.

This property is read-only.

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

By default, the InputSize property value is set to the network's input size [640 640 3], 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 3] sets the InputSize property to [224 224 3].

The detect function resizes the test image to the dimensions specified by the InputSize property before performing the detections.

Z-score normalization statistics, stored as a structure with the fields Mean and StandardDeviation, which contain the values from the COCO data set:

FieldDescriptionDefault Value
Mean1-by-C vector of means per channel.[123.6750 116.2800 103.5300]
StandardDeviation1-by-C vector of standard deviations per channel.[58.3950 57.1200 57.3750]

The number of channels C must match the number of channels in the image dimensions specified by InputSize.

Object Functions

detectDetect objects using RTMDet object detector

Examples

collapse all

Specify the name of a pretrained RTMDet deep learning network.

modelname = "medium-network-coco";

Create an RTMDet object detector by using the pretrained RTMDet network.

detector = rtmdetObjectDetector(modelname);

Read a test image into the workspace, and detect objects in it by using the pretrained RTMDet object detector with a Threshold value of 0.55.

img = imread("boats.png");
[bboxes,scores,labels] = detect(detector,img,Threshold=0.55);

Display the bounding boxes and predicted class labels of the detected objects.

detectedImg = insertObjectAnnotation(img,"rectangle",bboxes,labels);
figure
imshow(detectedImg)

Figure contains an axes object. The hidden axes object contains an object of type image.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2024b