From c6b778f8315d62bb9292b1eda5c954cc96e1b235 Mon Sep 17 00:00:00 2001 From: SVivdich02 Date: Sun, 23 Jun 2024 12:29:54 +0300 Subject: [PATCH] refactoring --- geo_seg_success_sam_without_pca.ipynb | 127 +++++++++++++------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/geo_seg_success_sam_without_pca.ipynb b/geo_seg_success_sam_without_pca.ipynb index 4b4a76a..5a4195f 100644 --- a/geo_seg_success_sam_without_pca.ipynb +++ b/geo_seg_success_sam_without_pca.ipynb @@ -27,7 +27,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-06-23 11:07:16.330 Python[772:9766839] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.\n" + "2024-06-23 12:19:02.844 Python[1858:9800516] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.\n" ] } ], @@ -39,39 +39,7 @@ "cell_type": "code", "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish: 0/4 x and 0/4 y\n", - "Finish: 0/4 x and 1/4 y\n", - "Finish: 0/4 x and 2/4 y\n", - "Finish: 0/4 x and 3/4 y\n", - "Finish: 0/4 x and 4/4 y\n", - "Finish: 1/4 x and 0/4 y\n", - "Finish: 1/4 x and 1/4 y\n", - "Finish: 1/4 x and 2/4 y\n", - "Finish: 1/4 x and 3/4 y\n", - "Finish: 1/4 x and 4/4 y\n", - "Finish: 2/4 x and 0/4 y\n", - "Finish: 2/4 x and 1/4 y\n", - "Finish: 2/4 x and 2/4 y\n", - "Finish: 2/4 x and 3/4 y\n", - "Finish: 2/4 x and 4/4 y\n", - "Finish: 3/4 x and 0/4 y\n", - "Finish: 3/4 x and 1/4 y\n", - "Finish: 3/4 x and 2/4 y\n", - "Finish: 3/4 x and 3/4 y\n", - "Finish: 3/4 x and 4/4 y\n", - "Finish: 4/4 x and 0/4 y\n", - "Finish: 4/4 x and 1/4 y\n", - "Finish: 4/4 x and 2/4 y\n", - "Finish: 4/4 x and 3/4 y\n", - "Finish: 4/4 x and 4/4 y\n" - ] - } - ], + "outputs": [], "source": [ "import numpy as np\n", "\n", @@ -113,15 +81,54 @@ " segments.append(dict)\n", " print(\"Finish: {}/{} x and {}/{} y\".format(i, len(x_grid) - 1 - 1, j, len(y_grid) - 1 - 1))\n", "\n", - " return segments\n", - "\n", - "segment_dicts = divide_pcd_into_square_segments(np.asarray(full_pcd.points), np.asarray(full_pcd.colors), num_segments=6)" + " return segments" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Finish: 0/4 x and 0/4 y\n", + "Finish: 0/4 x and 1/4 y\n", + "Finish: 0/4 x and 2/4 y\n", + "Finish: 0/4 x and 3/4 y\n", + "Finish: 0/4 x and 4/4 y\n", + "Finish: 1/4 x and 0/4 y\n", + "Finish: 1/4 x and 1/4 y\n", + "Finish: 1/4 x and 2/4 y\n", + "Finish: 1/4 x and 3/4 y\n", + "Finish: 1/4 x and 4/4 y\n", + "Finish: 2/4 x and 0/4 y\n", + "Finish: 2/4 x and 1/4 y\n", + "Finish: 2/4 x and 2/4 y\n", + "Finish: 2/4 x and 3/4 y\n", + "Finish: 2/4 x and 4/4 y\n", + "Finish: 3/4 x and 0/4 y\n", + "Finish: 3/4 x and 1/4 y\n", + "Finish: 3/4 x and 2/4 y\n", + "Finish: 3/4 x and 3/4 y\n", + "Finish: 3/4 x and 4/4 y\n", + "Finish: 4/4 x and 0/4 y\n", + "Finish: 4/4 x and 1/4 y\n", + "Finish: 4/4 x and 2/4 y\n", + "Finish: 4/4 x and 3/4 y\n", + "Finish: 4/4 x and 4/4 y\n" + ] + } + ], + "source": [ + "segment_dicts = divide_pcd_into_square_segments(np.asarray(full_pcd.points), np.asarray(full_pcd.colors), num_segments=6)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, "outputs": [ { "data": { @@ -129,7 +136,7 @@ "4679809" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -140,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -149,13 +156,6 @@ "text": [ "\u001b[1;33m[Open3D WARNING] GLFW Error: Cocoa: Failed to find service port for display\u001b[0;m\n" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2024-06-23 11:29:43.752 Python[929:9775455] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.\n" - ] } ], "source": [ @@ -167,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -193,7 +193,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -228,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -237,7 +237,7 @@ "PointCloud with 4679809 points." ] }, - "execution_count": 8, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -263,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -290,7 +290,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -314,7 +314,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -331,7 +331,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -344,7 +344,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -353,11 +353,11 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "def get_points_to_pixels(points, img_shape):\n", + "def get_points_to_pixels(points, img_shape, camera):\n", " img_width, img_height = img_shape\n", "\n", " intrinsic = np.asarray(\n", @@ -390,7 +390,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -407,6 +407,7 @@ "points_to_pixels = get_points_to_pixels(\n", " np.asarray(pcd_hidden_removal.points),\n", " ((image_labels.shape[1], image_labels.shape[0])),\n", + " camera,\n", ")\n", "\n", "for point_id, pixel_id in points_to_pixels.items():\n", @@ -417,7 +418,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -436,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -455,7 +456,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -464,7 +465,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 23, "metadata": {}, "outputs": [ {