def start_video(self, model):
camera = cv2.VideoCapture(0)
while True:
frame = camera.read()[1]
if frame is None:
continue
image_array = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image_array = cv2.resize(image_array, (300, 300))
image_array = substract_mean(image_array)
image_array = np.expand_dims(image_array, 0)
predictions = model.predict(image_array)
detections = detect(predictions, self.prior_boxes)
plot_detections(detections, frame, 0.6,
self.arg_to_class, self.colors)
cv2.imshow('webcam', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
camera.release()
cv2.destroyAllWindows()
video_demo.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录