This commit is contained in:
2025-09-03 13:52:24 +08:00
parent 8cb8e5f935
commit eb5cf715ec
5 changed files with 273 additions and 97 deletions

View File

@ -2,6 +2,17 @@ import asyncio
import logging
import cv2
import time
from ocr.ocr_violation_detector import OCRViolationDetector
import logging
# 创建检测器实例
detector = OCRViolationDetector(
forbidden_words_path=r"D:\Git\bin\video\ocr\forbidden_words.txt",
ocr_confidence_threshold=0.7,
log_level=logging.INFO,
log_file="ocr_detection.log"
)
# 配置日志与WHEP代码保持一致的日志风格
logging.basicConfig(level=logging.INFO)
@ -67,6 +78,15 @@ async def rtmp_pull_video_stream(rtmp_url):
print(f" 帧尺寸: {width}x{height}")
print(f" 配置帧率: {fps:.2f} FPS")
has_violation, violations, confidences = OCRViolationDetector.detect(frame)
# 输出检测结果
if has_violation:
detector.logger.info(f"在图片中检测到 {len(violations)} 个违禁词:")
for word, conf in zip(violations, confidences):
detector.logger.info(f"- {word} (置信度: {conf:.4f})")
else:
detector.logger.info("图片中未检测到违禁词")
# 7. 每100帧统计一次实际接收帧率补充性能监控与原RTMP示例逻辑一致
if frame_count % 100 == 0:
elapsed_time = time.time() - start_time