|
|
import open3d as o3d |
|
|
import numpy as np |
|
|
import json |
|
|
import os |
|
|
import subprocess |
|
|
import shutil |
|
|
|
|
|
|
|
|
folder = "./dataset" |
|
|
json_path = "ply_files.json" |
|
|
categories= ['100', '75', '50', '25', '0'] |
|
|
|
|
|
try: |
|
|
with open(json_path, "r", encoding="utf-8") as f: |
|
|
categorized_files = json.load(f) |
|
|
except FileNotFoundError: |
|
|
print(f"오류: '{json_path}' 파일을 찾을 수 없습니다. 먼저 파일 분류 코드를 실행해 주세요.") |
|
|
exit() |
|
|
|
|
|
print("=== 데이터 처리 시작 ===") |
|
|
|
|
|
for category in categories: |
|
|
print(f"\n--- [카테고리: {category} 처리 시작 ---") |
|
|
|
|
|
filenames_in_category = categorized_files.get(category, []) |
|
|
|
|
|
if not filenames_in_category: |
|
|
print("처리할 파일이 없습니다.") |
|
|
continue |
|
|
|
|
|
for filename in filenames_in_category: |
|
|
print(f"\n>>> 파일 처리 중: {filename}.ply") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists('./res'): |
|
|
shutil.rmtree('./res') |
|
|
print("이전 'res' 폴더를 삭제했습니다.") |
|
|
source_path = f'./initialized_result/initial_{filename}.ply' |
|
|
print(f"--- 로딩 시도 중인 파일: {source_path}") |
|
|
if not os.path.exists(source_path): |
|
|
print("!!!!!! 에러: 해당 경로에 파일이 존재하지 않습니다!") |
|
|
continue |
|
|
cmd = [ |
|
|
'../../FRICP', |
|
|
'./gt_filtered.ply', |
|
|
f'./noisy_result/noisy_filtered_{filename}.ply', |
|
|
'./res', |
|
|
'3' |
|
|
] |
|
|
print(cmd) |
|
|
|
|
|
try: |
|
|
result = subprocess.run(cmd, capture_output=True, text=True, check=True) |
|
|
print("--- STDOUT (표준 출력) ---") |
|
|
print("명령어가 성공적으로 실행되었습니다.") |
|
|
print(result.stdout) |
|
|
|
|
|
except FileNotFoundError: |
|
|
print("--- 에러 발생! ---") |
|
|
print(f"'{cmd[0]}' 파일을 찾을 수 없습니다.") |
|
|
print("경로가 올바른지, 파일이 그 위치에 존재하는지 확인해 주세요.") |
|
|
|
|
|
except subprocess.CalledProcessError as e: |
|
|
print("--- 에러 발생! ---") |
|
|
print(f"명령어 실행 중 오류가 발생했습니다. (종료 코드: {e.returncode})") |
|
|
|
|
|
|
|
|
print("\n--- STDOUT (오류 발생 전 표준 출력) ---") |
|
|
print(e.stdout) |
|
|
|
|
|
print("\n--- STDERR (에러 원인) ---") |
|
|
print(e.stderr) |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transformed_path = "./resm3reg_pc.ply" |
|
|
destination_path = f"./result/final_result_{filename}.ply" |
|
|
transformed_path2 = "./resm3trans.txt" |
|
|
destination_path2 = f"./result/final_result_{filename}.txt" |
|
|
|
|
|
|
|
|
if os.path.exists(transformed_path): |
|
|
shutil.move(transformed_path, destination_path) |
|
|
print(f"Successfully moved '{transformed_path}' to '{destination_path}'") |
|
|
else: |
|
|
print(f"오류: '{transformed_path}' 파일을 찾을 수 없어 이동하지 못했습니다.") |
|
|
|
|
|
if os.path.exists(transformed_path2): |
|
|
shutil.move(transformed_path2, destination_path2) |
|
|
print(f"Successfully moved '{transformed_path2}' to '{destination_path2}'") |
|
|
else: |
|
|
print(f"오류: '{transformed_path2}' 파일을 찾을 수 없어 이동하지 못했습니다.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("\n\n=== 모든 데이터 처리 완료! ===") |