object detection using image
object detection using image
import cv2
image_path = "person.jpg"
proto_path = 'MobileNetSSD_deploy.prototxt.txt'
model_path = 'MobileNetSSD_deploy.caffemodel'
min_confidence = 0.5
np.random.seed(543210)
colours = np.random.uniform(0, 255, size=(len(classes), 3))
img = cv2.imread(image_path)
height, width = img.shape[0], img.shape[1]
blob = cv2.dnn.blobFromImage(cv2.resize(img, (300, 300)), 0.007, (300, 300), 130)
net.setInput(blob)
class_detected = False
try:
detections = net.forward()
for i in range(detections.shape[2]):
confidence = detections[0][0][i][2]
class_detected = True
except IndexError: