bakeup
This commit is contained in:
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