bakeup
This commit is contained in:
@ -24,7 +24,7 @@ from tracking.utils.drawtracks import plot_frameID_y2, draw_all_trajectories
|
||||
|
||||
from tracking.utils.read_data import extract_data, read_deletedBarcode_file, read_tracking_output, read_returnGoods_file
|
||||
|
||||
from contrast.one2n_contrast import get_relative_paths, one2n_new, read_returnGoods_file
|
||||
from contrast.one2n_contrast import get_contrast_paths, one2n_return
|
||||
from tracking.utils.annotator import TrackAnnotator
|
||||
|
||||
W, H = 1024, 1280
|
||||
@ -362,10 +362,10 @@ def main_loop():
|
||||
saveimgs = True
|
||||
|
||||
if os.path.basename(del_barcode_file).find('deletedBarcode'):
|
||||
relative_paths = get_relative_paths(del_barcode_file, basepath, SavePath, saveimgs)
|
||||
relative_paths = get_contrast_paths(del_barcode_file, basepath, SavePath, saveimgs)
|
||||
elif os.path.basename(del_barcode_file).find('returnGoods'):
|
||||
blist = read_returnGoods_file(del_barcode_file)
|
||||
errpairs, corrpairs, err_similarity, correct_similarity = one2n_new(blist)
|
||||
errpairs, corrpairs, err_similarity, correct_similarity = one2n_return(blist)
|
||||
relative_paths = []
|
||||
for getoutevent, inputevent, errevent in errpairs:
|
||||
relative_paths.append(os.path.join(basepath, getoutevent))
|
||||
@ -412,13 +412,13 @@ def main():
|
||||
SavePath: 包含二级目录,一级目录为轨迹图像;二级目录为与data文件对应的序列图像存储地址。
|
||||
'''
|
||||
# eventPaths = r'\\192.168.1.28\share\测试_202406\0723\0723_3'
|
||||
eventPaths = r'D:\datasets\ym\exhibition\识别错'
|
||||
savePath = r'D:\contrast\dataset\result'
|
||||
eventPaths = r'\\192.168.1.28\share\测试视频数据以及日志\各模块测试记录\展厅测试\1120_展厅模型v801测试\扫A放A'
|
||||
savePath = r'D:\exhibition\result'
|
||||
|
||||
k=0
|
||||
for pathname in os.listdir(eventPaths):
|
||||
pathname = "放入薯片识别为辣条"
|
||||
|
||||
pathname = "20241121-144901-fdba61c6-aefa-4b50-876d-5e05998befdc_6920459905012_6920459905012"
|
||||
|
||||
eventpath = os.path.join(eventPaths, pathname)
|
||||
savepath = os.path.join(savePath, pathname)
|
||||
if not os.path.exists(savepath):
|
||||
|
Binary file not shown.
@ -10,8 +10,15 @@ from .utils import matching
|
||||
# from .utils.gmc import GMC
|
||||
from .utils.kalman_filter import KalmanFilterXYWH
|
||||
|
||||
from .reid.reid_interface import ReIDInterface
|
||||
from .reid.config import config
|
||||
# from .reid.reid_interface import ReIDInterface
|
||||
# from .reid.config import config
|
||||
|
||||
from contrast.feat_extract.inference import FeatsInterface
|
||||
from contrast.feat_extract.config import config as conf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BOTrack(STrack):
|
||||
shared_kalman = KalmanFilterXYWH()
|
||||
@ -111,7 +118,9 @@ class BOTSORT(BYTETracker):
|
||||
|
||||
if args.with_reid:
|
||||
# Haven't supported BoT-SORT(reid) yet
|
||||
self.encoder = ReIDInterface(config)
|
||||
# self.encoder = ReIDInterface(config)
|
||||
|
||||
self.encoder = FeatsInterface(conf)
|
||||
|
||||
# self.gmc = GMC(method=args.gmc_method) # commented by WQG
|
||||
|
||||
@ -119,13 +128,13 @@ class BOTSORT(BYTETracker):
|
||||
"""Returns an instance of KalmanFilterXYWH for object tracking."""
|
||||
return KalmanFilterXYWH()
|
||||
|
||||
def init_track(self, dets, scores, cls, imgs, features_keep):
|
||||
def init_track(self, dets, scores, cls, image, features_keep):
|
||||
"""Initialize track with detections, scores, and classes."""
|
||||
if len(dets) == 0:
|
||||
return []
|
||||
if self.args.with_reid and self.encoder is not None:
|
||||
if features_keep is None:
|
||||
features_keep = self.encoder.inference(imgs, dets)
|
||||
imgs, features_keep = self.encoder.inference(image, dets)
|
||||
|
||||
return [BOTrack(xyxy, s, c, f) for (xyxy, s, c, f) in zip(dets, scores, cls, features_keep)] # detections
|
||||
else:
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,9 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Jul 5 13:59:21 2024
|
||||
func: extract_data()
|
||||
读取 Pipeline 各模块的数据,在 read_pipeline_data.py(马晓慧)的基础上完成接口改造
|
||||
|
||||
函数 读取文件
|
||||
extract_data() 0/1_track.data
|
||||
read_tracking_output() 0/1_tracking_output.data
|
||||
read_similar() process.data
|
||||
|
||||
@author: ym
|
||||
"""
|
||||
import numpy as np
|
||||
@ -275,6 +277,7 @@ def read_returnGoods_file(filePath):
|
||||
continue
|
||||
if split_flag:
|
||||
bcd = label.split('_')[-1]
|
||||
if len(bcd)<8: continue
|
||||
# event_list.append(label + '_' + bcd)
|
||||
event_list.append(label)
|
||||
barcode_list.append(bcd)
|
||||
@ -294,47 +297,78 @@ def read_returnGoods_file(filePath):
|
||||
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# def read_seneor(filepath):
|
||||
# WeightDict = OrderedDict()
|
||||
# with open(filepath, 'r', encoding='utf-8') as f:
|
||||
# lines = f.readlines()
|
||||
# for i, line in enumerate(lines):
|
||||
# line = line.strip()
|
||||
#
|
||||
# keyword = line.split(':')[0]
|
||||
# value = line.split(':')[1]
|
||||
#
|
||||
# vdata = [float(s) for s in value.split(',') if len(s)]
|
||||
#
|
||||
# WeightDict[keyword] = vdata[-1]
|
||||
#
|
||||
# return WeightDict
|
||||
# =============================================================================
|
||||
|
||||
def read_one2one_simi(filePath):
|
||||
def read_seneor(filepath):
|
||||
WeightDict = OrderedDict()
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
clean_lines = [line.strip().replace("'", '').replace('"', '') for line in lines]
|
||||
for i, line in enumerate(clean_lines):
|
||||
line = line.strip()
|
||||
|
||||
keyword = line.split(':')[0]
|
||||
value = line.split(':')[1]
|
||||
|
||||
vdata = [float(s) for s in value.split(',') if len(s)]
|
||||
|
||||
WeightDict[keyword] = vdata[-1]
|
||||
|
||||
return WeightDict
|
||||
|
||||
def read_similar(filePath):
|
||||
SimiDict = {}
|
||||
SimiDict['one2one'] = []
|
||||
SimiDict['one2n'] = []
|
||||
|
||||
with open(filePath, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
flag = False
|
||||
for i, line in enumerate(lines):
|
||||
clean_lines = [line.strip().replace("'", '').replace('"', '') for line in lines]
|
||||
one2one_list, one2n_list = [], []
|
||||
|
||||
Flag_1to1, Flag_1ton = False, False
|
||||
for i, line in enumerate(clean_lines):
|
||||
line = line.strip()
|
||||
if line.find('barcode:')<0 and not flag:
|
||||
if line.endswith(','):
|
||||
line = line[:-1]
|
||||
Dict = {}
|
||||
|
||||
|
||||
if not line:
|
||||
if len(one2one_list): SimiDict['one2one'] = one2one_list
|
||||
if len(one2n_list): SimiDict['one2n'] = one2n_list
|
||||
one2one_list, one2n_list = [], []
|
||||
Flag_1to1, Flag_1ton = False, False
|
||||
continue
|
||||
if line.find('barcode:')==0 :
|
||||
flag = True
|
||||
|
||||
if line.find('oneToOne')>=0:
|
||||
Flag_1to1, Flag_1ton = True, False
|
||||
continue
|
||||
if line.find('oneTon')>=0:
|
||||
Flag_1to1, Flag_1ton = False, True
|
||||
continue
|
||||
|
||||
# if line.endswith(','):
|
||||
# line = line[:-1]
|
||||
if flag:
|
||||
if Flag_1to1:
|
||||
barcode = line.split(',')[0].strip()
|
||||
value = line.split(',')[1].split(':')[1].strip()
|
||||
SimiDict[barcode] = float(value)
|
||||
Dict['barcode'] = barcode
|
||||
Dict['similar'] = float(value)
|
||||
one2one_list.append(Dict)
|
||||
continue
|
||||
|
||||
if flag and not line:
|
||||
flag = False
|
||||
if Flag_1ton:
|
||||
label = line.split(':')[0].strip()
|
||||
value = line.split(':')[1].strip()
|
||||
|
||||
bcd = label.split('_')[-1]
|
||||
if len(bcd)<8: continue
|
||||
|
||||
Dict['event'] = label
|
||||
Dict['barcode'] = bcd
|
||||
Dict['similar'] = float(value.split(',')[0])
|
||||
Dict['type'] = value.split('=')[-1]
|
||||
one2n_list.append(Dict)
|
||||
|
||||
if len(one2one_list): SimiDict['one2one'] = one2one_list
|
||||
if len(one2n_list): SimiDict['one2n'] = one2n_list
|
||||
|
||||
return SimiDict
|
||||
|
||||
|
Reference in New Issue
Block a user