界面修改以及显示
This commit is contained in:
45
controller/camera_controller.py
Normal file
45
controller/camera_controller.py
Normal file
@ -0,0 +1,45 @@
|
||||
# controller/camera_controller.py
|
||||
from view.widgets.vibration_video_widget import VibrationVideoWidget
|
||||
from .config_loader import load_camera_config
|
||||
|
||||
class CameraController:
|
||||
def __init__(self, video_view: VibrationVideoWidget):
|
||||
self.video_view = video_view
|
||||
self._init_camera_configs()
|
||||
|
||||
def _init_camera_configs(self):
|
||||
try:
|
||||
# 加载配置
|
||||
cam1_config = load_camera_config("上位料斗")
|
||||
cam2_config = load_camera_config("下位料斗")
|
||||
cam3_config = load_camera_config("模具车")
|
||||
|
||||
# print("rtsp_url1:", cam1_config["rtsp_url"])
|
||||
# print("rtsp_url2:", cam2_config["rtsp_url"])
|
||||
# print("rtsp_url3:", cam3_config["rtsp_url"])
|
||||
|
||||
# 设置 camera_urls
|
||||
self.video_view.set_camera_urls(
|
||||
cam1_url=cam1_config["rtsp_url"],
|
||||
cam2_url=cam2_config["rtsp_url"],
|
||||
cam3_url=cam3_config["rtsp_url"]
|
||||
)
|
||||
|
||||
# 初始化视频流
|
||||
self.video_view.init_streams()
|
||||
|
||||
self._connect_signals()
|
||||
|
||||
except Exception as e:
|
||||
print(f"初始化摄像头配置失败: {e}")
|
||||
|
||||
def _connect_signals(self):
|
||||
# 流Stream的异常错误 触发 显示重连按钮
|
||||
self.video_view.stream1.error_signal.connect(lambda name, msg: self.video_view.onStreamError(name))
|
||||
self.video_view.stream2.error_signal.connect(lambda name, msg: self.video_view.onStreamError(name))
|
||||
self.video_view.stream3.error_signal.connect(lambda name, msg: self.video_view.onStreamError(name))
|
||||
|
||||
# 视频显示模组的 重连信号 连接 流Stream的重连函数
|
||||
self.video_view.cam1.reset_signal.connect(self.video_view.stream1.reset_retry)
|
||||
self.video_view.cam2.reset_signal.connect(self.video_view.stream2.reset_retry)
|
||||
self.video_view.cam3.reset_signal.connect(self.video_view.stream3.reset_retry)
|
||||
Reference in New Issue
Block a user