ocr1.0
This commit is contained in:
25
rtc/rtc.py
25
rtc/rtc.py
@ -102,23 +102,14 @@ async def frame_consumer(frame_queue):
|
|||||||
while True:
|
while True:
|
||||||
# 从队列中获取cv2帧(队列为空时会阻塞等待新帧)
|
# 从队列中获取cv2帧(队列为空时会阻塞等待新帧)
|
||||||
current_frame = await frame_queue.get()
|
current_frame = await frame_queue.get()
|
||||||
|
has_violation, words, confidences = ocr_detector.detect(current_frame)
|
||||||
ocr_detector.detect(current_frame)
|
# 输出所有检测到的违禁词
|
||||||
|
if has_violation:
|
||||||
|
print(f"测试结果:图片中共检测到 {len(words)} 个违禁词:")
|
||||||
|
for word, conf in zip(words, confidences):
|
||||||
|
print(f"- {word}(置信度:{conf:.4f})")
|
||||||
|
else:
|
||||||
|
print("测试结果:图片中未检测到违禁词")
|
||||||
# 验证这是cv2可以处理的帧
|
|
||||||
# print(f"从队列获取到cv2帧、尺寸: {current_frame.shape}、数据类型: {current_frame.dtype}")
|
|
||||||
|
|
||||||
# 这里可以添加cv2的处理代码,例如显示帧
|
|
||||||
# cv2.imshow('Received Frame', current_frame)
|
|
||||||
# if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
# break
|
|
||||||
|
|
||||||
# print("cv2帧处理完成")
|
|
||||||
|
|
||||||
# 标记任务完成
|
# 标记任务完成
|
||||||
frame_queue.task_done()
|
frame_queue.task_done()
|
||||||
|
Reference in New Issue
Block a user