# 比拟后果def compareResult(resCls, firstDict, imgName, resultList, resultProcess): # 如果resultDict的长度等于3: if len(resCls) == 3: if (sum(resCls) != 0) and (0 in resCls): if firstDict: firstResult = firstDict[0]['video_result'][0]['result'] firstImageName, currentImageName = firstImageName2currentImageName(firstDict, imgName) if len(firstResult['cls']) >= 2 and resultProcess.similarityComparison(firstDict)<0.3 and (int(currentImageName) - int(firstImageName)) > 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔大于4秒,则保留该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() elif len(firstResult['cls']) == 1 and firstResult['cls'][0] == 0 and resultProcess.getIou(firstResult, resultList)<0.3 and (int(currentImageName) - int(firstImageName)) < 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔小于4秒,则保留该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() else: # 如果resCls的长度大于等于2,且不全为0的话则画图展现并且上报 resultProcess.filterResult() # 如果resultDict的长度等于2: elif len(resCls) == 2: if (sum(resCls) != 0) and (0 in resCls): if firstDict: firstResult = firstDict[0]['video_result'][0]['result'] firstImageName, currentImageName = firstImageName2currentImageName(firstDict, imgName) if len(firstResult['cls']) >= 2 and resultProcess.similarityComparison(firstDict) < 0.3 and (int(currentImageName) - int(firstImageName)) > 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔大于4秒,则保留该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() elif len(firstResult['cls']) == 1 and firstResult['cls'][0] == 0 and resultProcess.getIou(firstResult, resultList)<0.3 and (int(currentImageName) - int(firstImageName)) < 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔小于4秒,则保留该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() else: resultProcess.filterResult() else: # 如果resCls的长度大于等于2,且不全为0的话则画图展现并且上报 resultProcess.filterResult() elif (sum(resCls) != 0) and (0 not in resCls) and (1 not in resCls): if firstDict: firstImageName, currentImageName = firstImageName2currentImageName(firstDict, imgName) if (int(currentImageName) - int(firstImageName)) > 4: resultProcess.filterResult() else: pass else: # 如果resultDict的长度等于1 if len(resCls) == 1 and (resCls[0] != 0): # 如果resCls的长度等于1, resCls的类别不是0,则必须要有firstDict,如果firstDict的长度大于等于2, 与之比拟 if firstDict: firstResult = firstDict[0]['video_result'][0]['result'] if len(firstResult['cls']) >= 2: # 上一条记录的img_name firstImageName, currentImageName = firstImageName2currentImageName(firstDict, imgName) # 如果上一条记录为0 if firstResult['cls'][0] == 0 and resultProcess.getIou(firstResult, resultList) <0.3 and (int(currentImageName) - int(firstImageName)) < 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔小于4秒,则删除该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() # 如果resCls的长度等于1, resCls的类别不是0,则必须要有firstDict,如果firstDict的长度等于1, 与之比拟 elif len(firstResult['cls']) == 1: if firstResult['cls'][0] == 0: # 上一条记录的imgName firstImageName, currentImageName = firstImageName2currentImageName(firstDict, imgName) iou = resultProcess.getIou(firstResult, resultList) # fixme: 留神此处是相交的 iou<0.3 if iou < 0.3 and (int(currentImageName) - int(firstImageName)) < 4 and sum(resCls) != 0: # 如果前一条记录与以后的记录相隔小于4秒,则保留该条记录 # 如果resCls的长度大于等于2,且不全为0 的话 resultProcess.filterResult() else: pass else: if len(resCls) > 3: resultProcess.saveSendResult()