修复了车牌判断的bug

This commit is contained in:
2025-10-19 19:10:10 +08:00
parent c1fbccd7ee
commit 40f5e1c1be

37
main.py
View File

@@ -1399,18 +1399,10 @@ class MainWindow(QMainWindow):
print(f"车牌ID: {plate_id} 帧数: {frame_count}, 忽略前两帧") print(f"车牌ID: {plate_id} 帧数: {frame_count}, 忽略前两帧")
continue continue
# 检查该识别框是否已经发送过命令 # 检查该识别框ID是否已经发送过命令
if plate_id in self.frame_command_sent: if plate_id in self.frame_command_sent:
# 如果该识别框已发送命令,跳过 print(f"识别框ID: {plate_id} 已发送命令,跳过")
if self.frame_command_sent[plate_id]['command_sent']: continue
continue
else:
# 新的识别框,初始化记录
self.frame_command_sent[plate_id] = {
'plate_number': plate_number,
'command_sent': False
}
# 检查白名单 # 检查白名单
if plate_number not in self.whitelist: if plate_number not in self.whitelist:
@@ -1419,8 +1411,13 @@ class MainWindow(QMainWindow):
message = f"{plate_number} 禁行" message = f"{plate_number} 禁行"
send_command(4, message) send_command(4, message)
print(f"发送道闸命令: {message}") print(f"发送道闸命令: {message}")
# 标记该识别框已发送命令
self.frame_command_sent[plate_id]['command_sent'] = True # 标记该识别框ID已发送命令
self.frame_command_sent[plate_id] = {
'plate_number': plate_number,
'command_sent': True
}
except Exception as e: except Exception as e:
print(f"发送道闸命令失败: {e}") print(f"发送道闸命令失败: {e}")
continue continue
@@ -1438,8 +1435,11 @@ class MainWindow(QMainWindow):
send_command(1, message) send_command(1, message)
print(f"发送道闸命令: {message}") print(f"发送道闸命令: {message}")
# 标记该识别框已发送命令 # 标记该识别框ID已发送命令
self.frame_command_sent[plate_id]['command_sent'] = True self.frame_command_sent[plate_id] = {
'plate_number': plate_number,
'command_sent': True
}
# 标记为已发送并清除记录,使第三次识别时重新按首次处理 # 标记为已发送并清除记录,使第三次识别时重新按首次处理
del self.plate_records[plate_number] del self.plate_records[plate_number]
@@ -1453,8 +1453,11 @@ class MainWindow(QMainWindow):
send_command(1, message) send_command(1, message)
print(f"发送道闸命令: {message}") print(f"发送道闸命令: {message}")
# 标记该识别框已发送命令 # 标记该识别框ID已发送命令
self.frame_command_sent[plate_id]['command_sent'] = True self.frame_command_sent[plate_id] = {
'plate_number': plate_number,
'command_sent': True
}
# 记录车牌信息 # 记录车牌信息
self.plate_records[plate_number] = { self.plate_records[plate_number] = {