update one2n.py

This commit is contained in:
王庆刚
2025-02-24 18:56:54 +08:00
parent 64248b1557
commit b657be729b
22 changed files with 279 additions and 123 deletions

View File

@ -24,7 +24,7 @@ def init_eventdict(sourcePath, stype="data"):
# bname = r"20241126-135911-bdf91cf9-3e9a-426d-94e8-ddf92238e175_6923555210479"
source_path = os.path.join(sourcePath, bname)
if stype=="data":
if stype=="data" or stype=="realtime":
pickpath = os.path.join(eventDataPath, f"{bname}.pickle")
if not os.path.isdir(source_path) or os.path.isfile(pickpath):
continue
@ -32,7 +32,12 @@ def init_eventdict(sourcePath, stype="data"):
pickpath = os.path.join(eventDataPath, bname)
if not os.path.isfile(source_path) or os.path.isfile(pickpath):
continue
evt = os.path.splitext(os.path.split(pickpath)[-1])[0].split('_')
cont = len(evt)>=2 and evt[-1].isdigit() and len(evt[-1])>=10
if not cont:
continue
try:
event = ShoppingEvent(source_path, stype)
@ -46,10 +51,10 @@ def init_eventdict(sourcePath, stype="data"):
# if k==1:
# break
errfile = os.path.join(resultPath, 'error_events.txt')
with open(errfile, 'a', encoding='utf-8') as f:
for line in errEvents:
f.write(line + '\n')
# errfile = os.path.join(resultPath, 'error_events.txt')
# with open(errfile, 'a', encoding='utf-8') as f:
# for line in errEvents:
# f.write(line + '\n')
def read_eventdict(eventDataPath):
evtDict = {}
@ -236,14 +241,22 @@ def one2n_pr(evtDicts, pattern=1):
def main():
'''1. 生成事件字典并保存至 eventDataPath, 只需运行一次 '''
init_eventdict(eventSourcePath, stype="data")
init_eventdict(eventSourcePath, stype="source") # 'source', 'data', 'realtime'
# for pfile in os.listdir(eventDataPath):
# evt = os.path.splitext(pfile)[0].split('_')
# cont = len(evt)>=2 and evt[-1].isdigit() and len(evt[-1])>=10
# if not cont:
# continue
'''2. 读取事件字典 '''
evtDicts = read_eventdict(eventDataPath)
'''3. 1:n 比对事件评估 '''
fpevents = one2n_pr(evtDicts, pattern=1)
fpevents = one2n_pr(evtDicts, pattern=2)
fpErrFile = str(Path(resultPath).joinpath("one2n_fp_Error.txt"))
with open(fpErrFile, "w") as file:
@ -253,10 +266,10 @@ def main():
if __name__ == '__main__':
eventSourcePath = r"\\192.168.1.28\share\测试视频数据以及日志\海外展厅测试数据\比对数据"
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\海外展厅测试数据\testing"
eventSourcePath = r"\\192.168.1.28\share\测试视频数据以及日志\全实时测试\result_V12\ShoppingDict_pkfile"
resultPath = r"\\192.168.1.28\share\测试视频数据以及日志\全实时测试\testing"
eventDataPath = os.path.join(resultPath, "evtobjs")
eventDataPath = os.path.join(resultPath, "evtobjs_data")
if not os.path.exists(eventDataPath):
os.makedirs(eventDataPath)