Skip to content

Commit

Permalink
Revert changes and move to GlobalAlignment as datastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
vjlux committed May 31, 2024
1 parent ec3f7ba commit 1199b52
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 44 deletions.
1 change: 0 additions & 1 deletion scantools/capture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
from .pose import Pose
from .proc import Proc
from .misc import KeyType
from .namedposes import NamedPoses
24 changes: 0 additions & 24 deletions scantools/capture/namedposes.py

This file was deleted.

3 changes: 1 addition & 2 deletions scantools/capture/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .sensors import Sensors, Camera
from .rigs import Rigs
from .trajectories import Trajectories
from .records import RecordsBluetooth, RecordsCamera, RecordsDepth, RecordsLidar, RecordsWifi, NamedPoses
from .records import RecordsBluetooth, RecordsCamera, RecordsDepth, RecordsLidar, RecordsWifi
from .proc import Proc
from .pose import Pose

Expand Down Expand Up @@ -42,7 +42,6 @@ class Session:
bt: Optional[RecordsBluetooth] = None
proc: Optional[Proc] = None
id: Optional[str] = None
namedposes: Optional[NamedPoses] = None

data_dirname = 'raw_data'
proc_dirname = 'proc'
Expand Down
12 changes: 6 additions & 6 deletions scantools/run_navvis_to_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from .capture import (
Capture, Session, Sensors, create_sensor, Trajectories, Rigs, Pose,
RecordsCamera, RecordsLidar, RecordBluetooth, RecordBluetoothSignal,
RecordsBluetooth, RecordWifi, RecordWifiSignal, RecordsWifi, NamedPoses)
RecordsBluetooth, RecordWifi, RecordWifiSignal, RecordsWifi)
from .proc import ( GlobalAlignment )
from .utils.misc import add_bool_arg
from .utils.io import read_image, write_image

Expand Down Expand Up @@ -102,10 +103,9 @@ def run(input_path: Path, capture: Capture, tiles_format: str, session_id: Optio
if nv.load_origin():
origin_qvec, origin_tvec, origin_crs = nv.get_origin()
origin_pose = Pose(r=origin_qvec, t=origin_tvec)
origin_poses = NamedPoses()
origin_poses['origin'] = origin_pose


global_alignment = GlobalAlignment()
global_alignment.origin = origin_pose


if export_as_rig:
# This code assumes NavVis produces consistent rigs across all frames,
Expand Down Expand Up @@ -242,7 +242,7 @@ def run(input_path: Path, capture: Capture, tiles_format: str, session_id: Optio

session = Session(
sensors=sensors, rigs=rigs, trajectories=trajectory,
images=images, pointclouds=pointclouds, wifi=wifi_signals, bt=bluetooth_signals, namedposes=origin_poses)
images=images, pointclouds=pointclouds, wifi=wifi_signals, bt=bluetooth_signals)
capture.sessions[session_id] = session
capture.save(capture.path, session_ids=[session_id])

Expand Down
27 changes: 27 additions & 0 deletions scantools/tests/test_navvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,30 @@ def test_get_image_filename(m6_object, m6_testdata):

res_image_filename = m6_object.get_image_filename(test_frame.id, test_frame.pose.camera_id)
assert res_image_filename == exp_image_filename


## CLEANUP

import pytest
import os
from scipy.spatial.transform import Rotation

from ..capture import Pose
from ..proc import GlobalAlignment

def Rz(theta):
return Rotation.from_euler('z', theta, degrees=True)

@pytest.mark.parametrize(
"rot,tvec",
[
(['1', '0', '0', '0'], ['0', '1', '1']),
(Rz(30), ['1', '1', '0'])
])
def test_pose_valid(rot, tvec, tmp_path):
temp_file_path = tmp_path / 'named_poses.csv'
pose = Pose(rot, tvec)
global_alignment = GlobalAlignment()
#global_alignment.save(temp_file_path, [pose])
#os.remove(temp_file_path)

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scipy.spatial.transform import Rotation

from ..capture import Pose
from ..capture import NamedPoses
from ..proc import GlobalAlignment

def Rz(theta):
return Rotation.from_euler('z', theta, degrees=True)
Expand All @@ -19,16 +19,9 @@ def Rz(theta):
def test_pose_valid(rot, tvec, tmp_path):
temp_file_path = tmp_path / 'named_poses.csv'
pose = Pose(rot, tvec)
poses = NamedPoses()
poses['pose1'] = pose
poses['pose2'] = pose
poses.save(temp_file_path)
loaded_poses = NamedPoses()
loaded_poses.load(temp_file_path)
assert len(poses) == len(loaded_poses)
assert poses.keys() == loaded_poses.keys()
for k in poses.keys():
assert poses[k].to_list() == loaded_poses[k].to_list()
global_alignment = GlobalAlignment()


os.remove(temp_file_path)


Expand Down

0 comments on commit 1199b52

Please sign in to comment.