From 9cac92978256da709ca79bafdfedb1ddd0c5266a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=BE=99?= Date: Tue, 25 Jun 2024 20:14:44 +0800 Subject: [PATCH] =?UTF-8?q?windows---=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E5=8A=9F=E8=83=BD=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 2 +- core/ModelManager.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index d8692b6..3d1abf8 100644 --- a/config.yaml +++ b/config.yaml @@ -28,7 +28,7 @@ ALLOWED_EXTENSIONS : {'zip'} RTSP_Check_Time : 600 #10分钟 #model -model_platform : cpu #npu gpu +model_platform : cpu #acl gpu weight_path: /model/weights yolov5_path: D:/Project/FristProject/model/base_model/yolov5 #使用绝对路径,不同的部署环境需要修改! cap_sleep_time: 300 #5分钟 diff --git a/core/ModelManager.py b/core/ModelManager.py index eda7653..2f70979 100644 --- a/core/ModelManager.py +++ b/core/ModelManager.py @@ -12,6 +12,12 @@ from myutils.MyLogger_logger import LogHandler from myutils.ConfigManager import myCongif from model.plugins.ModelBase import ModelBase +import acl +from PIL import Image + +ACL_MEM_MALLOC_HUGE_FIRST = 0 +ACL_MEMCPY_HOST_TO_DEVICE = 1 +ACL_MEMCPY_DEVICE_TO_HOST = 2 class VideoCaptureWithFPS: '''视频捕获的封装类,是一个通道一个''' @@ -65,10 +71,21 @@ class ModelManager: self.frame_interval = 1.0 / int(myCongif.get_data("verify_rate")) #保存视频相关内容 self.fourcc = cv2.VideoWriter_fourcc(*'mp4v') # 使用 mp4 编码 + #基于模型运行环境进行相应初始化工作 + if myCongif.get_data("model_platform") == "acl": + def __del__(self): self.logger.debug("释放资源") + def _init_acl(self): + '''acl初始化函数''' + self.device_id = 0 + #step1 初始化 + ret = acl.init() + + + def _open_view(self,url,itype): #打开摄像头 0--USB摄像头,1-RTSP,2-海康SDK if itype == 0: cap = VideoCaptureWithFPS(int(url))