ocr1.0
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
from ultralytics import YOLO
|
||||
import cv2
|
||||
from logger_config import logger
|
||||
|
||||
class ViolationDetector:
|
||||
"""
|
||||
@ -13,9 +12,9 @@ class ViolationDetector:
|
||||
Args:
|
||||
model_path (str): YOLO .pt模型的路径。
|
||||
"""
|
||||
logger.info(f"正在从 '{model_path}' 加载YOLO模型...")
|
||||
print(f"正在从 '{model_path}' 加载YOLO模型...")
|
||||
self.model = YOLO(model_path)
|
||||
logger.info("YOLO模型加载成功。")
|
||||
print("YOLO模型加载成功。")
|
||||
|
||||
def detect(self, frame):
|
||||
"""
|
||||
@ -45,4 +44,4 @@ class ViolationDetector:
|
||||
"""
|
||||
# 使用YOLO自带的plot功能,方便快捷
|
||||
annotated_frame = result.plot()
|
||||
return annotated_frame
|
||||
return annotated_frame
|
Reference in New Issue
Block a user