Skip to content
Draft
Show file tree
Hide file tree
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
40 changes: 0 additions & 40 deletions .github/workflows/lint.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9","3.10"]

steps:
- uses: actions/checkout@v4
Expand All @@ -37,4 +37,4 @@ jobs:

- name: Pytest
run: |
pytest .
pytest -s -v test/test_sfm_process.py
40 changes: 0 additions & 40 deletions .github/workflows/test_ubuntu.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/test_windows.yml

This file was deleted.

12 changes: 10 additions & 2 deletions marimapper/sfm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# it's something in heeeere
from pathlib import Path
from tempfile import TemporaryDirectory
print("importing pycolmap")
import pycolmap

print("pycolmap imported!")
from marimapper.database_populator import (
populate_database,
camera_model_radial,
Expand Down Expand Up @@ -37,19 +39,25 @@ def sfm(

populate_database(database_path, leds_2d, camera_model, camera_fov)

logger.error(f"database_path: {database_path}")
logger.error(f"temp_dir: {temp_dir}")

options = pycolmap.IncrementalPipelineOptions()
options.triangulation.ignore_two_view_tracks = False # used to be true
options.min_num_matches = 9 # default 15
options.mapper.abs_pose_min_num_inliers = 9 # default 30
options.mapper.init_min_num_inliers = 50 # used to be 100

with SupressLogging():
# I think what's happening here is that this is spinning up a thread which is crashing the forked process https://github.com/python/cpython/issues/77906
# Aaaah if this sig sevs then it got caught by the handler
if True:
pycolmap.incremental_mapping(
database_path=database_path,
image_path=temp_dir,
output_path=temp_dir,
options=options,
)
logger.error("sfm done!!!!")

# NOTE!
# There might be more map folders than just "0", however this is the base section and only the one we're
Expand Down
14 changes: 10 additions & 4 deletions marimapper/sfm_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(
camera_model_name: str = camera_model_radial.__name__,
camera_fov: int = 60,
):
print("initing sfm")
super().__init__()
self._input_queue: Queue2D = Queue2D()
self._output_queues: list[Queue3D] = []
Expand All @@ -83,6 +84,7 @@ def __init__(
self.leds_2d = existing_leds if existing_leds is not None else []
self.leds_3d: list[LED3D] = []
self.daemon = True
print("finished init sfm")

def get_input_queue(self) -> Queue2D:
return self._input_queue
Expand All @@ -97,16 +99,18 @@ def stop(self):
self._exit_event.set()

def run(self):

print("sfm running")
needs_initial_reconstruction = len(self.leds_2d) > 0
update_info = True
while not self._exit_event.is_set():
print("looping")

update_sfm = False
print_overlap = False
print_reconstructed = False

while not self._input_queue.empty():
print("items in input queue!")

control, data = self._input_queue.get()
if control == DetectionControlEnum.DETECT:
Expand All @@ -129,17 +133,18 @@ def run(self):
start_time = 0
end_sfm_time = 0
end_post_process_time = 0

print(f"len of leds {len(self.leds_2d)}")
if (update_sfm or needs_initial_reconstruction) and len(self.leds_2d) > 0:

print("update time baby!")
start_time = time.time()
self.leds_3d = sfm(
self.leds_2d,
camera_model=self._camera_model,
camera_fov=self._camera_fov,
)
end_sfm_time = time.time()

print(f"sfm complete with time of {end_sfm_time - start_time}")
print(f"len of leds {len(self.leds_3d)}")
if len(self.leds_3d) > 0:
rescale(self.leds_3d)

Expand All @@ -150,6 +155,7 @@ def run(self):
add_normals(self.leds_3d)

for queue in self._output_queues:
print(f"sending to output queue: {queue}")
queue.put(self.leds_3d)

if update_info:
Expand Down
33 changes: 21 additions & 12 deletions test/test_sfm_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,45 @@
from marimapper.queues import Queue3D
from utils import get_test_dir
import time
import pytest


@pytest.mark.skip("This test is flakey, needs a re-write")
# @pytest.mark.skip("This test is flakey, needs a re-write")
def test_sfm_process_basic():

print("starting test sfm process basic")
print("\n")
leds = get_all_2d_led_maps(get_test_dir("MariMapper-Test-Data/9_point_box"))
print("maps got")
assert len(leds) == 117, "failed to load all leds"

sfm = SFM(existing_leds=leds, max_fill=0)

output_queue = Queue3D()

sfm.add_output_queue(output_queue)
print("here we go!")
sfm.start()

map_3d = output_queue.get(timeout=5)

assert len(map_3d) == 21

print("done!")
time.sleep(2)
print("stopping")
sfm.stop()
timeout = time.time() + 5

while sfm.is_alive():
assert time.time() < timeout, "sfm has failed to stop"
#
# map_3d = output_queue.get(timeout=5)
#
# assert len(map_3d) == 21
#
# sfm.stop()
# timeout = time.time() + 5
#
# while sfm.is_alive():
# assert time.time() < timeout, "sfm has failed to stop"


def test_sfm_process_exit():

leds = get_all_2d_led_maps(get_test_dir("MariMapper-Test-Data/9_point_box"))

assert len(leds) == 117, "failed to load all leds"

sfm = SFM(existing_leds=leds)

output_queue = Queue3D()
Expand Down