From d2411c96798f57604177f2d2175c11e90690115e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=96=B5?= Date: Tue, 30 Jun 2026 17:48:16 +0800 Subject: [PATCH] =?UTF-8?q?2026.6.30=E5=B0=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infer_camera_modular.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infer_camera_modular.py b/infer_camera_modular.py index d4747d5..f52a4cd 100644 --- a/infer_camera_modular.py +++ b/infer_camera_modular.py @@ -97,7 +97,8 @@ class VideoStreaming: """ 打开摄像头或 RTSP 流,并设置低延迟参数 """ try: self.logger.info("正在连接视频源: %s", self.video_source) - self.cap = cv2.VideoCapture(self.video_source) + os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = 'rtsp_transport;tcp' + self.cap = cv2.VideoCapture(self.video_source, cv2.CAP_FFMPEG) if self.is_rtsp: # 设置 RTSP 缓冲区大小(只保留 1 帧,降低延迟)