diff --git a/rtc/rtc.py b/rtc/rtc.py index a160765..09f913f 100644 --- a/rtc/rtc.py +++ b/rtc/rtc.py @@ -102,23 +102,14 @@ async def frame_consumer(frame_queue): while True: # 从队列中获取cv2帧(队列为空时会阻塞等待新帧) current_frame = await frame_queue.get() - - ocr_detector.detect(current_frame) - - - - - - - # 验证这是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帧处理完成") + has_violation, words, confidences = 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("测试结果:图片中未检测到违禁词") # 标记任务完成 frame_queue.task_done()