| import os |
| import subprocess |
|
|
| def main(): |
| base_dir = r"D:\Users\roy\CV_final_project\champ-master" |
| driving_videos_dir = os.path.join(base_dir, "driving_videos") |
| blender_exe = r"D:\Program Files (x86)\blender-3.6.0-windows-x64\blender.exe" |
| script_path = os.path.join("scripts", "data_processors", "smpl", "smooth_smpls.py") |
| |
| if not os.path.exists(driving_videos_dir): |
| print(f"錯誤:找不到資料夾 {driving_videos_dir}") |
| return |
|
|
| |
| video_names = [d for d in os.listdir(driving_videos_dir) if os.path.isdir(os.path.join(driving_videos_dir, d))] |
| video_names.sort() |
| |
| print(f"總共找到 {len(video_names)} 支影片需要進行 3D 骨架平滑處理...") |
|
|
| for video_name in video_names: |
| |
| smpls_npz_path = os.path.join("driving_videos", video_name, "smpl_results", "smpls_group.npz") |
| |
| |
| full_npz_path = os.path.join(base_dir, smpls_npz_path) |
| if not os.path.exists(full_npz_path): |
| print(f"[{video_name}] 找不到動作捕捉檔案 (跳過): {smpls_npz_path}") |
| continue |
| |
| print(f"\n========================================") |
| print(f"正在平滑化影片骨架: {video_name}") |
| print(f"========================================") |
| |
| |
| cmd = [ |
| blender_exe, |
| "--background", |
| "--python", script_path, |
| "--", |
| "--smpls_group_path", smpls_npz_path, |
| "--smoothed_result_path", smpls_npz_path |
| ] |
| |
| result = subprocess.run(cmd, cwd=base_dir) |
| |
| if result.returncode != 0: |
| print(f"[{video_name}] 執行 Blender 時發生錯誤!") |
| else: |
| print(f"[{video_name}] 平滑化完成!\n") |
|
|
| if __name__ == "__main__": |
| main() |
|
|