You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def get_best_ocr(preds, rec_conf, ocr_res, track_id):
for info in preds:
# Check if it is current track id
if info['track_id'] == track_id:
# Check if the ocr confidenence is maximum or not
if info['ocr_conf'] < rec_conf:
info['ocr_conf'] = rec_conf
info['ocr_txt'] = ocr_res
else:
rec_conf = info['ocr_conf']
ocr_res = info['ocr_txt']
break
return preds, rec_conf, ocr_res
原函数中的逻辑不正确实际上只修改了第一个元素,不会遍历寻找更高置信度的元素,所以进行以下修改:
def update_best_ocr(preds, rec_conf, ocr_res, track_id):
updated = False # 添加一个标志,表示是否更新了信息
for info in preds:
# 查找并更新指定track_id的信息
if info['track_id'] == track_id:
# 直接更新OCR信息,不比较,假设传入的rec_conf和ocr_res是最新的
info['ocr_conf'] = rec_conf
info['ocr_txt'] = ocr_res
updated = True # 标记信息已被更新
break # 找到并更新后,不需要继续循环
The text was updated successfully, but these errors were encountered:
def get_best_ocr(preds, rec_conf, ocr_res, track_id):
for info in preds:
# Check if it is current track id
if info['track_id'] == track_id:
# Check if the ocr confidenence is maximum or not
if info['ocr_conf'] < rec_conf:
info['ocr_conf'] = rec_conf
info['ocr_txt'] = ocr_res
else:
rec_conf = info['ocr_conf']
ocr_res = info['ocr_txt']
break
return preds, rec_conf, ocr_res
原函数中的逻辑不正确实际上只修改了第一个元素,不会遍历寻找更高置信度的元素,所以进行以下修改:
def update_best_ocr(preds, rec_conf, ocr_res, track_id):
updated = False # 添加一个标志,表示是否更新了信息
The text was updated successfully, but these errors were encountered: