diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index d5aa534..58faa2d 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -5,6 +5,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 + - uses: astral-sh/ruff-action@v3 with: - version: 0.8.1 \ No newline at end of file + version: "0.11.4" + args: "--version" + - run: ruff check --config pyproject.toml + - run: ruff format --check --config pyproject.toml \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7554053..7dd75a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,16 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.8.1 + rev: v0.11.4 hooks: # Run the linter. - id: ruff types_or: [python, pyi, jupyter] - args: [ --fix ] + args: [--fix, --config, pyproject.toml] # Run the formatter. - id: ruff-format types_or: [python, pyi, jupyter] + args: [--config, pyproject.toml] - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.8 # Replace with the latest version diff --git a/oxford_spires_utils/sensor.py b/oxford_spires_utils/sensor.py index 44b8863..d0cb569 100644 --- a/oxford_spires_utils/sensor.py +++ b/oxford_spires_utils/sensor.py @@ -40,9 +40,9 @@ class Camera: def __post_init__(self): assert self.camera_model in supported_camera_models, f"Camera model {self.camera_model} not supported" assert len(self.intrinsics) == 4, f"Expected 4 intrinsics, got {len(self.intrinsics)}" - assert ( - len(self.extra_params) == expected_num_extra_param[self.camera_model] - ), f"Expected {expected_num_extra_param[self.camera_model]} extra params, got {len(self.extra_params)}" + assert len(self.extra_params) == expected_num_extra_param[self.camera_model], ( + f"Expected {expected_num_extra_param[self.camera_model]} extra params, got {len(self.extra_params)}" + ) self.T_cam_lidar_overwrite = ( get_transformation_matrix(self.T_cam_lidar_t_xyz_q_xyzw_overwrite) if len(self.T_cam_lidar_t_xyz_q_xyzw_overwrite) > 0 diff --git a/oxford_spires_utils/trajectory/file_interfaces/nerf.py b/oxford_spires_utils/trajectory/file_interfaces/nerf.py index dd0f360..fb4dd7c 100644 --- a/oxford_spires_utils/trajectory/file_interfaces/nerf.py +++ b/oxford_spires_utils/trajectory/file_interfaces/nerf.py @@ -163,14 +163,14 @@ def replace_transform_matrix(self, pose: PosePath3D, template_meta: dict): @params template_meta: template json file """ meta = deepcopy(template_meta) - assert ( - len(meta["frames"]) == pose.num_poses - ), "Number of frames in template file does not match the number of poses" + assert len(meta["frames"]) == pose.num_poses, ( + "Number of frames in template file does not match the number of poses" + ) for i in range(pose.num_poses): # assume order of frames in template file is the same as the order of poses - assert pose.timestamps[i] == NeRFTrajUtils.get_t_float128_from_fname( - meta["frames"][i]["file_path"] - ), "Timestamps of frames in template file does not match the timestamps of poses" + assert pose.timestamps[i] == NeRFTrajUtils.get_t_float128_from_fname(meta["frames"][i]["file_path"]), ( + "Timestamps of frames in template file does not match the timestamps of poses" + ) meta["frames"][i]["transform_matrix"] = pose.poses_se3[i].tolist() return meta diff --git a/oxford_spires_utils/trajectory/file_interfaces/timestamp.py b/oxford_spires_utils/trajectory/file_interfaces/timestamp.py index 8b14331..8988ee5 100644 --- a/oxford_spires_utils/trajectory/file_interfaces/timestamp.py +++ b/oxford_spires_utils/trajectory/file_interfaces/timestamp.py @@ -74,9 +74,9 @@ def t_float128(self): t_float128 = np.float128(self.t_string) # check - assert ( - TimeStamp.get_string_from_t_float128(t_float128) == self.t_string - ), f"Precision Lost: t_float128 {t_float128} should be {self.t_string}" + assert TimeStamp.get_string_from_t_float128(t_float128) == self.t_string, ( + f"Precision Lost: t_float128 {t_float128} should be {self.t_string}" + ) return t_float128 @@ -109,9 +109,9 @@ def get_sec_nsec_from_float128(t_float128): @param f: np.float128 @return: (sec, nsec), both str, nsec is 9 digits """ - assert isinstance( - t_float128, np.float128 - ), f"t_float128 should be of type np.float128, but is {type(t_float128)}" + assert isinstance(t_float128, np.float128), ( + f"t_float128 should be of type np.float128, but is {type(t_float128)}" + ) sec, nsec = str(t_float128).split(".") nsec = nsec.ljust(NSECONDS_DIGITS, "0") assert len(nsec) == NSECONDS_DIGITS, f"nsec {nsec} should be {NSECONDS_DIGITS} digits" diff --git a/oxford_spires_utils/trajectory/file_interfaces/tum.py b/oxford_spires_utils/trajectory/file_interfaces/tum.py index 157c71d..bb365fa 100644 --- a/oxford_spires_utils/trajectory/file_interfaces/tum.py +++ b/oxford_spires_utils/trajectory/file_interfaces/tum.py @@ -74,9 +74,9 @@ def read_tum_pose_custom(self, file_path, prefix="", suffix=""): print("skipping lines with wrong prefix or suffix") continue t_float128 = TimeStamp(t_string=fname[len(prefix) : len(fname) - len(suffix)]).t_float128 - assert ( - TimeStamp.get_string_from_t_float128(t_float128) == fname[len(prefix) : len(fname) - len(suffix)] - ), f"loss of precision in timestamp: before {fname[len(prefix) : len(fname)-len(suffix)]}; after {t_float}" + assert TimeStamp.get_string_from_t_float128(t_float128) == fname[len(prefix) : len(fname) - len(suffix)], ( + f"loss of precision in timestamp: before {fname[len(prefix) : len(fname) - len(suffix)]}; after {t_float}" + ) time_stamp.append(t_float128) translation = splited[1:4] quaternion_xyzw = splited[4:8] diff --git a/oxford_spires_utils/trajectory/file_interfaces/vilens_slam.py b/oxford_spires_utils/trajectory/file_interfaces/vilens_slam.py index ead789c..96cce68 100644 --- a/oxford_spires_utils/trajectory/file_interfaces/vilens_slam.py +++ b/oxford_spires_utils/trajectory/file_interfaces/vilens_slam.py @@ -31,6 +31,7 @@ def read_file(self): quat_wxyz = np.roll(quat_xyzw, 1, axis=1) # xyzw -> wxyz return evo.core.trajectory.PoseTrajectory3D(xyz, quat_wxyz, timestamps=timestamps) + class VilensSlamTrajWriter(BasicTrajWriter): """ write VILENS SLAM trajectory format file (poses.csv) @@ -41,7 +42,7 @@ def __init__(self, file_path, **kwargs): def write_file(self, pose): """ - this is used for CSV style trajectory file + this is used for CSV style trajectory file @param self.file_path: path to save the file @param pose: PoseTrajectory3D from evo """ @@ -69,4 +70,4 @@ def write_file(self, pose): f.write(str(pose.orientations_quat_wxyz[i][2]) + ", ") f.write(str(pose.orientations_quat_wxyz[i][3]) + ", ") f.write(str(pose.orientations_quat_wxyz[i][0])) - f.writelines("\n") \ No newline at end of file + f.writelines("\n") diff --git a/requirements.txt b/requirements.txt index 1eb008f..26acaab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,6 @@ pye57>=0.4.13 # nerfstudio==1.1.4 evo>=1.29.0 pytransform3d>=3.5.0 -huggingface_hub>=0.25.1 \ No newline at end of file +huggingface_hub>=0.25.1 +ruff==0.11.4 +pre-commit==3.0.0 \ No newline at end of file diff --git a/scripts/localisation_benchmark/colmap.py b/scripts/localisation_benchmark/colmap.py index 1085b8e..7dd25a2 100644 --- a/scripts/localisation_benchmark/colmap.py +++ b/scripts/localisation_benchmark/colmap.py @@ -10,8 +10,7 @@ from oxford_spires_utils.trajectory.json_handler import JsonHandler -def convert_to_tum (path_to_output, path_to_sec): - +def convert_to_tum(path_to_output, path_to_sec): print("Convert from JSON format to TUM!!") # Remove other cameras @@ -28,44 +27,46 @@ def convert_to_tum (path_to_output, path_to_sec): print("*********************************************************") -def get_sec_list (dataset_dir, flag_is_all=True): +def get_sec_list(dataset_dir, flag_is_all=True): if flag_is_all: list_sec = os.listdir(dataset_dir) else: list_sec = [ - "2024-03-12-keble-college-02", - "2024-03-12-keble-college-03", - "2024-03-12-keble-college-04", - "2024-03-12-keble-college-05", - "2024-03-13-observatory-quarter-01", - "2024-03-13-observatory-quarter-02", - "2024-03-14-blenheim-palace-01", - "2024-03-14-blenheim-palace-02", - "2024-03-14-blenheim-palace-05", - "2024-03-18-christ-church-01", - "2024-03-18-christ-church-02", - "2024-03-18-christ-church-03", - "2024-03-20-christ-church-05", - "2024-05-20-bodleian-library-02", - "2024-05-20-bodleian-library-03", - "2024-05-20-bodleian-library-04", - "2024-05-20-bodleian-library-05" - ] + "2024-03-12-keble-college-02", + "2024-03-12-keble-college-03", + "2024-03-12-keble-college-04", + "2024-03-12-keble-college-05", + "2024-03-13-observatory-quarter-01", + "2024-03-13-observatory-quarter-02", + "2024-03-14-blenheim-palace-01", + "2024-03-14-blenheim-palace-02", + "2024-03-14-blenheim-palace-05", + "2024-03-18-christ-church-01", + "2024-03-18-christ-church-02", + "2024-03-18-christ-church-03", + "2024-03-20-christ-church-05", + "2024-05-20-bodleian-library-02", + "2024-05-20-bodleian-library-03", + "2024-05-20-bodleian-library-04", + "2024-05-20-bodleian-library-05", + ] return list_sec -def evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, method): - + +def evaluation_ape_rmse(path_to_gt, path_traj, dataset_dir, method): print("RUNNING VILENS EVALUATION ...") - output = run_command("evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False) - + output = run_command( + "evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False + ) + rmse = -1 for line in output.stdout: print(line, end="") if "rmse" in line: - numbers = re.findall('\d+\.\d+|\d+', line) + numbers = re.findall("\d+\.\d+|\d+", line) rmse = numbers[0] - + logging.basicConfig(filename=dataset_dir + "results.log", filemode="a", level=logging.INFO) logging.info(path_to_sec) logging.info("APE - RMSE result ({}): {}".format(method, rmse)) @@ -73,35 +74,34 @@ def evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, method): return rmse -def create_output_folder (path_to_sec): + +def create_output_folder(path_to_sec): path_to_output = path_to_sec + "/output" + "/colmap/" # if not os.path.exists(path_to_output): # os.makedirs(path_to_output) return path_to_output -if __name__ == "__main__": +if __name__ == "__main__": # -------------------------------------------------------------------------------- # # TODO: get path from arg an define folders in the future class. package_dir = "/home/mice85/oxford-lab/labrobotica/algorithms/oxford_spires_dataset" - dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" + dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" flag_is_all = False # -------------------------------------------------------------------------------- # - list_sec = get_sec_list (dataset_dir, flag_is_all) - - print('Total sequence folders: ' + str(len(list_sec))) - + list_sec = get_sec_list(dataset_dir, flag_is_all) + + print("Total sequence folders: " + str(len(list_sec))) + # Print list of sequences for sec in list_sec: - path_to_sec = dataset_dir + sec path_to_gt = path_to_sec + "/processed/trajectory/gt-tum.txt" - path_to_output = create_output_folder (path_to_sec) + path_to_output = create_output_folder(path_to_sec) - convert_to_tum (path_to_output, path_to_sec) + convert_to_tum(path_to_output, path_to_sec) path_traj = path_to_sec + "/output" + "/colmap-tum.txt" - rmse = evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, "COLMAP") - \ No newline at end of file + rmse = evaluation_ape_rmse(path_to_gt, path_traj, dataset_dir, "COLMAP") diff --git a/scripts/localisation_benchmark/fast_lio_slam.py b/scripts/localisation_benchmark/fast_lio_slam.py index fb3d2a2..0515bb7 100644 --- a/scripts/localisation_benchmark/fast_lio_slam.py +++ b/scripts/localisation_benchmark/fast_lio_slam.py @@ -14,58 +14,57 @@ from oxford_spires_utils.bash_command import run_command -def run_fast_lio_slam (path_to_rosbag, path_to_output): - +def run_fast_lio_slam(path_to_rosbag, path_to_output): server = libtmux.Server() - server.cmd('new-session', '-d', '-P', '-F#{session_id}') + server.cmd("new-session", "-d", "-P", "-F#{session_id}") session = server.sessions[0] window_1 = session.new_window(attach=False, window_name="launch fast_lio_slam") window_2 = session.new_window(attach=False, window_name="launch aloam_velodyne") - window_3 = session.new_window(attach=False, window_name="rosbag") + window_3 = session.new_window(attach=False, window_name="rosbag") pane_1 = window_1.panes.get() pane_2 = window_2.panes.get() pane_3 = window_3.panes.get() - pane_2.send_keys('cd ~/oxford-lab/lidar_slam_ws/') - pane_2.send_keys('source devel/setup.bash') - pane_2.send_keys('roslaunch aloam_velodyne aloam_hesai.launch arg_save_directory:={}'.format(path_to_output)) + pane_2.send_keys("cd ~/oxford-lab/lidar_slam_ws/") + pane_2.send_keys("source devel/setup.bash") + pane_2.send_keys("roslaunch aloam_velodyne aloam_hesai.launch arg_save_directory:={}".format(path_to_output)) print("SC-PGO launched!! - mapping_hesai.launch") time.sleep(5) - pane_1.send_keys('cd ~/oxford-lab/lidar_slam_ws/') - pane_1.send_keys('source devel/setup.bash') - pane_1.send_keys('roslaunch fast_lio mapping_hesai.launch') + pane_1.send_keys("cd ~/oxford-lab/lidar_slam_ws/") + pane_1.send_keys("source devel/setup.bash") + pane_1.send_keys("roslaunch fast_lio mapping_hesai.launch") print("Fast-LIO-SLAM launched!! - mapping_hesai.launch") time.sleep(5) - - pane_3.send_keys('cd {}'.format(path_to_rosbag)) - pane_3.send_keys('rosbag play *.bag --clock') + + pane_3.send_keys("cd {}".format(path_to_rosbag)) + pane_3.send_keys("rosbag play *.bag --clock") print("Starting rosbag files in {}".format(path_to_rosbag)) # Check if the rosbag is "Done." - t = time.time() + t = time.time() flag_end = False - while (1): + while 1: pane_3.clear() time.sleep(1) cap_curr = pane_3.capture_pane() for line in cap_curr: if "[RUNNING]" in line: - t = time.time() + t = time.time() print(line) sys.stdout.write("\033[F") - if 'Done.' in line: - t = time.time() + if "Done." in line: + t = time.time() flag_end = True sys.stdout.write("\033[K") - print('Done.') + print("Done.") break if flag_end: break - if (time.time() - t) > 60.0: # To avoid infinite - print('Timeout!!') + if (time.time() - t) > 60.0: # To avoid infinite + print("Timeout!!") break print("PROCESS FINISHED!!") @@ -75,14 +74,17 @@ def run_fast_lio_slam (path_to_rosbag, path_to_output): server.kill() -def convert_to_tum (path_to_output, path_to_sec): - +def convert_to_tum(path_to_output, path_to_sec): print("Convert from KITTI format to TUM!!") pose_path = file_interface.read_kitti_poses_file(path_to_output + "optimized_poses.txt") raw_timestamps_mat = file_interface.csv_read_matrix(path_to_output + "times.txt") - error_msg = ("timestamp file must have one column of timestamps and same number of rows as the KITTI poses file") - if len(raw_timestamps_mat) > 0 and len(raw_timestamps_mat[0]) != 1 or len(raw_timestamps_mat) != pose_path.num_poses: + error_msg = "timestamp file must have one column of timestamps and same number of rows as the KITTI poses file" + if ( + len(raw_timestamps_mat) > 0 + and len(raw_timestamps_mat[0]) != 1 + or len(raw_timestamps_mat) != pose_path.num_poses + ): raise file_interface.FileInterfaceException(error_msg) try: timestamps_mat = np.array(raw_timestamps_mat).astype(float) @@ -97,81 +99,83 @@ def convert_to_tum (path_to_output, path_to_sec): print("*********************************************************") -def eval_fast_lio_slam (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): - +def eval_fast_lio_slam(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): path_traj = path_to_sec + "/output_slam" + "/fast_lio_tum.txt" - output = run_command("evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False) - + output = run_command( + "evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False + ) + rmse = -1 for line in output.stdout: print(line, end="") if "rmse" in line: - numbers = re.findall('\d+\.\d+|\d+', line) + numbers = re.findall("\d+\.\d+|\d+", line) rmse = numbers[0] - + logging.basicConfig(filename=dataset_dir + "results.log", filemode="a", level=logging.INFO) logging.info(path_to_sec) logging.info("APE - RMSE result (Fast_LIO-SLAM): {}".format(rmse)) print("RMSE added to log: {}".format(rmse)) -def create_output_folder (path_to_sec): + +def create_output_folder(path_to_sec): path_to_output = path_to_sec + "/output_slam" + "/fastlio_raw_output/" if not os.path.exists(path_to_output): - os.makedirs(path_to_output) + os.makedirs(path_to_output) return path_to_output -def get_sec_list (dataset_dir, flag_is_all=True): + +def get_sec_list(dataset_dir, flag_is_all=True): if flag_is_all: list_sec = os.listdir(dataset_dir) else: list_sec = [ - "2024-03-12-keble-college-02", - "2024-03-12-keble-college-03", - "2024-03-12-keble-college-04", - "2024-03-12-keble-college-05", - "2024-03-13-observatory-quarter-01", - "2024-03-13-observatory-quarter-02", - "2024-03-14-blenheim-palace-01", - "2024-03-14-blenheim-palace-02", - "2024-03-14-blenheim-palace-05", - "2024-03-18-christ-church-01", - "2024-03-18-christ-church-02", - "2024-03-18-christ-church-03", - "2024-03-20-christ-church-05", - "2024-05-20-bodleian-library-02", - "2024-05-20-bodleian-library-03", - "2024-05-20-bodleian-library-04", - "2024-05-20-bodleian-library-05" - ] + "2024-03-12-keble-college-02", + "2024-03-12-keble-college-03", + "2024-03-12-keble-college-04", + "2024-03-12-keble-college-05", + "2024-03-13-observatory-quarter-01", + "2024-03-13-observatory-quarter-02", + "2024-03-14-blenheim-palace-01", + "2024-03-14-blenheim-palace-02", + "2024-03-14-blenheim-palace-05", + "2024-03-18-christ-church-01", + "2024-03-18-christ-church-02", + "2024-03-18-christ-church-03", + "2024-03-20-christ-church-05", + "2024-05-20-bodleian-library-02", + "2024-05-20-bodleian-library-03", + "2024-05-20-bodleian-library-04", + "2024-05-20-bodleian-library-05", + ] return list_sec -if __name__ == "__main__": +if __name__ == "__main__": # -------------------------------------------------------------------------------- # # TODO: get path from arg an define folders in the future class. package_dir = "/home/mice85/oxford-lab/labrobotica/algorithms/oxford_spires_dataset" - dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" + dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" flag_is_all = False # -------------------------------------------------------------------------------- # - list_sec = get_sec_list (dataset_dir, flag_is_all) - - print('Total sequence folders: ' + str(len(list_sec))) - + list_sec = get_sec_list(dataset_dir, flag_is_all) + + print("Total sequence folders: " + str(len(list_sec))) + # Print list of sequences for sec in list_sec: - path_to_sec = dataset_dir + sec - path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" #path_to_sec + "/rosbag/" + path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" # path_to_sec + "/rosbag/" path_to_gt = path_to_sec + "/ground_truth_traj/gt_lidar.txt" - path_to_output = create_output_folder (path_to_sec) + path_to_output = create_output_folder(path_to_sec) - run_fast_lio_slam (path_to_rosbag, path_to_output) + run_fast_lio_slam(path_to_rosbag, path_to_output) time.sleep(5) - convert_to_tum (path_to_output, path_to_sec) + convert_to_tum(path_to_output, path_to_sec) - eval_fast_lio_slam (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) + eval_fast_lio_slam(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) - # break \ No newline at end of file + # break diff --git a/scripts/localisation_benchmark/immesh.py b/scripts/localisation_benchmark/immesh.py index 00c824a..f6c6228 100644 --- a/scripts/localisation_benchmark/immesh.py +++ b/scripts/localisation_benchmark/immesh.py @@ -11,62 +11,59 @@ from oxford_spires_utils.bash_command import run_command -def run_immesh (path_to_rosbag, path_to_output): - +def run_immesh(path_to_rosbag, path_to_output): server = libtmux.Server() - server.cmd('new-session', '-d', '-P', '-F#{session_id}') + server.cmd("new-session", "-d", "-P", "-F#{session_id}") session = server.sessions[0] window_1 = session.new_window(attach=False, window_name="launch immesh") - window_2 = session.new_window(attach=False, window_name="rosbag play") + window_2 = session.new_window(attach=False, window_name="rosbag play") window_3 = session.new_window(attach=False, window_name="rosbag record") pane_1 = window_1.panes.get() pane_2 = window_2.panes.get() pane_3 = window_3.panes.get() - - pane_1.send_keys('cd ~/oxford-lab/lidar_slam_ws/') - pane_1.send_keys('source devel/setup.bash') - pane_1.send_keys('roslaunch ImMesh mapping_spire.launch') + + pane_1.send_keys("cd ~/oxford-lab/lidar_slam_ws/") + pane_1.send_keys("source devel/setup.bash") + pane_1.send_keys("roslaunch ImMesh mapping_spire.launch") print("ImMesh launched!! - roslaunch ImMesh mapping_spire.launch") - - pane_2.send_keys('cd {}'.format(path_to_rosbag)) - pane_2.send_keys('rosbag play *.bag --clock') + + pane_2.send_keys("cd {}".format(path_to_rosbag)) + pane_2.send_keys("rosbag play *.bag --clock") print("Starting rosbag files in {}".format(path_to_rosbag)) - pane_3.send_keys('cd {}'.format(path_to_output)) - pane_3.send_keys('rosbag record -O immesh_path.bag /path __name:=immesh_path') + pane_3.send_keys("cd {}".format(path_to_output)) + pane_3.send_keys("rosbag record -O immesh_path.bag /path __name:=immesh_path") print("Rosbag record in {}".format(path_to_output)) - # Check if the rosbag is "Done." - t = time.time() + t = time.time() flag_end = False - while (1): + while 1: pane_2.clear() time.sleep(1) cap_curr = pane_2.capture_pane() for line in cap_curr: if "[RUNNING]" in line: - t = time.time() + t = time.time() print(line) sys.stdout.write("\033[F") - if 'Done.' in line: - t = time.time() + if "Done." in line: + t = time.time() flag_end = True sys.stdout.write("\033[K") - print('Done.') + print("Done.") break if flag_end: break - if (time.time() - t) > 60.0: # To avoid infinite - print('Timeout!!') + if (time.time() - t) > 60.0: # To avoid infinite + print("Timeout!!") break - + run_command("rosnode kill /immesh_path", print_output=True) time.sleep(3) - - if os.path.exists("{}/immesh_path.bag.active".format(path_to_output)): + if os.path.exists("{}/immesh_path.bag.active".format(path_to_output)): run_command("rosbag reindex {}/immesh_path.bag.active".format(path_to_output), print_output=True) old_file = os.path.join(path_to_output, "immesh_path.bag.active") @@ -80,49 +77,51 @@ def run_immesh (path_to_rosbag, path_to_output): server.kill() -def convert_to_tum (path_to_output): +def convert_to_tum(path_to_output): print("Convert from ROS /path format to TUM!!") - + server = libtmux.Server() - server.cmd('new-session', '-d', '-P', '-F#{session_id}') + server.cmd("new-session", "-d", "-P", "-F#{session_id}") session = server.sessions[0] window_1 = session.new_window(attach=False, window_name="launch bag_to_traj") - window_2 = session.new_window(attach=False, window_name="rosbag play") + window_2 = session.new_window(attach=False, window_name="rosbag play") pane_1 = window_1.panes.get() pane_2 = window_2.panes.get() - - pane_1.send_keys('cd ~/oxford-lab/oxford_ws/') - pane_1.send_keys('source devel/setup.bash') - pane_1.send_keys('roslaunch bag_to_traj bag_to_traj.launch arg_outfile_path:={}/immesh_tum.txt'.format(path_to_output)) + + pane_1.send_keys("cd ~/oxford-lab/oxford_ws/") + pane_1.send_keys("source devel/setup.bash") + pane_1.send_keys( + "roslaunch bag_to_traj bag_to_traj.launch arg_outfile_path:={}/immesh_tum.txt".format(path_to_output) + ) print("bag_to_traj launched!! - roslaunch bag_to_traj bag_to_traj.launch") - - pane_2.send_keys('cd {}'.format(path_to_output)) - pane_2.send_keys('rosbag play *.bag --clock') + + pane_2.send_keys("cd {}".format(path_to_output)) + pane_2.send_keys("rosbag play *.bag --clock") print("Starting rosbag files in {}".format(path_to_output)) # Check if the rosbag is "Done." - t = time.time() + t = time.time() flag_end = False - while (1): + while 1: pane_2.clear() time.sleep(1) cap_curr = pane_2.capture_pane() for line in cap_curr: if "[RUNNING]" in line: - t = time.time() + t = time.time() print(line) sys.stdout.write("\033[F") - if 'Done.' in line: - t = time.time() + if "Done." in line: + t = time.time() flag_end = True sys.stdout.write("\033[K") - print('Done.') + print("Done.") break if flag_end: break - if (time.time() - t) > 60.0: # To avoid infinite - print('Timeout!!') + if (time.time() - t) > 60.0: # To avoid infinite + print("Timeout!!") break old_file = os.path.join(path_to_output, "immesh_tum.txt") @@ -135,84 +134,86 @@ def convert_to_tum (path_to_output): server.kill() -def create_output_folder (path_to_sec): + +def create_output_folder(path_to_sec): path_to_output = path_to_sec + "/output_slam" + "/ImMesh_raw_output" if not os.path.exists(path_to_output): - os.makedirs(path_to_output) + os.makedirs(path_to_output) return path_to_output -def eval_immesh (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): +def eval_immesh(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): path_traj = os.path.join(path_to_sec + "/output_slam", "immesh_tum.txt") - output = run_command("evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False) - + output = run_command( + "evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False + ) + rmse = -1 for line in output.stdout: print(line, end="") if "rmse" in line: - numbers = re.findall('\d+\.\d+|\d+', line) + numbers = re.findall("\d+\.\d+|\d+", line) rmse = numbers[0] - + logging.basicConfig(filename=dataset_dir + "results.log", filemode="a", level=logging.INFO) logging.info(path_to_sec) logging.info("APE - RMSE result (ImMesh): {}".format(rmse)) print("RMSE added to log: {}".format(rmse)) -def get_sec_list (dataset_dir, flag_is_all=True): +def get_sec_list(dataset_dir, flag_is_all=True): if flag_is_all: list_sec = os.listdir(dataset_dir) else: list_sec = [ - "2024-03-12-keble-college-02", - "2024-03-12-keble-college-03", - "2024-03-12-keble-college-04", - "2024-03-12-keble-college-05", - "2024-03-13-observatory-quarter-01", - "2024-03-13-observatory-quarter-02", - "2024-03-14-blenheim-palace-01", - "2024-03-14-blenheim-palace-02", - "2024-03-14-blenheim-palace-05", - "2024-03-18-christ-church-01", - "2024-03-18-christ-church-02", - "2024-03-18-christ-church-03", - "2024-03-20-christ-church-05", - "2024-05-20-bodleian-library-02", - "2024-05-20-bodleian-library-03", - "2024-05-20-bodleian-library-04", - "2024-05-20-bodleian-library-05" - ] + "2024-03-12-keble-college-02", + "2024-03-12-keble-college-03", + "2024-03-12-keble-college-04", + "2024-03-12-keble-college-05", + "2024-03-13-observatory-quarter-01", + "2024-03-13-observatory-quarter-02", + "2024-03-14-blenheim-palace-01", + "2024-03-14-blenheim-palace-02", + "2024-03-14-blenheim-palace-05", + "2024-03-18-christ-church-01", + "2024-03-18-christ-church-02", + "2024-03-18-christ-church-03", + "2024-03-20-christ-church-05", + "2024-05-20-bodleian-library-02", + "2024-05-20-bodleian-library-03", + "2024-05-20-bodleian-library-04", + "2024-05-20-bodleian-library-05", + ] return list_sec -if __name__ == "__main__": +if __name__ == "__main__": # -------------------------------------------------------------------------------- # # TODO: get path from arg an define folders in the future class. package_dir = "/home/mice85/oxford-lab/labrobotica/algorithms/oxford_spires_dataset" - dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" + dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" flag_is_all = False # -------------------------------------------------------------------------------- # - list_sec = get_sec_list (dataset_dir, flag_is_all) - - print('Total sequence folders: ' + str(len(list_sec))) - + list_sec = get_sec_list(dataset_dir, flag_is_all) + + print("Total sequence folders: " + str(len(list_sec))) + # Print list of sequences for sec in list_sec: - path_to_sec = dataset_dir + sec - path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" #path_to_sec + "/rosbag/" + path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" # path_to_sec + "/rosbag/" path_to_gt = path_to_sec + "/ground_truth_traj/gt_lidar.txt" - path_to_output = create_output_folder (path_to_sec) + path_to_output = create_output_folder(path_to_sec) - run_immesh (path_to_rosbag, path_to_output) + run_immesh(path_to_rosbag, path_to_output) time.sleep(5) - convert_to_tum (path_to_output) + convert_to_tum(path_to_output) time.sleep(5) - eval_immesh (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) + eval_immesh(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) - # break \ No newline at end of file + # break diff --git a/scripts/localisation_benchmark/sc_lio_sam.py b/scripts/localisation_benchmark/sc_lio_sam.py index fba027a..d537e41 100644 --- a/scripts/localisation_benchmark/sc_lio_sam.py +++ b/scripts/localisation_benchmark/sc_lio_sam.py @@ -14,49 +14,48 @@ from oxford_spires_utils.bash_command import run_command -def run_sc_lio_sam (path_to_rosbag, path_to_output): - +def run_sc_lio_sam(path_to_rosbag, path_to_output): server = libtmux.Server() - server.cmd('new-session', '-d', '-P', '-F#{session_id}') + server.cmd("new-session", "-d", "-P", "-F#{session_id}") session = server.sessions[0] window_1 = session.new_window(attach=False, window_name="launch sc_lio_sam") - window_2 = session.new_window(attach=False, window_name="rosbag") + window_2 = session.new_window(attach=False, window_name="rosbag") pane_1 = window_1.panes.get() pane_2 = window_2.panes.get() - pane_1.send_keys('cd ~/oxford-lab/lidar_slam_ws/') - pane_1.send_keys('source devel/setup.bash') - pane_1.send_keys('roslaunch lio_sam run_hesai.launch arg_savePCDDirectory:={}'.format(path_to_output)) + pane_1.send_keys("cd ~/oxford-lab/lidar_slam_ws/") + pane_1.send_keys("source devel/setup.bash") + pane_1.send_keys("roslaunch lio_sam run_hesai.launch arg_savePCDDirectory:={}".format(path_to_output)) print("SC-LIO-SAM launched!! - run_hesai.launch") time.sleep(5) - - pane_2.send_keys('cd {}'.format(path_to_rosbag)) - pane_2.send_keys('rosbag play *.bag --clock') + + pane_2.send_keys("cd {}".format(path_to_rosbag)) + pane_2.send_keys("rosbag play *.bag --clock") print("Starting rosbag files in {}".format(path_to_rosbag)) # Check if the rosbag is "Done." - t = time.time() + t = time.time() flag_end = False - while (1): + while 1: pane_2.clear() time.sleep(1) cap_curr = pane_2.capture_pane() for line in cap_curr: if "[RUNNING]" in line: - t = time.time() + t = time.time() print(line) sys.stdout.write("\033[F") - if 'Done.' in line: - t = time.time() + if "Done." in line: + t = time.time() flag_end = True sys.stdout.write("\033[K") - print('Done.') + print("Done.") break if flag_end: break - if (time.time() - t) > 60.0: # To avoid infinite - print('Timeout!!') + if (time.time() - t) > 60.0: # To avoid infinite + print("Timeout!!") break print("PROCESS FINISHED!!") @@ -66,14 +65,17 @@ def run_sc_lio_sam (path_to_rosbag, path_to_output): server.kill() -def convert_to_tum (path_to_output, path_to_sec): - +def convert_to_tum(path_to_output, path_to_sec): print("Convert from KITTI format to TUM!!") pose_path = file_interface.read_kitti_poses_file(path_to_output + "optimized_poses.txt") raw_timestamps_mat = file_interface.csv_read_matrix(path_to_output + "times.txt") - error_msg = ("timestamp file must have one column of timestamps and same number of rows as the KITTI poses file") - if len(raw_timestamps_mat) > 0 and len(raw_timestamps_mat[0]) != 1 or len(raw_timestamps_mat) != pose_path.num_poses: + error_msg = "timestamp file must have one column of timestamps and same number of rows as the KITTI poses file" + if ( + len(raw_timestamps_mat) > 0 + and len(raw_timestamps_mat[0]) != 1 + or len(raw_timestamps_mat) != pose_path.num_poses + ): raise file_interface.FileInterfaceException(error_msg) try: timestamps_mat = np.array(raw_timestamps_mat).astype(float) @@ -88,81 +90,83 @@ def convert_to_tum (path_to_output, path_to_sec): print("*********************************************************") -def eval_sc_lio_sam (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): - +def eval_sc_lio_sam(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir): path_traj = path_to_sec + "/output_slam" + "/lio_sam_tum.txt" - output = run_command("evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False) - + output = run_command( + "evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False + ) + rmse = -1 for line in output.stdout: print(line, end="") if "rmse" in line: - numbers = re.findall('\d+\.\d+|\d+', line) + numbers = re.findall("\d+\.\d+|\d+", line) rmse = numbers[0] - + logging.basicConfig(filename=dataset_dir + "results.log", filemode="a", level=logging.INFO) logging.info(path_to_sec) logging.info("APE - RMSE result (SC-LIO-SAM): {}".format(rmse)) print("RMSE added to log: {}".format(rmse)) -def create_output_folder (path_to_sec): + +def create_output_folder(path_to_sec): path_to_output = path_to_sec + "/output_slam" + "/liosam_raw_output/" if not os.path.exists(path_to_output): - os.makedirs(path_to_output) + os.makedirs(path_to_output) return path_to_output -def get_sec_list (dataset_dir, flag_is_all=True): + +def get_sec_list(dataset_dir, flag_is_all=True): if flag_is_all: list_sec = os.listdir(dataset_dir) else: list_sec = [ - "2024-03-12-keble-college-02", - "2024-03-12-keble-college-03", - "2024-03-12-keble-college-04", - "2024-03-12-keble-college-05", - "2024-03-13-observatory-quarter-01", - "2024-03-13-observatory-quarter-02", - "2024-03-14-blenheim-palace-01", - "2024-03-14-blenheim-palace-02", - "2024-03-14-blenheim-palace-05", - "2024-03-18-christ-church-01", - "2024-03-18-christ-church-02", - "2024-03-18-christ-church-03", - "2024-03-20-christ-church-05", - "2024-05-20-bodleian-library-02", - "2024-05-20-bodleian-library-03", - "2024-05-20-bodleian-library-04", - "2024-05-20-bodleian-library-05" - ] + "2024-03-12-keble-college-02", + "2024-03-12-keble-college-03", + "2024-03-12-keble-college-04", + "2024-03-12-keble-college-05", + "2024-03-13-observatory-quarter-01", + "2024-03-13-observatory-quarter-02", + "2024-03-14-blenheim-palace-01", + "2024-03-14-blenheim-palace-02", + "2024-03-14-blenheim-palace-05", + "2024-03-18-christ-church-01", + "2024-03-18-christ-church-02", + "2024-03-18-christ-church-03", + "2024-03-20-christ-church-05", + "2024-05-20-bodleian-library-02", + "2024-05-20-bodleian-library-03", + "2024-05-20-bodleian-library-04", + "2024-05-20-bodleian-library-05", + ] return list_sec -if __name__ == "__main__": +if __name__ == "__main__": # -------------------------------------------------------------------------------- # # TODO: get path from arg an define folders in the future class. package_dir = "/home/mice85/oxford-lab/labrobotica/algorithms/oxford_spires_dataset" - dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" + dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" flag_is_all = False # -------------------------------------------------------------------------------- # - list_sec = get_sec_list (dataset_dir, flag_is_all) - - print('Total sequence folders: ' + str(len(list_sec))) - + list_sec = get_sec_list(dataset_dir, flag_is_all) + + print("Total sequence folders: " + str(len(list_sec))) + # Print list of sequences for sec in list_sec: - path_to_sec = dataset_dir + sec - path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" #path_to_sec + "/rosbag/" + path_to_rosbag = "/home/mice85/data/" + sec + "/rosbag/" # path_to_sec + "/rosbag/" path_to_gt = path_to_sec + "/ground_truth_traj/gt_lidar.txt" - path_to_output = create_output_folder (path_to_sec) + path_to_output = create_output_folder(path_to_sec) - run_sc_lio_sam (path_to_rosbag, path_to_output) + run_sc_lio_sam(path_to_rosbag, path_to_output) time.sleep(5) - convert_to_tum (path_to_output, path_to_sec) + convert_to_tum(path_to_output, path_to_sec) - eval_sc_lio_sam (path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) + eval_sc_lio_sam(path_to_gt, path_to_output, package_dir, path_to_sec, dataset_dir) - # break \ No newline at end of file + # break diff --git a/scripts/localisation_benchmark/vilens_hba.py b/scripts/localisation_benchmark/vilens_hba.py index 99e28d7..a3eef77 100644 --- a/scripts/localisation_benchmark/vilens_hba.py +++ b/scripts/localisation_benchmark/vilens_hba.py @@ -7,42 +7,44 @@ from oxford_spires_utils.bash_command import run_command -def get_sec_list (dataset_dir, flag_is_all=True): +def get_sec_list(dataset_dir, flag_is_all=True): if flag_is_all: list_sec = os.listdir(dataset_dir) else: list_sec = [ - "2024-03-12-keble-college-02", - "2024-03-12-keble-college-03", - "2024-03-12-keble-college-04", - "2024-03-12-keble-college-05", - "2024-03-13-observatory-quarter-01", - "2024-03-13-observatory-quarter-02", - "2024-03-14-blenheim-palace-01", - "2024-03-14-blenheim-palace-02", - "2024-03-14-blenheim-palace-05", - "2024-03-18-christ-church-01", - "2024-03-18-christ-church-02", - "2024-03-18-christ-church-03", - "2024-03-20-christ-church-05", - "2024-05-20-bodleian-library-02", - "2024-05-20-bodleian-library-03", - "2024-05-20-bodleian-library-04", - "2024-05-20-bodleian-library-05" - ] + "2024-03-12-keble-college-02", + "2024-03-12-keble-college-03", + "2024-03-12-keble-college-04", + "2024-03-12-keble-college-05", + "2024-03-13-observatory-quarter-01", + "2024-03-13-observatory-quarter-02", + "2024-03-14-blenheim-palace-01", + "2024-03-14-blenheim-palace-02", + "2024-03-14-blenheim-palace-05", + "2024-03-18-christ-church-01", + "2024-03-18-christ-church-02", + "2024-03-18-christ-church-03", + "2024-03-20-christ-church-05", + "2024-05-20-bodleian-library-02", + "2024-05-20-bodleian-library-03", + "2024-05-20-bodleian-library-04", + "2024-05-20-bodleian-library-05", + ] return list_sec -def evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, method): - - output = run_command("evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False) - + +def evaluation_ape_rmse(path_to_gt, path_traj, dataset_dir, method): + output = run_command( + "evo_ape tum {} {} --align --t_max_diff 0.01".format(path_to_gt, path_traj), print_output=False + ) + rmse = -1 for line in output.stdout: print(line, end="") if "rmse" in line: - numbers = re.findall('\d+\.\d+|\d+', line) + numbers = re.findall("\d+\.\d+|\d+", line) rmse = numbers[0] - + logging.basicConfig(filename=dataset_dir + "results.log", filemode="a", level=logging.INFO) logging.info(path_to_sec) logging.info("APE - RMSE result ({}): {}".format(method, rmse)) @@ -50,31 +52,29 @@ def evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, method): return rmse -if __name__ == "__main__": +if __name__ == "__main__": # -------------------------------------------------------------------------------- # # TODO: get path from arg an define folders in the future class. package_dir = "/home/mice85/oxford-lab/labrobotica/algorithms/oxford_spires_dataset" - dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" + dataset_dir = "/media/mice85/blackdrive1/oxford_spires_dataset/data/" flag_is_all = False # -------------------------------------------------------------------------------- # - list_sec = get_sec_list (dataset_dir, flag_is_all) - - print('Total sequence folders: ' + str(len(list_sec))) - + list_sec = get_sec_list(dataset_dir, flag_is_all) + + print("Total sequence folders: " + str(len(list_sec))) + # Print list of sequences for sec in list_sec: - path_to_sec = dataset_dir + sec path_to_gt = path_to_sec + "/ground_truth_traj/gt_lidar.txt" print("RUNNING VILENS EVALUATION ...") path_traj = path_to_sec + "/output_slam" + "/vilens_poses_tum.txt" - rmse = evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, "VILENS") + rmse = evaluation_ape_rmse(path_to_gt, path_traj, dataset_dir, "VILENS") file_name = "hba_poses_tum.txt" path_traj = path_to_sec + "/output_slam" + "/hba_poses_tum.txt" print("RUNNING HBA EVALUATION ...") - rmse = evaluation_ape_rmse (path_to_gt, path_traj, dataset_dir, "HBA") - \ No newline at end of file + rmse = evaluation_ape_rmse(path_to_gt, path_traj, dataset_dir, "HBA") diff --git a/scripts/reconstruction_benchmark/mvs.py b/scripts/reconstruction_benchmark/mvs.py index 9a3aade..1f279ef 100644 --- a/scripts/reconstruction_benchmark/mvs.py +++ b/scripts/reconstruction_benchmark/mvs.py @@ -17,7 +17,7 @@ def run_colmap_mvs(image_path, colmap_output_path, sparse_folder, max_image_size "colmap image_undistorter", f"--image_path {image_path}", f"--input_path {sparse_folder}", - f"--output_path {colmap_output_path/'dense'}", + f"--output_path {colmap_output_path / 'dense'}", "--output_type COLMAP", f"--max_image_size {max_image_size}", ] @@ -26,7 +26,7 @@ def run_colmap_mvs(image_path, colmap_output_path, sparse_folder, max_image_size colmap_patch_match_stereo_cmd = [ "colmap patch_match_stereo", - f"--workspace_path {colmap_output_path/'dense'}", + f"--workspace_path {colmap_output_path / 'dense'}", "--workspace_format COLMAP", "--PatchMatchStereo.geom_consistency true", ] @@ -35,18 +35,18 @@ def run_colmap_mvs(image_path, colmap_output_path, sparse_folder, max_image_size colmap_stereo_fusion_cmd = [ "colmap stereo_fusion", - f"--workspace_path {colmap_output_path/'dense'}", + f"--workspace_path {colmap_output_path / 'dense'}", "--workspace_format COLMAP", "--input_type geometric", - f"--output_path {colmap_output_path /'dense'/'fused.ply'}", + f"--output_path {colmap_output_path / 'dense' / 'fused.ply'}", ] colmap_stereo_fusion_cmd = " ".join(colmap_stereo_fusion_cmd) run_command(colmap_stereo_fusion_cmd, print_command=True) colmap_delauany_mesh_filter_cmd = [ "colmap delaunay_mesher", - f"--input_path {colmap_output_path /'dense'}", - f"--output_path {colmap_output_path /'dense'/'meshed-delaunay.ply'}", + f"--input_path {colmap_output_path / 'dense'}", + f"--output_path {colmap_output_path / 'dense' / 'meshed-delaunay.ply'}", ] colmap_delauany_mesh_filter_cmd = " ".join(colmap_delauany_mesh_filter_cmd) run_command(colmap_delauany_mesh_filter_cmd, print_command=True) diff --git a/scripts/reconstruction_benchmark/nerf.py b/scripts/reconstruction_benchmark/nerf.py index d8a68c2..fa06891 100644 --- a/scripts/reconstruction_benchmark/nerf.py +++ b/scripts/reconstruction_benchmark/nerf.py @@ -98,7 +98,7 @@ def run_nerfstudio(ns_config, ns_data_config, export_cloud=True): cloud = o3d.io.read_point_cloud(str(output_cloud_file)) cloud.transform(scale_matrix) cloud.transform(np.linalg.inv(ns_se3)) - final_metric_cloud_file = output_cloud_file.with_name(f'{ns_config["method"]}_cloud_metric.pcd') + final_metric_cloud_file = output_cloud_file.with_name(f"{ns_config['method']}_cloud_metric.pcd") o3d.io.write_point_cloud(str(final_metric_cloud_file), cloud) return final_metric_cloud_file diff --git a/scripts/reconstruction_benchmark/nerf_json.py b/scripts/reconstruction_benchmark/nerf_json.py index d552f8b..b191520 100644 --- a/scripts/reconstruction_benchmark/nerf_json.py +++ b/scripts/reconstruction_benchmark/nerf_json.py @@ -78,8 +78,8 @@ def merge_json_files(json_train_file, json_eval_file, image_dir, new_image_dir, train_image_folder = dataset_folder / "train_val_image" / "train" eval_image_folder = dataset_folder / "train_val_image" / "eval" -assert (train_image_folder / "images").exists(), f"{train_image_folder/'images'} does not exist" -assert (eval_image_folder / "images").exists(), f"{eval_image_folder/'images'} does not exist" +assert (train_image_folder / "images").exists(), f"{train_image_folder / 'images'} does not exist" +assert (eval_image_folder / "images").exists(), f"{eval_image_folder / 'images'} does not exist" train_save_path = Path(json_file).parent / f"{train_name}.json" eval_save_path = Path(json_file).parent / f"{eval_name}.json" diff --git a/scripts/reconstruction_benchmark/sfm.py b/scripts/reconstruction_benchmark/sfm.py index beb0704..8a67627 100644 --- a/scripts/reconstruction_benchmark/sfm.py +++ b/scripts/reconstruction_benchmark/sfm.py @@ -122,7 +122,7 @@ def run_colmap( "colmap image_undistorter", f"--image_path {image_path}", f"--input_path {sparse_0_path}", - f"--output_path {output_path/'dense'}", + f"--output_path {output_path / 'dense'}", "--output_type COLMAP", f"--max_image_size {max_image_size}", ] diff --git a/spires_cpp/example.py b/spires_cpp/example.py index d59ecc6..bc60655 100644 --- a/spires_cpp/example.py +++ b/spires_cpp/example.py @@ -1,11 +1,6 @@ from __future__ import annotations -from spires_cpp import ( - OcTree, - convertOctreeToPointCloud, - processPCDFolder, - removeUnknownPoints, -) +from spires_cpp import OcTree, convertOctreeToPointCloud, processPCDFolder, removeUnknownPoints pcd_folder = "/home/yifu/data/nerf_data_pipeline/2024-03-13-maths_1/raw/individual_clouds_new" resolution = 0.1 diff --git a/spires_cpp/src/spires_cpp/__init__.py b/spires_cpp/src/spires_cpp/__init__.py index 2f9cfc5..8886609 100644 --- a/spires_cpp/src/spires_cpp/__init__.py +++ b/spires_cpp/src/spires_cpp/__init__.py @@ -1,13 +1,6 @@ from __future__ import annotations -from ._core import ( - OcTree, - __doc__, - __version__, - convertOctreeToPointCloud, - processPCDFolder, - removeUnknownPoints, -) +from ._core import OcTree, __doc__, __version__, convertOctreeToPointCloud, processPCDFolder, removeUnknownPoints __all__ = [ "OcTree",