@@ -44,7 +44,7 @@ def __init__(
4444 a numpy array and returns a numpy array. Default: None
4545 """
4646 super ().__init__ (resolution , fps , adjustments )
47- self .device_index = self ._resolve_camera_id (device )
47+ self .device = self ._resolve_camera_id (device )
4848 self .logger = logger
4949
5050 self ._cap = None
@@ -123,9 +123,9 @@ def _get_video_devices_by_index(self) -> dict[int, str]:
123123
124124 def _open_camera (self ) -> None :
125125 """Open the V4L camera connection."""
126- self ._cap = cv2 .VideoCapture (self .device_index )
126+ self ._cap = cv2 .VideoCapture (self .device )
127127 if not self ._cap .isOpened ():
128- raise CameraOpenError (f"Failed to open V4L camera { self .device_index } " )
128+ raise CameraOpenError (f"Failed to open V4L camera { self .device } " )
129129
130130 self ._cap .set (cv2 .CAP_PROP_BUFFERSIZE , 1 ) # Reduce buffer to minimize latency
131131
@@ -139,7 +139,7 @@ def _open_camera(self) -> None:
139139 actual_height = int (self ._cap .get (cv2 .CAP_PROP_FRAME_HEIGHT ))
140140 if actual_width != self .resolution [0 ] or actual_height != self .resolution [1 ]:
141141 logger .warning (
142- f"Camera { self .device_index } resolution set to { actual_width } x{ actual_height } "
142+ f"Camera { self .device } resolution set to { actual_width } x{ actual_height } "
143143 f"instead of requested { self .resolution [0 ]} x{ self .resolution [1 ]} "
144144 )
145145 self .resolution = (actual_width , actual_height )
@@ -149,10 +149,10 @@ def _open_camera(self) -> None:
149149
150150 actual_fps = int (self ._cap .get (cv2 .CAP_PROP_FPS ))
151151 if actual_fps != self .fps :
152- logger .warning (f"Camera { self .device_index } FPS set to { actual_fps } instead of requested { self .fps } " )
152+ logger .warning (f"Camera { self .device } FPS set to { actual_fps } instead of requested { self .fps } " )
153153 self .fps = actual_fps
154154
155- logger .info (f"Opened V4L camera with index { self .device_index } " )
155+ logger .info (f"Opened V4L camera with index { self .device } " )
156156
157157 def _close_camera (self ) -> None :
158158 """Close the V4L camera connection."""
@@ -167,6 +167,6 @@ def _read_frame(self) -> np.ndarray | None:
167167
168168 ret , frame = self ._cap .read ()
169169 if not ret or frame is None :
170- raise CameraReadError (f"Failed to read from V4L camera { self .device_index } " )
170+ raise CameraReadError (f"Failed to read from V4L camera { self .device } " )
171171
172172 return frame
0 commit comments