Skip to content

Commit

Permalink
Adjusted log levels
Browse files Browse the repository at this point in the history
Added iterator to find largest map
  • Loading branch information
TheMariday committed Dec 27, 2024
1 parent 1771e74 commit 525229c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions marimapper/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,31 @@ def set_autofocus(self, mode, focus=0):
logger.debug(f"Setting autofocus to mode {mode} with focus {focus}")

if not self.device.set(cv2.CAP_PROP_AUTOFOCUS, mode):
logger.error(f"Failed to set autofocus to {mode}")
logger.info(f"Failed to set autofocus to {mode}")

if not self.device.set(cv2.CAP_PROP_FOCUS, focus):
logger.error(f"Failed to set focus to {focus}")
logger.info(f"Failed to set focus to {focus}")

def set_exposure_mode(self, mode):

logger.debug(f"Setting exposure to mode {mode}")

if not self.device.set(cv2.CAP_PROP_AUTO_EXPOSURE, mode):
logger.error(f"Failed to put camera into manual exposure mode {mode}")
logger.info(f"Failed to put camera into manual exposure mode {mode}")

def set_gain(self, gain):

logger.debug(f"Setting gain to {gain}")

if not self.device.set(cv2.CAP_PROP_GAIN, gain):
logger.error(f"failed to set camera gain to {gain}")
logger.info(f"failed to set camera gain to {gain}")

def set_exposure(self, exposure):

logger.debug(f"Setting exposure to {exposure}")

if not self.device.set(cv2.CAP_PROP_EXPOSURE, exposure):
logger.error(f"Failed to set exposure to {exposure}")
logger.warning(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_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,18 @@ def run(self):
if led_current is not None:
distance = get_distance(led_current, led_previous)
if distance > 0.01: # 1% movement
logger.error(
f"Camera movement of {int(distance*100)}% has been detected"
)
movement = True
else:
logger.error(
f"went back to check led {led_previous.led_id} for movement, and led could no longer be found"
f"Went back to check led {led_previous.led_id} for movement, and led could no longer be found"
)
movement = True

if movement:
logger.error("Deleting scan due to camera movement")
self.put_in_all_output_queues(
DetectionControlEnum.DELETE, view_id
)
Expand Down
13 changes: 9 additions & 4 deletions marimapper/sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ def sfm(leds_2d: list[LED2D]) -> list[LED3D]:
# Because of this, lots of existing functionality like inter-led distance might break
# Leaving it out for now but perhaps something to come back to.

if not Path(temp_dir, "0", "points3D.bin").exists():
return []
leds_3d = []
for map_id in range(0, 10):
if not Path(temp_dir, f"{map_id}", "points3D.bin").exists():
break

leds_3d = binary_to_led_map_3d(Path(temp_dir))
logger.debug(f"sfm managed to reconstruct {len(leds_3d)} leds")
new_map = binary_to_led_map_3d(Path(temp_dir))

print(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

return leds_3d

0 comments on commit 525229c

Please sign in to comment.