From 814a5cfd11282c4f3a35f6b2fd9d892eac18f0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=BE=99?= Date: Mon, 9 Sep 2024 20:35:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=80=9A=E9=81=93=E4=B8=80=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=AE=8C=E6=95=B4=E7=89=88--V1.0=EF=BC=88=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=BA=86=E4=B8=80=E4=BA=9B=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/CapManager.py | 8 +++++++- core/ModelManager.py | 4 ++++ model/plugins/RYRQ_ACL/RYRQ_Model_ACL.py | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/CapManager.py b/core/CapManager.py index 0c10d2d..3b7b869 100644 --- a/core/CapManager.py +++ b/core/CapManager.py @@ -87,7 +87,13 @@ class VideoCaptureWithFPS: self.cap.release() self.bok = False print(f"{self.source}视频流,将于{sleep_time}秒后重连!") - time.sleep(sleep_time) + # 分段休眠,检测 self.running + total_sleep = 0 + while total_sleep < sleep_time: + if not self.running: + return + time.sleep(2) + total_sleep += 2 #释放cap资源,由release调用实现 #resized_frame = cv2.resize(frame, (int(self.width / 2), int(self.height / 2))) diff --git a/core/ModelManager.py b/core/ModelManager.py index 0896388..0e77538 100644 --- a/core/ModelManager.py +++ b/core/ModelManager.py @@ -123,6 +123,10 @@ class ModelManager: #重新读取工作线程数据,重启该通道的工作线程 self.startModelWork(channel_id) + '''模型独立线程修改2024-9-9,要求是双模式兼容''' + def thModel(self): + pass + def test1(self): # from model.plugins.RYRQ_Model_ACL.RYRQ_Model_ACL import Model # mymodel = Model("") diff --git a/model/plugins/RYRQ_ACL/RYRQ_Model_ACL.py b/model/plugins/RYRQ_ACL/RYRQ_Model_ACL.py index 67ab430..ad78942 100644 --- a/model/plugins/RYRQ_ACL/RYRQ_Model_ACL.py +++ b/model/plugins/RYRQ_ACL/RYRQ_Model_ACL.py @@ -48,7 +48,6 @@ class Model(ModelBase): output_torch = torch.tensor(output) boxout = nms(output_torch, conf_thres=0.4,iou_thres=0.5) del output_torch - output_torch = None pred_all = boxout[0].numpy() # 转换为numpy数组 -- [[],[],[]] --[x1,y1,x2,y2,置信度,coco_index] # pred_all[:, :4] 取所有行的前4列,pred_all[:,1]--第一列 scale_coords([640, 640], pred_all[:, :4], image.shape, ratio_pad=(scale_ratio, pad_size)) # 将推理结果缩放到原始图片大小