deep_sort 提升版本

This commit is contained in:
2025-06-11 16:19:38 +08:00
parent 9e99b08d13
commit ca245e4cec
47 changed files with 114 additions and 3644 deletions

View File

@ -1,3 +1,4 @@
import cv2
import time
import asyncio
from pathlib import Path
@ -97,11 +98,10 @@ class YoloModel:
conf=0.6
)
def predict_rtsp(self, source, detect_id):
def predict_rtsp(self, source, room_name):
"""
对rtsp视频流进行预测
"""
room_name = 'detect_rtsp_' + str(detect_id)
start_time = time.time()
for result in self.model.predict(source=source, stream=True, device='0', conf=0.6):
# 检查是否已经超过10分钟600秒
@ -109,5 +109,7 @@ class YoloModel:
if elapsed_time > 600: # 600 seconds = 10 minutes
break
frame = result.plot()
frame_data = frame.tobytes()
asyncio.run(room_manager.send_stream_to_room(room_name, frame_data))
ret, jpeg = cv2.imencode('.jpg', frame)
if ret:
frame_data = jpeg.tobytes()
asyncio.run(room_manager.send_stream_to_room(room_name, frame_data))