用摄像机来完成实时检测
此程序基于Tensorflow object detection API。
视频演示:https://www.bilibili.com/video/av32418677/?p=1
# By Bend_Function
# https://space.bilibili.com/275177832
# 可以放在任何文件夹下运行(前提正确配置API[环境变量])
# 退出 按q键
import numpy as np
import tensorflow as tf
import cv2
import os
from object_detection.utils import visualization_utils as vis_util
from object_detection.utils import label_map_util
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
cv2.setUseOptimized(True) # 加速cv
# 要改的内容
###############################################
PATH_TO_CKPT = 'model\\ssd_mobilenet_v1_graph.pb' # 模型及标签地址
PATH_TO_LABELS = 'model\\mscoco_label_map.pbtxt'
NUM_CLASSES = 90 # 检测对象个数
camera_num = 1 # 要打开的摄像头编号,可能是0或1
width, height = 1280,720 # 视频分辨率
################################