modify 1:1 比对方式
This commit is contained in:
82
pipeline.py
82
pipeline.py
@ -5,11 +5,19 @@ Created on Sun Sep 29 08:59:21 2024
|
||||
@author: ym
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import cv2
|
||||
import pickle
|
||||
import argparse
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
from track_reid import parse_opt, yolo_resnet_tracker
|
||||
from track_reid import parse_opt
|
||||
from track_reid import yolo_resnet_tracker
|
||||
# FILE = Path(__file__).resolve()
|
||||
# ROOT = FILE.parents[0] # YOLOv5 root directory
|
||||
# if str(ROOT) not in sys.path:
|
||||
# sys.path.append(str(ROOT)) # add ROOT to PATH
|
||||
# ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
||||
|
||||
from tracking.dotrack.dotracks_back import doBackTracks
|
||||
from tracking.dotrack.dotracks_front import doFrontTracks
|
||||
@ -35,38 +43,27 @@ def get_interbcd_inputenents():
|
||||
|
||||
return input_enents
|
||||
|
||||
def pipeline(eventpath, stdfeat_path=None, SourceType = "image"):
|
||||
'''
|
||||
inputs:
|
||||
eventpath: 事件文件夹
|
||||
stdfeat_path: 标准特征文件地址
|
||||
outputs:
|
||||
|
||||
'''
|
||||
# SourceType = "image" # image
|
||||
# eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1\20240918-110822-1bc3902e-5a8e-4e23-8eca-fb3f02738551_6938314601726"
|
||||
|
||||
savepath = r"D:\contrast\detect"
|
||||
|
||||
opt = parse_opt()
|
||||
optdict = vars(opt)
|
||||
optdict["project"] = savepath
|
||||
|
||||
eventname = os.path.basename(eventpath)
|
||||
# barcode = eventname.split('_')[-1]
|
||||
|
||||
|
||||
def pipeline(
|
||||
eventpath,
|
||||
savepath,
|
||||
SourceType = "image", # video
|
||||
stdfeat_path = None
|
||||
):
|
||||
if SourceType == "video":
|
||||
vpaths = get_video_pairs(eventpath)
|
||||
elif SourceType == "image":
|
||||
vpaths = get_image_pairs(eventpath)
|
||||
|
||||
|
||||
|
||||
'''======== 函数 yolo_resnet_tracker() 的参数字典 ========'''
|
||||
opt = parse_opt()
|
||||
optdict = vars(opt)
|
||||
optdict["is_save_img"] = True
|
||||
optdict["is_save_video"] = True
|
||||
|
||||
event_tracks = []
|
||||
for vpath in vpaths:
|
||||
'''事件结果文件夹'''
|
||||
save_dir_event = Path(savepath) / Path(eventname)
|
||||
save_dir_event = Path(savepath) / Path(os.path.basename(eventpath))
|
||||
if isinstance(vpath, list):
|
||||
save_dir_video = save_dir_event / Path("images")
|
||||
else:
|
||||
@ -78,8 +75,7 @@ def pipeline(eventpath, stdfeat_path=None, SourceType = "image"):
|
||||
'''Yolo + Resnet + Tracker'''
|
||||
optdict["source"] = vpath
|
||||
optdict["save_dir"] = save_dir_video
|
||||
optdict["is_save_img"] = True
|
||||
optdict["is_save_video"] = True
|
||||
|
||||
|
||||
tracksdict = yolo_resnet_tracker(**optdict)
|
||||
|
||||
@ -138,6 +134,7 @@ def pipeline(eventpath, stdfeat_path=None, SourceType = "image"):
|
||||
|
||||
|
||||
'''前后摄轨迹选择'''
|
||||
|
||||
if stdfeat_path is not None:
|
||||
with open(stdfeat_path, 'rb') as f:
|
||||
featDict = pickle.load(f)
|
||||
@ -171,22 +168,29 @@ def main_loop():
|
||||
stdfeat_path = os.path.join(bcdpath, f"{bcd}.pickle")
|
||||
input_enents.append((event_path, stdfeat_path))
|
||||
|
||||
|
||||
parmDict = {}
|
||||
parmDict["SourceType"] = "image"
|
||||
parmDict["savepath"] = r"D:\contrast\detect"
|
||||
for eventpath, stdfeat_path in input_enents:
|
||||
pipeline(eventpath, stdfeat_path, SourceType)
|
||||
parmDict["eventpath"] = eventpath
|
||||
parmDict["stdfeat_path"] = stdfeat_path
|
||||
|
||||
|
||||
def main():
|
||||
eventpath = r"D:\datasets\ym\exhibition\175836"
|
||||
pipeline(**parmDict)
|
||||
|
||||
eventpath = r"\\192.168.1.28\share\测试视频数据以及日志\各模块测试记录\展厅测试\1120_展厅模型v801测试\扫A放A\20241121-144855-dce94b09-1100-43f1-92e8-33a1b538b159_6924743915848_6924743915848"
|
||||
|
||||
SourceType = 'image'
|
||||
stdfeat_path = None
|
||||
|
||||
pipeline(eventpath, stdfeat_path, SourceType)
|
||||
|
||||
|
||||
def main():
|
||||
'''
|
||||
函数:pipeline(),遍历事件文件夹,选择类型 image 或 video,
|
||||
'''
|
||||
parmDict = {}
|
||||
parmDict["eventpath"] = r"\\192.168.1.28\share\测试视频数据以及日志\各模块测试记录\展厅测试\1120_展厅模型v801测试\扫A放A\20241121-144855-dce94b09-1100-43f1-92e8-33a1b538b159_6924743915848_6924743915848"
|
||||
|
||||
parmDict["savepath"] = r"D:\contrast\detect"
|
||||
parmDict["SourceType"] = "image" # video, image
|
||||
parmDict["stdfeat_path"] = None
|
||||
|
||||
pipeline(**parmDict)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Reference in New Issue
Block a user