Skip to content

Commit

Permalink
added very basic reconstruction test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMariday committed Mar 11, 2024
1 parent 0b14d8f commit 64b8306
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/sfm/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def pair_id_to_image_ids(pair_id):

def array_to_blob(array):
if IS_PYTHON3:
return array.tostring()
return array.tobytes()
else:
return np.getbuffer(array)

Expand Down
13 changes: 1 addition & 12 deletions lib/sfm/sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,4 @@ def save_points(self, filename):
)

with open(filename, "w") as f:
f.write("\n".join(lines))


if __name__ == "__main__":

sfm = SFM("D:\\Users\\Sam\\GIT\\L3D\\my_scans\\test\\")

sfm.process()

sfm.print_points()
sfm.save_points("points3d.csv")
sfm.display()
f.write("\n".join(lines))
4 changes: 1 addition & 3 deletions scripts/capture_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@

# The filename is made out of the date, then the resolution of the camera
string_time = time.strftime("%Y%m%d-%H%M%S")
filename = (
f"capture_{string_time}.csv"
)
filename = f"capture_{string_time}.csv"

filepath = os.path.join(output_dir_full, filename)
cprint(f"Opening scan file {filepath}\n")
Expand Down
2 changes: 1 addition & 1 deletion scripts/visualise.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if len(file_points[0]) == 3:

for point_id, point_u, point_v in file_points:
image_point = (int(point_u*640), int(point_v*640))
image_point = (int(point_u * 640), int(point_v * 640))
cv2.drawMarker(display, image_point, color=(0, 255, 0))
cv2.putText(
display,
Expand Down
8 changes: 3 additions & 5 deletions test/test_capture_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def test_capture_sequence():

output_dir_full = os.path.join(os.getcwd(), "my_scans", "test")
output_dir_full = os.path.join(os.getcwd(), "test", "scan")

os.makedirs(output_dir_full, exist_ok=True)

Expand All @@ -26,9 +26,7 @@ def test_capture_sequence():
)

# The filename is made out of the date, then the resolution of the camera
filename = (
f"capture_cam_{device_id}.csv"
)
filename = f"capture_cam_{device_id}.csv"

filepath = os.path.join(output_dir_full, filename)

Expand All @@ -50,7 +48,7 @@ def test_capture_sequence_correctness():
mock_camera = MockCamera()

for device_id in range(9):
output_dir_full = os.path.join(os.getcwd(), "my_scans", "test")
output_dir_full = os.path.join(os.getcwd(), "test", "scan")
filename = f"capture_cam_{device_id}.csv"
filepath = os.path.join(output_dir_full, filename)

Expand Down
4 changes: 2 additions & 2 deletions test/test_led_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_basic_image_loading():

led_results = led_finder.find_led(mock_camera.read())

assert close(led_results.u(), 257/640.0)
assert close(led_results.v(), 177/480.0)
assert close(led_results.u(), 257 / 640.0)
assert close(led_results.v(), 177 / 480.0)


def test_none_found():
Expand Down
14 changes: 14 additions & 0 deletions test/test_reconstruction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys

sys.path.append("./")

from lib.sfm.sfm import SFM


def test_reconstruction():

sfm = SFM("test/scan")

sfm.process()

sfm.print_points()

0 comments on commit 64b8306

Please sign in to comment.