资源简介
yolo3,目标检测、识别、跟踪, 人和车 都已经实现
程序入口是app.py 已在python 3.7 tensorflow 1.12.0上测试通过 详细说明请参照代码 里面有详细注释
代码片段和文件信息
import os
from timeit import time
import sys
import cv2
import numpy as np
from PIL import Image
from yolo import YOLO
from application_util import preprocessing
from deep_sort import nn_matching
from deep_sort.detection import Detection
from deep_sort.tracker import Tracker
from tools import generate_detections as gdet
from deep_sort.detection import Detection as ddet
‘‘‘
This project does both detection and tracking of objects.
It utilizes the following project.
Tracker is based on: https://github.com/nwojke/deep_sort
Detector is based on: https://github.com/qqwweee/keras-yolo3
Just call detect_video to start the program.
Or just run py py app.py to see a demo.
Also you can refer to the usage example below.
@Params
yolo: Yolo detector object.
filename: filename of video to be detected
path: path of video to be detected
resize_flag: whether the video to be processed should be rescaled by half.
‘‘‘
def detect_video(yolo filename=‘‘ path=‘‘ resize_flag=False):
# define video path
fullpath = path + filename
model_path = yolo.model_path
model_name = model_path.split(‘/‘)[1][:-3]
output_path = ‘‘
if resize_flag == True:
output_path = f‘output/resized-{model_name}‘
else:
output_path = f‘output/original-{model_name}‘
# create output dir if not exist
if not os.path.exists(output_path):
os.makedirs(output_path)
# Gating threshold for cosine distance
max_cosine_distance = 0.2
# Maximum size of the appearance descriptors
nn_budget = None
# Non-maxima suppression threshold
nms_max_overlap = 1.0
# deep_sort
model_filename = ‘model_data/mars-small128.pb‘
encoder = gdet.create_box_encoder(model_filename batch_size=1)
metric = nn_matching.NearestNeighborDistanceMetric(
“cosine“ max_cosine_distance nn_budget)
tracker = Tracker(metric)
writeVideo_flag = True
video_capture = cv2.VideoCapture(fullpath)
if writeVideo_flag:
# Define the codec and create VideoWriter object
w = int(video_capture.get(3))
h = int(video_capture.get(4))
if resize_flag == True:
# default to resize by half
w = int(w/2)
h = int(h/2)
fourcc = cv2.VideoWriter_fourcc(* ‘MJPG‘)
# trim the filename to get rid of file extension
filename = filename[:-4]
# result output
out = cv2.VideoWriter(
f‘{output_path}/output-{filename}.avi‘ fourcc 15 (w h))
# location of detected objects
list_file = open(f‘{output_path}/detection-{filename}.txt‘ ‘w‘)
# framerate of detection.
fps_file = open(f‘{output_path}/framerate-{filename}.txt‘ ‘w‘)
frame_index = -1
fps = 0.0
while True:
ret frame = video_capture.read() # frame shape 640*480*3
if ret != True:
break
h w _ = frame.shape
if resize_flag == True:
frame = cv2.resize(frame (int(w/2) int(h/2))
相关资源
- pytorch版本手写体识别MNIST.zip
- 姿势检测的动作识别
- yolov3-tiny检测网络
- python调用dlib库实现简单的人脸识别
- 基于python和pencv的车牌号码识别
- Python实现的GMM用于语音识别
- python实现kaggle中的数字识别
- python3中文识别词库模型
- 基于人脸识别的课堂签到管理系统.
- 人脸识别代码python
- keras 实现的表情识别
- TensorflowOpenCV实现的CNN车牌识别代码
- python dlib 训练人脸特征点检测器
- 基于python下的 车牌识别代码 的车牌数
- 基于python下的 车牌识别代码
- 基于python的vgg网络学习,很基础但又
- LBPH算法人脸识别代码.rar
- mnist手写字体识别之BP.zip
- 基于卷积神经网络的人脸识别
- 基于卷积神经网络的手势识别
- 基于卷积神经网络的猫种类识别
- python项目-face++人脸识别考勤机-pytho
- python实现车牌识别
- (一)python爬虫验证码识别去除干扰
- tesserocr库
- Python实现基于SVM的车牌识别程序.zip
- 计算机/数字图像处理专业本科毕设—
- Python-Opencv自定义训练器识别任意物体
- 基于python的表情识别系统
- 基于Python的车牌识别
评论
共有 条评论