600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > python车流量检测车流统计车辆计数yolov5 deepsort车流检测

python车流量检测车流统计车辆计数yolov5 deepsort车流检测

时间:2019-09-01 19:38:54

相关推荐

python车流量检测车流统计车辆计数yolov5 deepsort车流检测

python车流量检测车流统计车辆计数yolov5 deepsort车流检测

基于之前的yolo+deepsort上,将person类别改为车辆类别,因为coco数据集中,车辆类别有几种【car,bus,truck】,所以都要保存下来。

首先来看一下yolov5+deepsort的车辆跟踪初始效果,看着密密麻麻的框和id,思考一下该如何去设计这些规则进行统计。

labelsPath = "./yolo-coco/coco.names"LABELS = open(labelsPath).read().strip().split("\n")np.random.seed(42)COLORS = np.random.randint(0, 255, size=(200, 3),dtype="uint8")weightsPath = "./yolo-coco/yolov5.weights"configPath = "./yolo-coco/yolov5.cfg"net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)ln = net.getLayerNames()ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]# ----------------------------------------------------------------------------------------------------------------------"""# cv2.VideoCapture() --- 里面参数如果地址,打开视频文件 --- 里面参数是0/1,打开摄像头# 当参数是0的时候,打开计算机的内置摄像头,当参数为1的时候打开计算机的外置摄像头# (W, H) = (None, None) --- 视频的宽度和高度,初始化视频编写器(writer)和帧尺寸"""# ----------------------------------------------------------------------------------------------------------------------vs = cv2.VideoCapture('./input/123.mp4')(W, H) = (None, None)# ----------------------------------------------------------------------------------------------------------------------"""# try to determine the total number of frames in the video file# 打开一个指向视频文件的文件指针,循环读取帧 --- 尝试确定视频文件中的总帧数(total),以便估计整个视频的处理时间;# CV_CAP_PROP_FRAME_COUNT --- 视频的帧数# 这里使用是处理视频的时候固定的过程,不必过度的纠结其使用 ---# if imutils.is_cv2():#prop = cv2.cv.CV_CAP_PROP_FRAME_COUNT# else:#prop = cv2.CAP_PROP_FRAME_COUNT## vs.get(prop) --- cv2.VideoCapture.get(prop) --- 得到视频的总帧数 # print("[INFO] {} total frames in video".format(total)) --- 输出视频的帧数"""# ----------------------------------------------------------------------------------------------------------------------try:prop = cv2.cv.CV_CAP_PROP_FRAME_COUNT if imutils.is_cv2() \else cv2.CAP_PROP_FRAME_COUNTtotal = int(vs.get(prop))print("[INFO] {} total frames in video".format(total))except:print("[INFO] could not determine # of frames in video")print("[INFO] no approx. completion time can be provided")total = -1while True:# ----------------------------------------------------------------------------------------------------------------------"""# cv2.VideoCapture.read() ---> 读取视频,在while中循环读取视频的frame# vs.read() ---> 得到两个参数,其中ret是布尔值,如果读取帧是正确的则返回True,# 如果文件读取到结尾,它的返回值就为False。frame就是每一帧的图像,是个三维矩阵。# 第一个参数为False的时候,if not grabbed --- True --- 循环结束,"""(grabbed, frame) = vs.read()if not grabbed:breakif W is None or H is None:(H, W) = frame.shape[:2]

python车流量检测双向车流计数

python车流量检测车流统计车辆计数yolov5deepsort车流检测-机器学习文档类资源-CSDN下载

0 代码基础视频跑通教程:

/download/babyai996/85100267

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。