rebuild
This commit is contained in:
84
tools/threshold_partition.py
Normal file
84
tools/threshold_partition.py
Normal file
@ -0,0 +1,84 @@
|
||||
'''
|
||||
现场1:N测试,确定阈值
|
||||
'''
|
||||
import os
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def showHist(filtered_data):
|
||||
Same = filtered_data[:, 1].astype(np.float32)
|
||||
Cross = filtered_data[:, 2].astype(np.float32)
|
||||
|
||||
fig, axs = plt.subplots(2, 1)
|
||||
axs[0].hist(Same, bins=50, edgecolor='black')
|
||||
axs[0].set_xlim([-0.1, 1])
|
||||
axs[0].set_title('first')
|
||||
|
||||
axs[1].hist(Cross, bins=50, edgecolor='black')
|
||||
axs[1].set_xlim([-0.1, 1])
|
||||
axs[1].set_title('second')
|
||||
# plt.savefig('plot.png')
|
||||
plt.show()
|
||||
|
||||
|
||||
def get_tartget_list(nested_list):
|
||||
filtered_list = np.array(list(filter(lambda x: len(x) >= 2, nested_list))) # 去除无轨迹的数据
|
||||
filtered_correct = filtered_list[filtered_list[:, 0] != 'wrong'] # 获取比对正确的时项
|
||||
filtered_wrong = filtered_list[filtered_list[:, 0] == 'wrong'] # 获取比对错误的时项
|
||||
showHist(filtered_correct)
|
||||
# showHist(filtered_wrong)
|
||||
print(filtered_list)
|
||||
|
||||
|
||||
def deal_process(file_pth):
|
||||
flag = False
|
||||
event = file_pth.split('\\')[-2]
|
||||
target_barcode = file_pth.split('\\')[-2].split('_')[-1]
|
||||
temp_list = []
|
||||
|
||||
with open(file_pth, 'r') as f:
|
||||
for line in f:
|
||||
if 'oneToOne' in line:
|
||||
flag = True
|
||||
continue
|
||||
if flag:
|
||||
line = line.replace('\n', '')
|
||||
comparison_data = line.split(',')
|
||||
forecast_barcode = comparison_data[0]
|
||||
value = comparison_data[-1].split(':')[-1]
|
||||
if value == '':
|
||||
break
|
||||
if len(temp_list) == 0:
|
||||
if forecast_barcode == target_barcode:
|
||||
temp_list.append('correct')
|
||||
else:
|
||||
temp_list.append('wrong')
|
||||
temp_list.append(float(value))
|
||||
temp_list.append(event)
|
||||
return temp_list
|
||||
|
||||
|
||||
def anaylze_scratch(scratch_pth):
|
||||
purchase, back = [], []
|
||||
for root, dirs, files in os.walk(scratch_pth):
|
||||
if len(root) > 0:
|
||||
if len(root.split('_')) == 4: # 加购
|
||||
process = os.path.join(root, 'process.data')
|
||||
if not os.path.exists(process):
|
||||
continue
|
||||
purchase.append(deal_process(process))
|
||||
elif len(root.split('_')) == 3:
|
||||
process = os.path.join(root, 'process.data')
|
||||
if not os.path.exists(process):
|
||||
continue
|
||||
back.append(deal_process(process))
|
||||
# get_tartget_list(purchase)
|
||||
get_tartget_list(back)
|
||||
print(purchase)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# scratch_pth = r'\\192.168.1.28\\share\\测试视频数据以及日志\\各模块测试记录\\展厅测试\\1108_展厅模型v800测试\\'
|
||||
scratch_pth = r'\\192.168.1.28\\share\\测试视频数据以及日志\\各模块测试记录\\展厅测试\\1120_展厅模型v801测试\\扫A放A\\'
|
||||
anaylze_scratch(scratch_pth)
|
Reference in New Issue
Block a user