Detecting objects with the Single Shot Detection (SSD) model
In this recipe, you will learn how to detect objects using the Single Shot Detection (SSD) approach with the pretrained MobileNet network. The model supports 20 classes and can be used in many computer vision applications where finding objects in a scene is required, such as vehicle-collision warning. To know more visit https://arxiv.org/abs/1512.02325.
Getting ready
Before you proceed with this recipe, you need to install the OpenCV 3.x Python API package.
How to do it...
You need to complete these steps:
- Import the modules:
import cv2 import numpy as np
- Import the
Caffe
model:
model = cv2.dnn.readNetFromCaffe('../data/MobileNetSSD_deploy.prototxt', '../data/MobileNetSSD_deploy.caffemodel')
- Set a confidence threshold and specify the classes supported by the model:
CONF_THR = 0.3 LABELS = {1: 'aeroplane', 2: 'bicycle', 3: 'bird', 4: 'boat', 5: 'bottle', 6: 'bus', 7: 'car', 8: 'cat', 9: 'chair',...