Merge branch 'jetson' into dev
This commit is contained in:
+11
-5
@@ -146,7 +146,11 @@ class Sensor:
|
||||
self._av_stream = None
|
||||
self._av_decoder = None
|
||||
self.cap = None
|
||||
self._is_live_camera = isinstance(self.vid_src, int)
|
||||
# Treat both camera index (0) and V4L2 path ("/dev/video0") as live camera for threading/low-latency path.
|
||||
self._is_live_camera = (
|
||||
isinstance(self.vid_src, int)
|
||||
or (isinstance(self.vid_src, str) and self.vid_src.startswith("/dev/video"))
|
||||
)
|
||||
self._capture_thread = None
|
||||
self._capture_running = False
|
||||
self._latest_frame = None
|
||||
@@ -468,14 +472,18 @@ class Sensor:
|
||||
|
||||
def _open_video_source(self, override, box):
|
||||
"""Initialize video capture and calibration."""
|
||||
_is_camera_index = isinstance(self.vid_src, int)
|
||||
_is_v4l2_path = isinstance(self.vid_src, str) and self.vid_src.startswith("/dev/video")
|
||||
use_linux_camera_pyav = (
|
||||
platform.system() == "Linux"
|
||||
and isinstance(self.vid_src, int)
|
||||
and (_is_camera_index or _is_v4l2_path)
|
||||
and av is not None
|
||||
)
|
||||
|
||||
if use_linux_camera_pyav:
|
||||
device = f"/dev/video{self.vid_src}"
|
||||
device = self.vid_src if _is_v4l2_path else f"/dev/video{self.vid_src}"
|
||||
if self.verbose:
|
||||
print(f"Using PyAV Linux camera backend: {device}")
|
||||
try:
|
||||
self._av_container = av.open(
|
||||
device,
|
||||
@@ -489,8 +497,6 @@ class Sensor:
|
||||
self._av_stream = self._av_container.streams.video[0]
|
||||
self._av_decoder = self._av_container.decode(self._av_stream)
|
||||
self._use_pyav = True
|
||||
if self.verbose:
|
||||
print(f"Using PyAV Linux camera backend: {device}")
|
||||
except Exception as exc:
|
||||
if self.verbose:
|
||||
print(f"PyAV camera open failed ({exc}), fallback to OpenCV backend.")
|
||||
|
||||
Reference in New Issue
Block a user