{ "cells": [ { "cell_type": "markdown", "id": "c4b47595-ee12-4217-b52f-0ec867f74d95", "metadata": {}, "source": [ "# Visualizing 3D Data" ] }, { "cell_type": "code", "execution_count": 7, "id": "19814cbe-7df1-4129-b77b-16dbd6426122", "metadata": {}, "outputs": [], "source": [ "import os\n", "os.environ[\"WEBRTC_PORT\"] = \"8889\"\n", "os.environ[\"WEBRTC_IP\"] = \"127.0.0.1\"\n", "\n", "import pickle\n", "from vis4d.vis.functional import show_points\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "fac0fb90-4121-4a7a-8a53-9af164ce1500", "metadata": {}, "source": [ "First, lets load the pointcloud data so we can visualize it." ] }, { "cell_type": "code", "execution_count": 13, "id": "05d6da4e-ae42-465d-b781-76c82617cb47", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loaded pointcloud with 535899 points\n" ] } ], "source": [ "pc_data = pickle.load(open(\"data/pc_data.pkl\", \"rb\"))\n", "\n", "xyz = pc_data[\"points3d\"] - np.mean(pc_data[\"points3d\"], 0)\n", "colors = pc_data[\"colors3d\"]\n", "classes = pc_data[\"semantics3d\"]\n", "instances = pc_data[\"instances3d\"]\n", "\n", "# Lets remove the top part of the pointcloud to see it better\n", "lower_mask = xyz[:, -1] < 1.4\n", "xyz = xyz[lower_mask, :]\n", "colors = colors[lower_mask, :]\n", "classes = classes[lower_mask]\n", "instances = instances[lower_mask]\n", "\n", "print(f\"Loaded pointcloud with {colors.shape[0]} points\")" ] }, { "cell_type": "markdown", "id": "f6513b7c-ef2b-4b9d-8bb0-1f211f7b6956", "metadata": {}, "source": [ "Now, lets visualize the pointcloud with color!" ] }, { "cell_type": "code", "execution_count": 14, "id": "df27a38a-0a36-465a-b144-17b317bb373d", "metadata": {}, "outputs": [], "source": [ "show_points(xyz, colors)" ] }, { "cell_type": "markdown", "id": "7b9c6830-8a8d-4ccb-b015-37b6e874c053", "metadata": {}, "source": [ "Lets look at some other predictions. Class and Instances" ] }, { "cell_type": "markdown", "id": "3f6fcca9-27ac-403a-8a7e-637ccdc1c6ea", "metadata": {}, "source": [ "#### Classes" ] }, { "cell_type": "code", "execution_count": 15, "id": "da9e8553-3c9e-45a5-809e-9146b7151755", "metadata": {}, "outputs": [], "source": [ "show_points(xyz, classes = classes)" ] }, { "cell_type": "markdown", "id": "1c880f26-895f-46df-a55e-b6d71e35b15f", "metadata": {}, "source": [ "#### Instances" ] }, { "cell_type": "code", "execution_count": 16, "id": "6dd29007-c296-4e39-8cf7-2c787e9b2e82", "metadata": {}, "outputs": [], "source": [ "show_points(xyz, instances = instances)" ] }, { "cell_type": "markdown", "id": "69fda6f2-50af-4e08-a185-c29cbcd2643e", "metadata": {}, "source": [ "Finally, lets show all predictions in one window. \n", "This will copy the room three times and color it differently each time, based on 'color', 'classes' and 'instances'" ] }, { "cell_type": "code", "execution_count": 17, "id": "b2b2a96e-ddda-42ae-bcd3-71f187ea9378", "metadata": {}, "outputs": [], "source": [ "show_points(xyz, colors =colors, classes=classes, instances = instances)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8" } }, "nbformat": 4, "nbformat_minor": 5 }