Main Content

Deep Learning Object Detector

Detect objects using trained deep learning object detector

  • Library:
  • Computer Vision Toolbox / Analysis & Enhancement

  • Deep Learning Object Detector block

Description

The Deep Learning Object Detector block predicts bounding boxes, class labels, and scores for the input image by using the trained object detector specified through the block parameter. This block allows loading of a pretrained object detector into the Simulink® model from a MAT file or from a MATLAB® function. This block provides a graphical interface for using the detector objects in Simulink. To enable some parameters of the Deep Learning Object Detector block you must choose an object detector that supports those parameters. For example, using a yolov2ObjectDetector object with this block enables you to select parameters similar to the name-value arguments of the associated detect object function.

Ports

Input

expand all

An H-by-W-by-C numeric array, where H, W, and C are the height, width, and number of channels of the image, respectively. Only one image per time step is allowed as input.

Output

expand all

Locations of the objects detected within the input image, returned as an M-by-4 matrix. M is the number of bounding boxes detected in the image. You can put an upper bound to the size M by specifying the Maximum Number of Detections parameter. Each row of Bboxes is of the form [x y width height], specifying the upper-left corner and size of the corresponding bounding box in pixels.

Labels for the bounding boxes, returned as an M-by-1 enumerated vector. M is the number of bounding boxes detected in the image.

Detection confidence scores for each label, returned as an M-by-1 vector. M is the number of bounding boxes detected in the image. A higher score indicates higher confidence in the detection.

Parameters

expand all

Select the source for the detector object from these options:

  • Detector from MAT file — Import a detector object from a MAT file. For example, select a MAT file containing an rcnnObjectDetector object.

  • Detector from MATLAB function — Import a detector object from a MATLAB function. For example, specify the function vehicleDetectorYOLOv2, which returns a trained yolov2ObjectDetector object.

The imported detector must be one of these supported objects:

  • rcnnObjectDetector

  • fastRCNNObjectDetector

  • fasterRCNNObjectDetector

  • ssdObjectDetector

  • yolov2ObjectDetector

Programmatic Use

Block Parameter: Detector
Type: character vector, string
Values: Detector from MAT file' | 'Detector from MATLAB function'
Default: Detector from MAT file'

This parameter specifies the name of the MAT file that contains the detector object to load. If the file is not on the MATLAB path, use the Browse button to locate the file.

Dependencies

To enable this parameter, set the Detector parameter to Detector from MAT file.

Programmatic Use

Block Parameter: DetectorFilePath
Type: character vector, string
Values: MAT file path or name
Default: 'untitled.mat'

This parameter specifies the name of the MATLAB function that returns a trained object detector. For example, specify the function vehicleDetectorYOLOv2, which returns a trained yolov2ObjectDetector object, or specify a custom function.

Dependencies

To enable this parameter, set the Detector parameter to Detector from MATLAB function.

Programmatic Use

Block Parameter: DetectorFunction
Type: character vector, string
Values: MATLAB function name
Default: 'untitled'

Specify the search region of interest as vector of the form [x y width height]. The vector specifies the upper-left corner and size of a region in pixels.

Dependencies

To enable this parameter, select the Specify region of interest parameter.

Programmatic Use

Block Parameter: ROI
Type: character vector, string
Values: character vector specified as '[x y width height]'
Default: '[1 1 100 100]'

Specify the detection threshold as scalar in the range [0, 1]. Detections that have scores lower than this threshold value are removed. To reduce false positives, increase this value.

Dependencies

To enable this parameter, you must use a detector that supports the Detection threshold parameter. For example, use a yolov2ObjectDetector object.

Programmatic Use

Block Parameter: Threshold
Type: character vector, string
Values: scalar
Default: '0.5'

Specify the maximum number of strongest region proposals as an integer. Reduce this value to speed up processing at the cost of detection accuracy. To use all region proposals, specify this parameter as Inf.

Dependencies

To enable this parameter, use a detector that supports the Number of Strongest Regions parameter. For example, use an rcnnObjectDetector object.

Programmatic Use

Block Parameter: NumStrongestRegions
Type: character vector, string
Values: integer
Default: '2000'

Specify the maximum region size as a vector of the form [height width]. Units are in pixels. The maximum region size defines the size of the largest region containing the object. For example, [50 50] sets the size of the largest region containing the object to 50-by-50 pixels. To reduce computation time, set this value to the known maximum region size for the objects that can be detected in the input test images.

Dependencies

To enable this parameter

  • Select the Specify maximum region size parameter.

  • Use a detector that supports the Maximum Region Size parameter. For example, use a yolov2ObjectDetector object.

Programmatic Use

Block Parameter: MaxSize
Type: character vector, string
Values: character vector specified as '[height width]'
Default: '[50 50]'

Specify the minimum region size as a vector of the form [height width]. Units are in pixels. The minimum region size defines the size of the smallest region containing the object. For example, [1 1] sets the size of the smallest region containing the object to 1-by-1 pixels.

Dependencies

To enable this parameter

  • Select the Specify minimum region size parameter.

  • Use a detector that supports the Minimum Region Size parameter. For example, use a yolov2ObjectDetector object.

Programmatic Use

Block Parameter: MinSize
Type: character vector, string
Values: character vector specified as '[height width]'
Default: '[1 1]'

Specify the maximum number of detections as a positive integer. This value is the upper bound for the number of detections.

Programmatic Use

Block Parameter: MaxDetections
Type: character vector, string
Values: integer
Default: '500'

Extended Capabilities

See Also

Objects

Blocks

Introduced in R2021b