Skip to content

Commit

Permalink
Removed the mock camera entirely as the image path can be passed dire…
Browse files Browse the repository at this point in the history
…ctly in via the device id

Added capture_0024.png to all captures as the capture device always reads one image ahead
Added mailmap for old email addresses
  • Loading branch information
TheMariday committed Jun 20, 2024
1 parent 14e1187 commit d80de4e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The Mariday <martinsa0182@gmail.com> Samuel <martinsa0182@gmail.com>
The Mariday <martinsa0182@gmail.com> sam <martinsa0182@gmail.com>
3 changes: 0 additions & 3 deletions lib/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self, device_id):

if not self.device.isOpened():
logging.error(f"Failed to connect to camera {device_id}")
quit()

self.set_resolution(self.get_width(), self.get_height()) # Don't ask

Expand Down Expand Up @@ -77,8 +76,6 @@ def set_resolution(self, width, height):
f"Failed to set camera {self.device_id} resolution to {width} x {height}",
)

self.device.read() # do not remove! do not ask why, just accept it

logging.debug(f"Camera resolution set to {new_width} x {new_height}")

def set_autofocus(self, mode, focus=0):
Expand Down
2 changes: 1 addition & 1 deletion test/MariMapper-Test-Data
58 changes: 0 additions & 58 deletions test/mock_camera.py

This file was deleted.

8 changes: 1 addition & 7 deletions test/test_capture_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from lib.reconstructor import Reconstructor
from lib.led_map_2d import LEDMap2D
from mock_camera import MockCamera


def test_capture_sequence():
Expand All @@ -12,16 +11,11 @@ def test_capture_sequence():

for view_index in range(9):

mock_camera = MockCamera(device_id=view_index)

reconstructor = Reconstructor(
device=view_index,
device=f"test/MariMapper-Test-Data/9_point_box/cam_{view_index}/capture_%04d.png",
dark_exposure=-10,
threshold=128,
led_backend=None,
width=mock_camera.get_width(),
height=mock_camera.get_height(),
camera=mock_camera,
)

led_map_2d = LEDMap2D()
Expand Down
15 changes: 8 additions & 7 deletions test/test_led_identifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lib.led_identifier import LedFinder
from mock_camera import MockCamera
from lib.camera import Camera


def close(x, y):
Expand All @@ -13,7 +13,7 @@ def test_init():
def test_basic_image_loading():
led_finder = LedFinder()

mock_camera = MockCamera()
mock_camera = Camera("test/MariMapper-Test-Data/9_point_box/cam_0/capture_0000.png")

detection = led_finder.find_led(mock_camera.read())
assert close(detection.u, 0.4029418361244019)
Expand All @@ -23,9 +23,10 @@ def test_basic_image_loading():
def test_none_found():
led_finder = LedFinder()

mock_camera = MockCamera()
mock_camera = Camera("test/MariMapper-Test-Data/9_point_box/cam_0/capture_%04d.png")

for frame_id in [7, 15, 23]: # None of these should be visible from any views
frame = mock_camera.read_frame(frame_id)
led_results = led_finder.find_led(frame)
assert led_results is None
for frame_id in range(24):
frame = mock_camera.read()
if frame_id in [7, 15, 23]:
led_results = led_finder.find_led(frame)
assert led_results is None

0 comments on commit d80de4e

Please sign in to comment.