共计 2931 个字符,预计需要花费 8 分钟才能阅读完成。
# 比拟后果
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()
正文完