Detect vehicles using YOLO v2 Network
trained you only look once (YOLO) v2 object detector for detecting vehicles. YOLO v2 is a
deep learning object detection framework that uses a convolutional neural network (CNN) for
detector = vehicleDetectorYOLOv2
The detector is trained using unoccluded RGB images of the front, rear, left, and right
sides of cars on a highway scene. The CNN used with the vehicle detector uses a modified
version of the MobileNet-v2 network architecture. You can also fine tune the vehicle
detector with additional training data by using the
trainYOLOv2ObjectDetector (Computer Vision Toolbox).
For information about creating a YOLO v2 object detector, see Create YOLO v2 Object Detection Network (Computer Vision Toolbox). Use of this function requires Deep Learning Toolbox™.
This example shows how to detect cars in an image and annotate the image with the detection scores. To detect the cars, use a YOLO v2 detector that is trained to detect vehicles in an image.
Load the pretrained detector.
detector = vehicleDetectorYOLOv2();
Read a test image into the workspace.
I = imread('highway.png');
Detect vehicles in the test image by using the trained YOLO v2 detector. Pass the test image and the detector as input to the
detect (Computer Vision Toolbox) function. The
detect function returns the bounding boxes and the detection scores.
[bboxes,scores] = detect(detector,I);
Annotate the image with the bounding boxes and the detection scores. Display the detection results. The bounding boxes localize vehicles in the test image.
I = insertObjectAnnotation(I,'rectangle',bboxes,scores); figure imshow(I) title('Detected vehicles and detection scores');
detector— Trained YOLO v2 network for vehicle detection
yolov2ObjectDetector(Computer Vision Toolbox)