only keep sync pipeline

This commit is contained in:
unknown
2026-01-01 10:13:50 +08:00
parent fc0025650f
commit ce39d4004f
2 changed files with 81 additions and 5 deletions
+14 -1
View File
@@ -514,7 +514,20 @@ class Sensor:
def _open_video_source(self, override, box):
"""Initialize video capture and calibration."""
self.cap = cv2.VideoCapture(self.vid_src)
# Use DirectShow backend on Windows for cameras (more stable than MSMF)
if isinstance(self.vid_src, int):
# For camera indices, try DirectShow first (avoids MSMF errors)
try:
self.cap = cv2.VideoCapture(self.vid_src, cv2.CAP_DSHOW)
except:
# Fallback to default backend
self.cap = cv2.VideoCapture(self.vid_src)
else:
# For file paths, use default backend
self.cap = cv2.VideoCapture(self.vid_src)
# Set buffer size to 1 to reduce latency and avoid frame accumulation
self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'))
self.cap.set(cv2.CAP_PROP_FPS, self._config_fps)
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, self._config_resolution_raw[0])