modify pipeline.py

This commit is contained in:
王庆刚
2025-01-13 17:35:15 +08:00
parent 3d13b0d9c5
commit a50f777839
12 changed files with 322 additions and 211 deletions

View File

@ -174,16 +174,6 @@ def calc_simil(event, stdfeat):
def simi_matrix():
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result\single_event"
@ -347,20 +337,6 @@ def main():
if __name__ == "__main__":
main()
# cluster()

View File

@ -136,8 +136,8 @@ def stdfeat_infer(imgPath, featPath, bcdSet=None):
continue
featpath = os.path.join(featPath, f"{bcd}.pickle")
# if os.path.isfile(featpath):
# continue
if os.path.isfile(featpath):
continue
stdbDict = {}
t1 = time.time()

View File

@ -24,10 +24,15 @@ def init_eventdict(sourcePath, stype="data"):
# bname = r"20241126-135911-bdf91cf9-3e9a-426d-94e8-ddf92238e175_6923555210479"
source_path = os.path.join(sourcePath, bname)
if not os.path.isdir(source_path): continue
if stype=="data":
pickpath = os.path.join(eventDataPath, f"{bname}.pickle")
if os.path.isfile(pickpath): continue
if not os.path.isdir(source_path) or os.path.isfile(pickpath):
continue
if stype=="source":
pickpath = os.path.join(eventDataPath, bname)
if not os.path.isfile(source_path) or os.path.isfile(pickpath):
continue
try:
event = ShoppingEvent(source_path, stype)
@ -86,20 +91,28 @@ def simi_calc(event, o2nevt, typee=None):
feat1 = event.back_feats
feat2 = o2nevt.front_feats
'''自定义事件特征选择'''
if typee==3:
feat1 = event.feats_compose
feat2 = o2nevt.feats_compose
if len(feat1) and len(feat2):
matrix = 1 - cdist(feat1[0], feat2[0], 'cosine')
simi = np.mean(matrix)
else:
simi = None
return simi
def one2n_pr(evtDicts, pattern=1):
'''
pattern:
1: process.data 中记录的相似度
2: 根据 process.data 中标记的 type 选择特征计算
3: 以其它方式选择特征计算
'''
def one2n_pr(evtDicts):
tpevents, fnevents, fpevents, tnevents = [], [], [], []
tpsimi, fnsimi, tnsimi, fpsimi = [], [], [], []
errorFile_one2n = []
@ -112,21 +125,29 @@ def one2n_pr(evtDicts):
similar = ndict["similar"]
typee = ndict["type"].strip()
evt_names.append(nname)
evt_barcodes.append(barcode)
evt_types.append(typee)
if pattern==1:
evt_similars.append(similar)
if pattern==2 or pattern==3:
o2n_evt = [evt for name, evt in evtDicts.items() if name.find(nname[:15])==0]
if len(o2n_evt)==1:
o2nevt = o2n_evt[0]
else:
continue
if pattern==2:
simival = simi_calc(event, o2nevt, typee)
if pattern==3:
simival = simi_calc(event, o2nevt, typee=pattern)
if simival==None:
continue
evt_names.append(nname)
evt_barcodes.append(barcode)
evt_similars.append(simival)
evt_types.append(typee)
if len(evt_names)==len(evt_barcodes) and len(evt_barcodes)==len(evt_similars) \
and len(evt_similars)==len(evt_types) and len(evt_names)>0:
@ -205,14 +226,14 @@ def one2n_pr(evtDicts):
def main():
'''1. 生成事件字典并保存至 eventDataPath, 只需运行一次 '''
# init_eventdict(eventSourcePath)
init_eventdict(eventSourcePath, stype="source")
'''2. 读取事件字典 '''
evtDicts = read_eventdict(eventDataPath)
'''3. 1:n 比对事件评估 '''
fpevents = one2n_pr(evtDicts)
fpevents = one2n_pr(evtDicts, pattern=3)
fpErrFile = str(Path(resultPath).joinpath("one2n_fp_Error.txt"))
with open(fpErrFile, "w") as file:
@ -221,14 +242,9 @@ def main():
if __name__ == '__main__':
eventSourcePath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\images"
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result"
eventSourcePath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result\ShoppingDict_pkfile"
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result\contrast"
eventDataPath = os.path.join(resultPath, "evtobjs")
similPath = os.path.join(resultPath, "simidata")

View File

@ -194,6 +194,7 @@ def simi_calc(event, stdfeat):
if len(evtfeat)==0 or len(stdfeat)==0:
return None, None, None
evtfeat /= np.linalg.norm(evtfeat, axis=1)[:, None]
stdfeat /= np.linalg.norm(stdfeat, axis=1)[:, None]
@ -305,8 +306,8 @@ def one2SN_pr(evtList, evtDict, stdDict):
barcodes, similars = [], []
for stdbcd in bcd_selected:
stdfeat = stdDict[stdbcd]
# simi_mean, simi_max, simi_mfeat = simi_calc(event, stdfeat)
simi_mean = calc_simil(event, stdfeat)
simi_mean, simi_max, simi_mfeat = simi_calc(event, stdfeat)
# simi_mean = calc_simil(event, stdfeat)
## 在event.front_feats和event.back_feats同时为空时此处不需要保护
# if simi_mean==None:
@ -629,10 +630,8 @@ if __name__ == '__main__':
stdBarcodePath = r"D:\全实时\source_data\bcdpath"
stdFeaturePath = r"D:\全实时\source_data\stdfeats"
eventSourcePath = [r"D:\全实时\result\pipeline\pipeline"]
resultPath = r"D:\全实时\result\pipeline"
eventSourcePath = [r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result\ShoppingDict_pkfile"]
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result\contrast"
eventDataPath = os.path.join(resultPath, "evtobjs")
similPath = os.path.join(resultPath, "simidata")
if not os.path.exists(eventDataPath):
@ -640,7 +639,7 @@ if __name__ == '__main__':
if not os.path.exists(similPath):
os.makedirs(similPath)
test_one2one()
# test_one2one()
test_one2SN()

View File

@ -76,7 +76,7 @@ def array2list(bboxes):
class ShoppingEvent:
def __init__(self, eventpath, stype="data"):
'''stype: str, 'source', 'data', '''
'''stype: str, 'source', 'data', 'realtime', 共三种 '''
self.eventpath = eventpath
self.evtname = str(Path(eventpath).stem)
@ -167,21 +167,23 @@ class ShoppingEvent:
def from_source_pkl(self, eventpath):
with open(eventpath, 'rb') as f:
ShoppingDict = pickle.load(f)
self.eventpath = ShoppingDict["eventPath"]
self.evtname = ShoppingDict["eventName"]
self.barcode = ShoppingDict["barcode"]
if len(ShoppingDict["one2n"]):
self.one2n = ShoppingDict["one2n"]
'''=========== path of image and video =========== '''
self.back_videopath = ShoppingDict["backCamera"]["videoPath"]
self.front_videopath = ShoppingDict["frontCamera"]["videoPath"]
self.back_imgpaths = ShoppingDict["backCamera"]["imagePaths"]
self.front_imgpaths = ShoppingDict["frontCamera"]["imagePaths"]
'''===========对应于 0/1_track.data ============================='''
backdata, back_outdata = self.kerndata(ShoppingDict, "backCamera")
frontdata, front_outdata = self.kerndata(ShoppingDict, "frontCamera")

111
events/evt_rename.py Normal file
View File

@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 9 14:34:41 2025
@author: ym
"""
import os
def read_deletedBarcode_file(filePath):
with open(filePath, 'r', encoding='utf-8') as f:
lines = f.readlines()
split_flag, all_list = False, []
dict, barcode_list, similarity_list = {}, [], []
clean_lines = [line.strip().replace("'", '').replace('"', '') for line in lines]
for i, line in enumerate(clean_lines):
if line.endswith(','):
line = line[:-1]
stripped_line = line.strip()
if not stripped_line:
if len(barcode_list): dict['barcode'] = barcode_list
if len(similarity_list): dict['similarity'] = similarity_list
if len(dict): all_list.append(dict)
split_flag = False
dict, barcode_list, similarity_list = {}, [], []
continue
if line.find(':')<0: continue
label = line.split(':')[0]
value = line.split(':')[1]
if label == 'SeqDir':
dict['SeqDir'] = value
dict['filetype'] = "deletedBarcode"
if label == 'Deleted':
dict['Deleted'] = value
if label == 'List':
split_flag = True
continue
if split_flag:
barcode_list.append(label)
similarity_list.append(value)
if len(barcode_list): dict['barcode'] = barcode_list
if len(similarity_list): dict['similarity'] = similarity_list
if len(dict): all_list.append(dict)
return all_list
def event_rename(path):
for filename in os.listdir(path):
fpath = os.path.join(path, filename)
if os.path.isfile(fpath): continue
flist = filename.split("_")
if len(flist)==3 and flist[-1].isdigit() and len(flist[-1])>=8:
print(f"{path}: renamed!")
return
dpath = os.path.join(path, "deletedBarcode.txt")
alist = read_deletedBarcode_file(dpath)
input_events, getout_events = [], []
for filename in os.listdir(path):
fpath = os.path.join(path, filename)
if os.path.isfile(fpath): continue
flist = filename.split("_")
bcd = flist[-1]
if len(flist)==2 and flist[0].find("2024")==0 and len(bcd)==0:
bcds = [dt['Deleted'] for dt in alist if dt['SeqDir'].strip()==filename]
if len(bcds)==1:
getout_events.append((filename, filename + bcds[0].strip()))
if len(flist)==2 and flist[0].find("2024")==0 and len(bcd)>=10:
input_events.append((filename, filename + '_' + bcd))
events = (input_events, getout_events)
for evts in events:
for name_old, name_new in evts:
path_old = os.path.join(path, name_old)
path_new = os.path.join(path, name_new)
try:
os.rename(path_old, path_new)
except Exception as e:
print(f"发生错误:{e}")
def main():
path = r"\\192.168.1.28\share\测试视频数据以及日志\测试_202406\0910\images"
event_rename(path)
if __name__ == "__main__":
main()

View File

@ -5,67 +5,48 @@ Created on Sun Sep 29 08:59:21 2024
@author: ym
"""
import os
import sys
# import sys
import cv2
import pickle
import argparse
import numpy as np
from pathlib import Path
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
from tracking.utils.drawtracks import plot_frameID_y2, draw_all_trajectories
from utils.getsource import get_image_pairs, get_video_pairs
def get_interbcd_inputenents():
bcdpath = r"\\192.168.1.28\share\测试_202406\contrast\std_barcodes_2192"
eventpath = r"\\192.168.1.28\share\测试_202406\0918"
barcodes = []
eventpaths = []
for featname in os.listdir(bcdpath):
barcode, ext = os.path.splitext(featname)
barcodes.append(barcode)
input_enents = []
for root, dirs, files in os.walk(eventpath):
input_enent = [os.path.join(root, d) for d in dirs if d.split('_')[-1] in barcodes]
input_enents.extend(input_enent)
from tracking.utils.read_data import read_similar
return input_enents
def save_subimgs(imgdict, boxes, spath, ctype):
for i in range(len(boxes)):
fid, bid = int(boxes[i, 7]), int(boxes[i, 8])
if f"{fid}_{bid}" in imgdict.keys():
img = imgdict[f"{fid}_{bid}"]
imgpath = spath / f"{ctype}_{fid}_{bid}.png"
cv2.imwrite(imgpath, img)
def pipeline(
eventpath,
savepath = '',
SourceType = "image", # video
stdfeat_path = None
savepath,
SourceType,
weights
):
if SourceType == "video":
vpaths = get_video_pairs(eventpath)
elif SourceType == "image":
vpaths = get_image_pairs(eventpath)
'''
eventpath: 单个事件的存储路径
'''
'''======== 函数 yolo_resnet_tracker() 的参数字典 ========'''
opt = parse_opt()
optdict = vars(opt)
if SourceType == "video":
vpaths = get_video_pairs(eventpath)
elif SourceType == "image":
vpaths = get_image_pairs(eventpath)
optdict = {}
optdict["weights"] = weights
optdict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt'
optdict["is_save_img"] = True
optdict["is_save_video"] = True
event_tracks = []
@ -76,21 +57,35 @@ def pipeline(
and evtname.split('_')[-1].isdigit() else ''
'''事件结果存储文件夹'''
if not savepath:
savepath = Path(__file__).resolve().parents[0] / "evtresult"
savepath = Path(__file__).resolve().parents[0] / "events_result"
save_dir_event = Path(savepath) / evtname
savepath_pipeline = Path(savepath) / Path("Yolos_Tracking") / evtname
pickpath = Path(savepath)/"pickfile"
if not pickpath.exists():
pickpath.mkdir(parents=True, exist_ok=True)
"""ShoppingDict pickle 文件保存地址 """
savepath_spdict = Path(savepath) / "ShoppingDict_pkfile"
if not savepath_spdict.exists():
savepath_spdict.mkdir(parents=True, exist_ok=True)
pf_path = Path(savepath_spdict) / Path(str(evtname)+".pickle")
# if pf_path.exists():
# return
ShoppingDict = {"eventPath": eventpath,
"eventName": evtname,
"barcode": barcode,
"eventType": '', # "input", "output", "other"
"frontCamera": {},
"backCamera": {}}
"backCamera": {},
"one2n": []
}
procpath = Path(eventpath).joinpath('process.data')
if procpath.is_file():
SimiDict = read_similar(procpath)
ShoppingDict["one2n"] = SimiDict['one2n']
for vpath in vpaths:
'''相机事件字典构造'''
@ -115,16 +110,20 @@ def pipeline(
'''事件结果存储文件夹'''
if isinstance(vpath, list):
save_dir_video = save_dir_event / Path("images")
savepath_pipeline_imgs = savepath_pipeline / Path("images")
else:
save_dir_video = save_dir_event / Path(str(Path(vpath).stem))
if not save_dir_video.exists():
save_dir_video.mkdir(parents=True, exist_ok=True)
savepath_pipeline_imgs = savepath_pipeline / Path(str(Path(vpath).stem))
if not savepath_pipeline_imgs.exists():
savepath_pipeline_imgs.mkdir(parents=True, exist_ok=True)
savepath_pipeline_subimgs = savepath_pipeline / Path("subimgs")
if not savepath_pipeline_subimgs.exists():
savepath_pipeline_subimgs.mkdir(parents=True, exist_ok=True)
'''Yolo + Resnet + Tracker'''
optdict["source"] = vpath
optdict["save_dir"] = save_dir_video
optdict["save_dir"] = savepath_pipeline_imgs
yrtOut = yolo_resnet_tracker(**optdict)
@ -164,14 +163,31 @@ def pipeline(
CameraEvent["tracking"] = vts
ShoppingDict["frontCamera"] = CameraEvent
# pklpath = save_dir_event / "ShoppingDict.pkl"
# with open(str(pklpath), 'wb') as f:
# pickle.dump(ShoppingDict, f)
pf_path = Path(pickpath) / Path(str(evtname)+".pkl")
with open(str(pf_path), 'wb') as f:
pickle.dump(ShoppingDict, f)
for CamerType, vts in event_tracks:
if len(vts.tracks)==0: continue
if CamerType == 'front':
yolos = ShoppingDict["frontCamera"]["yoloResnetTracker"]
ctype = 1
if CamerType == 'back':
yolos = ShoppingDict["backCamera"]["yoloResnetTracker"]
ctype = 0
imgdict = {}
for y in yolos:
imgdict.update(y["imgs"])
for track in vts.Residual:
if isinstance(track, np.ndarray):
save_subimgs(imgdict, track, savepath_pipeline_subimgs, ctype)
else:
save_subimgs(imgdict, track.boxes, savepath_pipeline_subimgs, ctype)
'''轨迹显示模块'''
illus = [None, None]
for CamerType, vts in event_tracks:
@ -181,24 +197,23 @@ def pipeline(
edgeline = cv2.imread("./tracking/shopcart/cart_tempt/board_ftmp_line.png")
h, w = edgeline.shape[:2]
nh, nw = h//2, w//2
edgeline = cv2.resize(edgeline, (nw, nh), interpolation=cv2.INTER_AREA)
# nh, nw = h//2, w//2
# edgeline = cv2.resize(edgeline, (nw, nh), interpolation=cv2.INTER_AREA)
img_tracking = draw_all_trajectories(vts, edgeline, save_dir_event, CamerType, draw5p=True)
img_tracking = draw_all_trajectories(vts, edgeline, savepath_pipeline, CamerType, draw5p=True)
illus[0] = img_tracking
plt = plot_frameID_y2(vts)
plt.savefig(os.path.join(save_dir_event, "front_y2.png"))
plt.savefig(os.path.join(savepath_pipeline, "front_y2.png"))
if CamerType == 'back':
edgeline = cv2.imread("./tracking/shopcart/cart_tempt/edgeline.png")
h, w = edgeline.shape[:2]
nh, nw = h//2, w//2
edgeline = cv2.resize(edgeline, (nw, nh), interpolation=cv2.INTER_AREA)
# nh, nw = h//2, w//2
# edgeline = cv2.resize(edgeline, (nw, nh), interpolation=cv2.INTER_AREA)
img_tracking = draw_all_trajectories(vts, edgeline, save_dir_event, CamerType, draw5p=True)
img_tracking = draw_all_trajectories(vts, edgeline, savepath_pipeline, CamerType, draw5p=True)
illus[1] = img_tracking
illus = [im for im in illus if im is not None]
@ -208,64 +223,25 @@ def pipeline(
H, W = img_cat.shape[:2]
cv2.line(img_cat, (int(W/2), 0), (int(W/2), int(H)), (128, 128, 255), 3)
trajpath = os.path.join(save_dir_event, "traj.png")
trajpath = os.path.join(savepath_pipeline, "trajectory.png")
cv2.imwrite(trajpath, img_cat)
def main_loop():
bcdpath = r"\\192.168.1.28\share\测试_202406\contrast\std_barcodes_2192"
eventpath = r"\\192.168.1.28\share\测试_202406\0918\images1"
SourceType = "image" # video, image
barcodes = []
input_enents = []
output_events = []
'''1. 获得barcode标准特征集列表'''
for featname in os.listdir(bcdpath):
barcode, ext = os.path.splitext(featname)
if not barcode.isdigit() or len(barcode)<=8 or ext != ".pickle" :
continue
barcodes.append(barcode)
'''2. 构造(放入事件,标准特征)对'''
for filename in os.listdir(eventpath):
'''barcode为时间文件夹的最后一个字段'''
bcd = filename.split('_')[-1]
event_path = os.path.join(eventpath, filename)
stdfeat_path = None
if bcd in barcodes:
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:
parmDict["eventpath"] = eventpath
parmDict["stdfeat_path"] = stdfeat_path
pipeline(**parmDict)
def main():
'''
函数pipeline(),遍历事件文件夹,选择类型 image 或 video,
'''
evtdir = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\images"
evtdir = Path(evtdir)
parmDict = {}
parmDict["savepath"] = r"D:\contrast\202412测试"
parmDict["SourceType"] = "video" # video, image
parmDict["stdfeat_path"] = None
k = 0
errEvents = []
parmDict = {}
evtdir = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\images"
parmDict["SourceType"] = "video" # video, image
parmDict["savepath"] = r"\\192.168.1.28\share\测试视频数据以及日志\算法全流程测试\202412\result"
parmDict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt'
evtdir = Path(evtdir)
k, errEvents = 0, []
for item in evtdir.iterdir():
if item.is_dir():
# item = r"D:\exhibition\images\images2\images2"
# item = evtdir/Path("20241209-160201-b97f7a0e-7322-4375-9f17-c475500097e9_6926265317292")
parmDict["eventpath"] = item
# pipeline(**parmDict)
@ -273,10 +249,9 @@ def main():
pipeline(**parmDict)
except Exception as e:
errEvents.append(str(item))
# k+=1
# if k==1:
# break
k+=1
if k==1:
break
errfile = os.path.join(parmDict["savepath"], f'error_events.txt')
with open(errfile, 'w', encoding='utf-8') as f:

View File

@ -62,6 +62,7 @@ from hands.hand_inference import hand_pose
from contrast.feat_extract.config import config as conf
from contrast.feat_extract.inference import FeatsInterface
ReIDEncoder = FeatsInterface(conf)
IMG_FORMATS = '.bmp', '.dng', '.jpeg', '.jpg', '.mpo', '.png', '.tif', '.tiff', '.webp', '.pfm' # include image suffixes
@ -139,12 +140,8 @@ def init_trackers(tracker_yaml = None, bs=1):
def yolo_resnet_tracker(
weights=ROOT / 'yolov5s.pt', # model path or triton URL
source=ROOT / 'data/images', # file/dir/URL/glob/screen/0(webcam)
project=ROOT / 'runs/detect', # save results to project/name
name='exp', # save results to project/name
save_dir = '',
is_save_img = False,
is_save_img = True,
is_save_video = True,
tracker_yaml = "./tracking/trackers/cfg/botsort.yaml",
@ -154,19 +151,9 @@ def yolo_resnet_tracker(
max_det=1000, # maximum detections per image
device='', # cuda device, i.e. 0 or 0,1,2,3 or cpu
view_img=False, # show results
save_txt=False, # save results to *.txt
save_csv=False, # save results in CSV format
save_conf=False, # save confidences in --save-txt labels
save_crop=False, # save cropped prediction boxes
nosave=False, # do not save images/videos
update=False, # update all models
exist_ok=False, # existing project/name ok, do not increment
classes=None, # filter by class: --class 0, or --class 0 2 3
agnostic_nms=False, # class-agnostic NMS
augment=False, # augmented inference
visualize=False, # visualize features
line_thickness=3, # bounding box thickness (pixels)
hide_labels=False, # hide labels
@ -208,7 +195,7 @@ def yolo_resnet_tracker(
# Inference
with dt[1]:
visualize = increment_path(project / Path(path).stem, mkdir=True) if visualize else False
# visualize = increment_path(project / Path(path).stem, mkdir=True) if visualize else False
pred = model(im, augment=augment, visualize=False)
# NMS
@ -242,15 +229,16 @@ def yolo_resnet_tracker(
# trackerBoxes = np.concatenate([trackerBoxes, tracks], axis=0)
'''================== 1. 存储 dets/subimgs/features Dict ============='''
imgs, features = ReIDEncoder.inference(im0, tracks)
featdict = {}
imgdict, featdict = {}, {}
for ii, bid in enumerate(tracks[:, 8]):
featdict.update({f"{int(frameId)}_{int(bid)}": features[ii, :]}) # [f"feat_{int(bid)}"] = features[i, :]
imgdict.update({f"{int(frameId)}_{int(bid)}": imgs[ii]})
frameDict = {"path": path,
"fid": int(frameId),
"bboxes": det,
"tboxes": tracks,
"imgs": imgs,
"imgs": imgdict,
"feats": featdict}
yoloResnetTracker.append(frameDict)

View File

@ -26,9 +26,53 @@
4. 整体流程仿真
pipeline.py
SourceType: "image", "video", yolo+resent+tracker模块输入数据类型
需要指定是个变量:
(1) evtdir: 保存各个事件的文件夹
(2) SourceType: "image", "video", yolo+resent+tracker模块输入数据类型
(3) savepath: 结果数据保存位置
(4) weights: YoloV5 模型权重
保存为 pickle 文件,该文件可用于 ShoppingEvent 对象构建。
savepath
(1) Yolos_Tracking
eventname文件夹保存yolo+resent+tracker模块输出包括
(1) images 或 {videoname}
(2) subimgs
(3) trajectory
(4) front_y2.png
(5) trajectory.png
(2) ShoppingDict_pkfile
保存 ShoppingDict 字典的 pickle 文件,可用于构造 ShoppingEvent 对象。
(3) contrast
保存1:1、1:SN、1:n数据
(4) error_events.txt
事件字典结构:
ShoppingDict = {"eventPath": eventpath,
"eventName": evtname,
"barcode": barcode,
"eventType": '', # "input", "output", "other"
"frontCamera": {},
"backCamera": {},
"one2n": []
}
相机字典:
CameraEvent = {"cameraType": '', # "front", "back"
"videoPath": '',
"imagePaths": [],
"yoloResnetTracker": [],
"tracking": [],
}
yoloResnetTracker列表元素 "frameDict" 为有关帧数据的字典结构
frameDict = {"path": path,
"fid": int(frameId),
"bboxes": det,
"tboxes": tracks,
"imgs": imgdict,
"feats": featdict}