Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALPR_inference中函数部分代码修改 #929

Open
jiangjq907 opened this issue Jul 6, 2024 · 0 comments
Open

ALPR_inference中函数部分代码修改 #929

jiangjq907 opened this issue Jul 6, 2024 · 0 comments

Comments

@jiangjq907
Copy link

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  # 找到并更新后,不需要继续循环
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant