Skip to content

Commit

Permalink
Put the camera in dark mode for a moment to catch property setting er…
Browse files Browse the repository at this point in the history
…rors
  • Loading branch information
TheMariday committed Dec 27, 2024
1 parent b70e3ac commit 673fbfc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion marimapper/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def set_exposure(self, exposure):
logger.debug(f"Setting exposure to {exposure}")

if not self.device.set(cv2.CAP_PROP_EXPOSURE, exposure):
logger.warning(f"Failed to set exposure to {exposure}")
logger.info(f"Failed to set exposure to {exposure}")

def eat(self, count=30):
for _ in range(count):
Expand Down
6 changes: 5 additions & 1 deletion marimapper/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def set_cam_dark(cam: Camera, exposure: int) -> None:
cam.set_autofocus(0, 0)
cam.set_exposure_mode(0)
cam.set_gain(0)
cam.set_exposure(exposure)
if not cam.set_exposure(exposure):
logger.warning(
f"failed to set exposure to {exposure}, your camera might not support exposure control, try darkening the scene and adjusting the threshold with --threshold "
)

cam.eat()


Expand Down
4 changes: 4 additions & 0 deletions marimapper/detector_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def run(self):

timeout_controller = TimeoutController()

# we quickly switch to dark mode here to throw any exceptions about the camera early
set_cam_dark(cam, self._dark_exposure)
set_cam_default(cam)

while not self._exit_event.is_set():

if not self._request_detections_queue.empty():
Expand Down
4 changes: 3 additions & 1 deletion marimapper/sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def sfm(leds_2d: list[LED2D]) -> list[LED3D]:

new_map = binary_to_led_map_3d(Path(temp_dir))

logger.debug(f"sfm managed to reconstruct {len(new_map)} leds in map {map_id}")
logger.debug(
f"sfm managed to reconstruct {len(new_map)} leds in map {map_id}"
)

leds_3d = new_map if len(new_map) > len(leds_3d) else leds_3d

Expand Down

0 comments on commit 673fbfc

Please sign in to comment.