Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/om1_vlm/anonymizationSys/face_recog_stream/camera_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import subprocess
from typing import Optional

import cv2
Expand Down Expand Up @@ -79,6 +80,31 @@ def open_capture(
self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
self.cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 3)

try:
subprocess.run(
[
"v4l2-ctl",
"-d",
device,
"--set-ctrl=exposure_dynamic_framerate=1",
],
check=True,
capture_output=True,
text=True,
)
logging.info("Enabled exposure_dynamic_framerate on %s", device)
except FileNotFoundError:
logging.warning(
"v4l2-ctl not found; install v4l-utils to enable "
"exposure_dynamic_framerate"
)
except subprocess.CalledProcessError as e:
logging.warning(
"Failed to set exposure_dynamic_framerate on %s: %s",
device,
(e.stderr or e.stdout or "").strip(),
)

if not self.cap or not self.cap.isOpened():
raise RuntimeError(f"Failed to open camera device {device}")

Expand Down
Loading