开始写 monitor_and_analyse 方法
This commit is contained in:
parent
8ac24740db
commit
41e96084b8
|
@ -642,10 +642,3 @@ def snap_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
||||||
})
|
})
|
||||||
if event:
|
if event:
|
||||||
notify_event(event)
|
notify_event(event)
|
||||||
|
|
||||||
|
|
||||||
def loop_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
|
||||||
# 启动rtsp轮询进行算法识别
|
|
||||||
pass
|
|
||||||
# cates = EventCate.objects.filter(loop_on=True, self_algo=True)
|
|
||||||
# AlgoChannel.objects.filter(algo__loop_on=True, algo__self_algo=True).values('algo__code', 'vchannel')
|
|
||||||
|
|
|
@ -117,3 +117,45 @@ def opl_task(vc_codes: list, opl_id: str):
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
opl.mtask_uid = None
|
opl.mtask_uid = None
|
||||||
opl.save()
|
opl.save()
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task(base=CustomTask)
|
||||||
|
def monitor_and_analyse(vchannel_code: str, algo_codes: list):
|
||||||
|
"""rtsp流监控进行算法识别
|
||||||
|
|
||||||
|
Args:
|
||||||
|
vchannel_code (str): 视频通道编号
|
||||||
|
algo_codes (list): 算法代号
|
||||||
|
"""
|
||||||
|
# cates = EventCate.objects.filter(loop_on=True, self_algo=True)
|
||||||
|
# AlgoChannel.objects.filter(algo__loop_on=True, algo__self_algo=True).values('algo__code', 'vchannel')
|
||||||
|
import cv2
|
||||||
|
# RTSP URL
|
||||||
|
rtsp_url = dhClient.get_rtsp(vchannel_code)
|
||||||
|
# 打开RTSP流
|
||||||
|
cap = cv2.VideoCapture(rtsp_url)
|
||||||
|
# 检查是否成功打开
|
||||||
|
if not cap.isOpened():
|
||||||
|
print("Error opening video stream or file")
|
||||||
|
|
||||||
|
# 循环读取帧
|
||||||
|
while cap.isOpened():
|
||||||
|
ret, frame = cap.read()
|
||||||
|
|
||||||
|
if not ret:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 在这里可以对每一帧进行处理
|
||||||
|
|
||||||
|
# 显示帧
|
||||||
|
cv2.namedWindow("Frame", 0)
|
||||||
|
cv2.resizeWindow("Frame", 1600, 900)
|
||||||
|
cv2.imshow("Frame", frame)
|
||||||
|
|
||||||
|
# 按 'q' 键退出
|
||||||
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||||
|
break
|
||||||
|
|
||||||
|
# 释放资源
|
||||||
|
cap.release()
|
||||||
|
cv2.destroyAllWindows()
|
Loading…
Reference in New Issue