{ "cells": [ { "cell_type": "code", "execution_count": 202, "metadata": {}, "outputs": [], "source": [ "# conda activate vision\n", "# cd build\n", "# cmake -DCMAKE_BUILD_TYPE=Release ..\n", "# make\n", "# ./FRICP ./data/bottle/tea_gt_filtered.ply ./data/bottle/tea_noisy_filtered.ply ./data/bottle/res/ 3\n", "\n", "\n", "# 100_16 is the best thing. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Source PCD" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "RPly: Unexpected end of file\n", "RPly: Error reading 'view_px' of 'camera' number 0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;33m[Open3D WARNING] Read PLY failed: unable to read file: ./result/noisy_filtered_100_20.ply\u001b[0;m\n", "Source shape: (48393, 3)\n" ] } ], "source": [ "import open3d as o3d\n", "import numpy as np\n", "\n", "filename = '100_21'\n", "\n", "\n", "source_path = f\"./result/noisy_filtered_{filename}.ply\"\n", "source_pcd = o3d.io.read_point_cloud(source_path)\n", "\n", "source_pcd_array = np.asarray(source_pcd.points)\n", "print(\"Source shape:\", source_pcd_array.shape)\n", "\n", "coord_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=50.0, origin=[0, 0, 0])\n", "o3d.visualization.draw_geometries([source_pcd,coord_frame])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Target PCD" ] }, { "cell_type": "code", "execution_count": 204, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "RPly: Unexpected end of file\n", "RPly: Error reading 'view_px' of 'camera' number 0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;33m[Open3D WARNING] Read PLY failed: unable to read file: gt_filtered.ply\u001b[0;m\n", "Target shape: (50000, 3)\n" ] } ], "source": [ "target_path = f\"gt_filtered.ply\"\n", "target_pcd = o3d.io.read_point_cloud(target_path)\n", "\n", "target_pcd_array = np.asarray(target_pcd.points)\n", "print(\"Target shape:\", target_pcd_array.shape)\n", "\n", "o3d.visualization.draw_geometries([target_pcd, coord_frame])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute termianl" ] }, { "cell_type": "code", "execution_count": 205, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/cam/Fast-Robust-ICP/data/spray\n", "--- STDOUT (표준 출력) ---\n", "명령어가 성공적으로 실행되었습니다.\n", "source: 3x48393\n", "target: 3x50000\n", "scale = 589.925\n", "begin registration...\n", "Registration done!\n", "\n" ] } ], "source": [ "# ./FRICP ./data/bottle_2/gt_filtered.ply ./data/bottle_2/result/noisy_filtered_100_1.ply ./data/bottle_2/res 3 execute\n", "import os\n", "print(os.getcwd())\n", "\n", "import subprocess\n", "\n", "cmd = [\n", " '../../FRICP',\n", " './gt_filtered.ply',\n", " f'./result/noisy_filtered_{filename}.ply',\n", " './res',\n", " '3'\n", "]\n", "try:\n", " result = subprocess.run(cmd, capture_output=True, text=True, check=True)\n", "\n", " print(\"--- STDOUT (표준 출력) ---\")\n", " print(\"명령어가 성공적으로 실행되었습니다.\")\n", " print(result.stdout)\n", "\n", "except FileNotFoundError:\n", " print(\"--- 에러 발생! ---\")\n", " print(f\"'{cmd[0]}' 파일을 찾을 수 없습니다.\")\n", " print(\"경로가 올바른지, 파일이 그 위치에 존재하는지 확인해 주세요.\")\n", "\n", "except subprocess.CalledProcessError as e:\n", " print(\"--- 에러 발생! ---\")\n", " print(f\"명령어 실행 중 오류가 발생했습니다. (종료 코드: {e.returncode})\")\n", " print(\"\\n--- STDERR (에러 원인) ---\")\n", " print(e.stderr)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Change the path for result\n" ] }, { "cell_type": "code", "execution_count": 206, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Successfully moved and renamed 'resm3reg_pc.ply' to './result/resm3reg_pc_100_20.ply'\n", "Successfully moved and renamed 'resm3trans.txt' to './result/resm3trans_100_20.txt'\n" ] } ], "source": [ "import shutil\n", "import os\n", "\n", "transformed_path = \"resm3reg_pc.ply\"\n", "destination_path = f\"./result/resm3reg_pc_{filename}.ply\"\n", "transformed_path2 = \"resm3trans.txt\"\n", "destination_path2 = f\"./result/resm3trans_{filename}.txt\"\n", "\n", "shutil.move(transformed_path, destination_path)\n", "print(f\"Successfully moved and renamed '{transformed_path}' to '{destination_path}'\")\n", "\n", "\n", "\n", "shutil.move(transformed_path2, destination_path2)\n", "print(f\"Successfully moved and renamed '{transformed_path2}' to '{destination_path2}'\")\n", "\n", "\n", "\n", "# # for ply file\n", "# try:\n", "# if not os.path.exists(destination_path):\n", "# shutil.move(transformed_path, destination_path)\n", "# print(f\"Successfully moved and renamed '{transformed_path}' to '{destination_path}'\")\n", "# else:\n", "# print(f\"⚠️ Operation skipped: '{destination_path}' already exists.\")\n", "# raise(ValueError)\n", " \n", "# except FileNotFoundError:\n", "# print(f\"Error: The file '{transformed_path}' was not found.\")\n", "\n", "# # for trans txt file\n", "# try:\n", "# if not os.path.exists(destination_path2):\n", "# shutil.move(transformed_path2, destination_path2)\n", "# print(f\"Successfully moved and renamed '{transformed_path2}' to '{destination_path2}'\")\n", "# else:\n", "# print(f\"⚠️ Operation skipped: '{destination_path2}' already exists.\")\n", "# raise(ValueError)\n", " \n", "# except FileNotFoundError:\n", "# print(f\"Error: The file '{transformed_path2}' was not found.\")\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Transformed Source PCD" ] }, { "cell_type": "code", "execution_count": 207, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Transformed shape: (48393, 3)\n" ] } ], "source": [ "\n", "transformed_pcd = o3d.io.read_point_cloud(destination_path)\n", "\n", "transformed_pcd_array = np.asarray(transformed_pcd.points)\n", "print(\"Transformed shape:\", transformed_pcd_array.shape)\n", "\n", "o3d.visualization.draw_geometries([transformed_pcd, coord_frame])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Source (Original) + Target" ] }, { "cell_type": "code", "execution_count": 208, "metadata": {}, "outputs": [], "source": [ "source_pcd.paint_uniform_color([1, 0, 0])\n", "target_pcd.paint_uniform_color([0, 1, 0])\n", "\n", "vis = o3d.visualization.Visualizer()\n", "vis.create_window(window_name=\"Point Cloud Viewer\", width=1200, height=800, visible=True)\n", "vis.add_geometry(source_pcd)\n", "vis.add_geometry(target_pcd)\n", "vis.add_geometry(coord_frame)\n", "vis.run()\n", "\n", "\n", "vis.destroy_window()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Transformed + Target" ] }, { "cell_type": "code", "execution_count": 209, "metadata": {}, "outputs": [], "source": [ "transformed_pcd.paint_uniform_color([1, 0, 0])\n", "target_pcd.paint_uniform_color([0, 1, 0])\n", "\n", "vis = o3d.visualization.Visualizer()\n", "vis.create_window(window_name=\"Point Cloud Viewer\", width=1200, height=800, visible=True)\n", "vis.add_geometry(transformed_pcd)\n", "vis.add_geometry(target_pcd)\n", "vis.add_geometry(coord_frame)\n", "vis.run()\n", "vis.destroy_window()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }