《OpenCV系列教程》
项目位置:OpenCV-Sample
代码位置:105-FindFacebyCaffeModel.py
代码:
import cv2 as cv
from cv2 import dnn
cap = cv.VideoCapture('./res/test.mp4')
net = dnn.readNetFromCaffe('./res/deploy.prototxt', './res/res10_300x300_ssd_iter_140000.caffemodel')
inWidth = 300
inHeight = 300
confThreshold = 0.5
while True:
ret, frame = cap.read()
cols = frame.shape[1]
rows = frame.shape[0]
net.setInput(dnn.blobFromImage(frame, 1.0, (inWidth, inHeight), (104.0, 177.0, 123.0), False, False))
detections = net.forward()
# perf