5 Star 1 Fork 1

wenjingyuer/Object detection in video

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.py 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
WuMoe 提交于 2021-04-01 11:45 . change
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import _init_paths
import logging
import os
import os.path as osp
from opts import opts
from tracking_utils.utils import mkdir_if_missing
from tracking_utils.log import logger
import datasets.dataset.jde as datasets
from track import eval_seq
logger.setLevel(logging.INFO)
def demo(opt):
result_root = opt.output_root if opt.output_root != '' else '.'
mkdir_if_missing(result_root)
#nms 0.05?
#conf up ?
logger.info('Starting tracking...')
# input video 可以0 webcam
#self.cap = cv2.VideoCapture(path)
# Face-Tracking-usingFairMOT\src\lib\datasets\dataset\jde.py
if(opt.input_video == "0"):
opt.input_video = 0
dataloader = datasets.LoadVideo(opt.input_video, opt.img_size)
result_filename = os.path.join(result_root, 'results.txt')
frame_rate = dataloader.frame_rate
frame_dir = None if opt.output_format == 'text' else osp.join(
result_root, 'frame')
eval_seq(opt, dataloader, 'mot', result_filename,
save_dir=frame_dir, show_image=True, frame_rate=frame_rate) # if show_image
if opt.output_format == 'video':
output_video_path = osp.join(result_root, 'MOT16-03-results.mp4')
cmd_str = 'ffmpeg -f image2 -i {}/%05d.jpg -b 5000k -c:v mpeg4 {}'.format(
osp.join(result_root, 'frame'), output_video_path)
os.system(cmd_str)
if __name__ == '__main__':
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
opt = opts().init()
demo(opt)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wenjingyuer/object-detection-in-video.git
git@gitee.com:wenjingyuer/object-detection-in-video.git
wenjingyuer
object-detection-in-video
Object detection in video
master

搜索帮助