%% Detect Vehicles on Highway
% Detect cars in a single image and annotate the image with the detection scores. To detect cars, use a Faster R-CNN object detector that was trained using images of vehicles.
% Load the pretrained detector.

fasterRCNN = vehicleDetectorFasterRCNN('full-view');

%
% Use the detector on a loaded image. Store the locations of the bounding boxes and their detection scores.

I = imread('highway.png');
[bboxes,scores] = detect(fasterRCNN,I);

%
% Annotate the image with the detections and their scores.

I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
figure
imshow(I)
title('Detected Vehicles and Detection Scores')

% Copyright 2017 The MathWorks, Inc.