Main Content

fastRCNNObjectDetector

(Not recommended) Detect objects using Fast R-CNN deep learning detector

fastRCNNObjectDetector is not recommended. Instead, use a different type of object detector, such as a yoloxObjectDetector or yolov4ObjectDetector detector. For more information, see Version History.

Description

The fastRCNNObjectDetector object detects objects from an image, using a Fast R-CNN (regions with convolution neural networks) object detector. To detect objects in an image, pass the trained detector to the detect function. To classify image regions, pass the detector to the classifyRegions function.

When using the detect or classifyRegions functions with fastRCNNObjectDetector, use of a CUDA® enabled NVIDIA® GPU is highly recommended. The GPU reduces computation time significantly. Usage of the GPU requires Parallel Computing Toolbox™. For information about the supported compute capabilities, see GPU Computing Requirements (Parallel Computing Toolbox).

Creation

Create a fastRCNNObjectDetector object by calling the trainFastRCNNObjectDetector function with training data (requires Deep Learning Toolbox™).

detector = trainFastRCNNObjectDetector(trainingData,...)

Properties

expand all

Name of the classification model, specified as a character vector or string scalar. By default, the name is set to the heading of the second column of the trainingData table specified in the trainFastRCNNObjectDetector function. You can modify this name after creating your fastRCNNObjectDetector object.

Example: 'stopSign'

This property is read-only.

Trained Fast R-CNN detection network used within the Fast R-CNN detector, specified as a DAGNetwork (Deep Learning Toolbox) object. This object stores the layers that define the convolutional neural network used within the Fast R-CNN detector. This network classifies region proposals produced by the RegionProposalFcn property.

Region proposal method, specified as a function handle.

This property is read-only.

Names of the object classes that the Fast R-CNN detector was trained to find, specified as a cell array. This property is set by the trainingData input argument for the trainFastRCNNObjectDetector function. Specify the class names as part of the trainingData table.

This property is read-only.

Minimum object size supported by the Fast R-CNN network, specified as a [height width] vector. The minimum size depends on the network architecture.

Object Functions

detect(Not recommended) Detect objects using Fast R-CNN object detector
classifyRegions(Not recommended) Classify objects in image regions using Fast R-CNN object detector

Examples

collapse all

Detect vehicles within an image by using a Faster R-CNN object detector.

Load a Faster R-CNN object detector pretrained to detect vehicles.

data = load('fasterRCNNVehicleTrainingData.mat', 'detector');
detector = data.detector;

Read in a test image.

I = imread('highway.png');
imshow(I)

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

Run the detector on the image and inspect the results. The labels come from the ClassNames property of the detector.

[bboxes,scores,labels] = detect(detector,I)
bboxes = 2×4

   150    86    80    72
    91    89    67    48

scores = 2x1 single column vector

    1.0000
    0.9001

labels = 2x1 categorical
     vehicle 
     vehicle 

The detector has high confidence in the detections. Annotate the image with the bounding boxes for the detections and the corresponding detection scores.

  detectedI = insertObjectAnnotation(I,'Rectangle',bboxes,cellstr(labels));
  figure
  imshow(detectedI)

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

References

[1] Girshick, Ross, et al. “Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation.” 2014 IEEE Conference on Computer Vision and Pattern Recognition, IEEE, 2014, pp. 580–87. DOI.org (Crossref), https://doi.org/10.1109/CVPR.2014.81.

[2] Girshick, Ross. “Fast R-CNN.” 2015 IEEE International Conference on Computer Vision (ICCV), IEEE, 2015, pp. 1440–48. DOI.org (Crossref), https://doi.org/10.1109/ICCV.2015.169.

[3] Zitnick, C. Lawrence, and Dollar, Piotr. “Edge boxes: Locating object proposals from edges.” Computer Vision-ECCV 2014, Springer International Publishing, 2014. 391-405. DOI.org (Crossref), https://doi.org/10.1007/978-3-319-10602-1_26.

[4] Ren, Shaoqing, et al. “Faster R-CNN: Towards real-time object detection with region proposal networks.” IEEE Transactions on Pattern Analysis and Machine Intelligence, IEEE, 2016. 1137-1149. DOI.org (Crossref), https://doi.org/10.1109/TPAMI.2016.2577031.

Version History

Introduced in R2017a

collapse all

R2024b: Not Recommended

Starting in R2024b, R-CNN object detectors are no longer recommended. Instead, use a different type of object detector, such as a yoloxObjectDetector or yolov4ObjectDetector object. These object detectors are faster than R-CNN object detectors. For more information, see Choose an Object Detector.