-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spires_cpp package with octomap utility for reconstruction filter…
…ing (#2)
- Loading branch information
Showing
26 changed files
with
877 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
class TerminalColors: | ||
RED = "\033[91m" | ||
GREEN = "\033[92m" | ||
YELLOW = "\033[93m" | ||
ORANGE = "\033[94m" | ||
PURPLE = "\033[95m" | ||
CYAN = "\033[96m" | ||
ENDC = "\033[0m" | ||
BOLD = "\033[1m" | ||
UNDERLINE = "\033[4m" | ||
|
||
|
||
def print_with_colour(text, colour=TerminalColors.CYAN): | ||
print(f"{colour}{text}{TerminalColors.ENDC}") | ||
|
||
|
||
def run_command(cmd, log_path=None, print_command=True): | ||
if print_command: | ||
print_with_colour(f"Running command: {cmd}") | ||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, universal_newlines=True) | ||
for line in process.stdout: | ||
print(line, end="") | ||
if log_path is not None: | ||
assert isinstance(log_path, (Path, str)) | ||
with open(log_path, "a") as f: | ||
f.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
numpy >= 1.24.4 | ||
open3d >= 0.17.0 | ||
scipy >= 1.10.1 | ||
pytest>=8.0.0 | ||
numpy>=1.24.4 | ||
open3d>=0.17.0 | ||
scipy>=1.10.1 | ||
pytest>=8.0.0 | ||
pypcd4>=1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pathlib import Path | ||
|
||
from oxford_spires_utils.io import convert_e57_to_pcd | ||
|
||
|
||
def convert_e57_folder_to_pcd_folder(e57_folder, pcd_folder): | ||
Path(pcd_folder).mkdir(parents=True, exist_ok=True) | ||
e57_files = list(Path(e57_folder).glob("*.e57")) | ||
for e57_file in e57_files: | ||
pcd_file = Path(pcd_folder) / (e57_file.stem + ".pcd") | ||
print(f"Converting {e57_file} to {pcd_file}") | ||
convert_e57_to_pcd(e57_file, pcd_file, pcd_lib="pypcd4") | ||
|
||
|
||
if __name__ == "__main__": | ||
# e57_file_path = "/media/yifu/Samsung_T71/oxford_spires/2024-03-13-maths/gt/individual/Math Inst- 001.e57" | ||
# output_pcd = "/home/yifu/workspace/oxford_spires_dataset/output.pcd" | ||
# new_pcd = "/home/yifu/workspace/oxford_spires_dataset/output_new.pcd" | ||
# convert_e57_to_pcd(e57_file_path, output_pcd) | ||
e57_folder = "/media/yifu/Samsung_T71/oxford_spires/2024-03-13-maths/gt/individual" | ||
pcd_folder = "/media/yifu/Samsung_T71/oxford_spires/2024-03-13-maths/gt/individual_pcd" | ||
convert_e57_folder_to_pcd_folder(e57_folder, pcd_folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import multiprocessing | ||
from pathlib import Path | ||
|
||
from spires_cpp import convertOctreeToPointCloud, processPCDFolder, removeUnknownPoints | ||
|
||
# input_cloud_folder_path = "/home/yifu/workspace/Spires_2025/2024-03-13-maths_1/input_cloud_test" | ||
# gt_cloud_folder_path = "/home/yifu/workspace/Spires_2025/2024-03-13-maths_1/gt_cloud_test" | ||
input_cloud_folder_path = "/home/yifu/data/nerf_data_pipeline/2024-03-13-maths_1/raw/individual_clouds_new" | ||
gt_cloud_folder_path = "/media/yifu/Samsung_T71/oxford_spires/2024-03-13-maths/gt/individual_pcd" | ||
project_folder = "/home/yifu/workspace/Spires_2025/2024-03-13-maths_1" | ||
Path(project_folder).mkdir(parents=True, exist_ok=True) | ||
|
||
input_cloud_bt_path = Path(project_folder) / "input_cloud.bt" | ||
gt_cloud_bt_path = Path(project_folder) / "gt_cloud.bt" | ||
|
||
|
||
processes = [] | ||
octomap_resolution = 0.1 | ||
for cloud_folder, cloud_bt_path in zip( | ||
[input_cloud_folder_path, gt_cloud_folder_path], [input_cloud_bt_path, gt_cloud_bt_path] | ||
): | ||
process = multiprocessing.Process( | ||
target=processPCDFolder, args=(str(cloud_folder), octomap_resolution, str(cloud_bt_path)) | ||
) | ||
processes.append(process) | ||
|
||
|
||
# for process in processes: | ||
# process.start() | ||
|
||
# for process in processes: | ||
# process.join() | ||
|
||
|
||
gt_cloud_free_path = str(Path(gt_cloud_bt_path).with_name(f"{Path(gt_cloud_bt_path).stem}_free.pcd")) | ||
gt_cloud_occ_path = str(Path(gt_cloud_bt_path).with_name(f"{Path(gt_cloud_bt_path).stem}_occ.pcd")) | ||
input_cloud_free_path = str(Path(input_cloud_bt_path).with_name(f"{Path(input_cloud_bt_path).stem}_free.pcd")) | ||
input_cloud_occ_path = str(Path(input_cloud_bt_path).with_name(f"{Path(input_cloud_bt_path).stem}_occ.pcd")) | ||
convertOctreeToPointCloud(str(gt_cloud_bt_path), str(gt_cloud_free_path), str(gt_cloud_occ_path)) | ||
convertOctreeToPointCloud(str(input_cloud_bt_path), str(input_cloud_free_path), str(input_cloud_occ_path)) | ||
|
||
input_occ_pcd_path = str(Path(input_cloud_bt_path).with_name(f"{Path(input_cloud_bt_path).stem}_occ.pcd")) | ||
input_occ_filtered_path = str(Path(input_cloud_bt_path).with_name(f"{Path(input_cloud_bt_path).stem}_occ_filtered.pcd")) | ||
gt_occ_pcd_path = str(Path(gt_cloud_bt_path).with_name(f"{Path(gt_cloud_bt_path).stem}_occ.pcd")) | ||
gt_occ_filtered_path = str(Path(gt_cloud_bt_path).with_name(f"{Path(gt_cloud_bt_path).stem}_occ_filtered.pcd")) | ||
|
||
|
||
removeUnknownPoints(input_occ_pcd_path, str(gt_cloud_bt_path), input_occ_filtered_path) | ||
removeUnknownPoints(gt_occ_pcd_path, str(input_cloud_bt_path), gt_occ_filtered_path) |
Oops, something went wrong.