{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Points cloud" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5f5b06f9ff234a1bb22020d7b8456c5a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np \n", "import k3d\n", "\n", "plot = k3d.plot(camera_auto_fit=False)\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from k3d.helpers import download\n", "from pyunpack import Archive\n", "\n", "filename = download('http://www.semantic3d.net/data/point-clouds/testing1/' +\n", " 'stgallencathedral_station1_intensity_rgb.7z')\n", "Archive(filename).extractall('./')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import csv\n", "\n", "data = None\n", "\n", "with open(filename.replace('.7z', '.txt'), mode='r') as csv_file:\n", " csv_reader = csv.reader(csv_file, delimiter=' ') \n", " data = np.array(list(csv_reader), dtype=np.float32)\n", "\n", "# compute color in hex format\n", "data[:, 4] = np.sum(data[:, 4:7].astype(np.uint32) * np.array([1, 256, 256 ** 2]), axis=1) \n", "data = data[:, 0:5]\n", "data = data[::10] # every 10th points" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((3117977, 5), 3.117977)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.shape, data.shape[0] / 1e6" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "plot += k3d.points(data[:, 0:3], \n", " data[:, 4].astype(np.uint32), point_size=0.15, shader=\"flat\", \n", " compression_level=9)" ] }, { "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.7.8" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": { "451b5689949841bbb8944d1c52a1c3c3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "5f5b06f9ff234a1bb22020d7b8456c5a": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "layout": "IPY_MODEL_451b5689949841bbb8944d1c52a1c3c3", "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "853f81d55ea64dc792335c15983b91ba", "version_major": 2, "version_minor": 0 }, "text/plain": "Plot(antialias=3, axes=['x', 'y', 'z'], axes_helper=1.0, background_color=16777215, camera=[2, -3, 0.2, 0.0, 0…" }, "metadata": {}, "output_type": "display_data" } ] } }, "853f81d55ea64dc792335c15983b91ba": { "model_module": "k3d", "model_module_version": "2.9.0", "model_name": "PlotModel", "state": { "_backend_version": "2.9.0", "_dom_classes": [], "_view_count": null, "antialias": 3, "auto_rendering": true, "axes": [ "x", "y", "z" ], "axes_helper": 1, "background_color": 16777215, "camera": [ 5.471405376561164, -9.066631877032508, 1.1489672217360902, 0, 0, 0, -0.04206774864800836, 0.03607567065582528, 0.998463244446394 ], "camera_animation": [], "camera_auto_fit": false, "camera_fov": 60, "camera_mode": "trackball", "camera_no_pan": false, "camera_no_rotate": false, "camera_no_zoom": false, "clipping_planes": [], "colorbar_object_id": -1, "colorbar_scientific": false, "fps": 25, "fps_meter": false, "grid": [ -1, -1, -1, 1, 1, 1 ], "grid_auto_fit": true, "grid_visible": true, "height": 512, "layout": "IPY_MODEL_9b943e42dd0440a2ba9db1675f53ff7d", "lighting": 1.5, "manipulate_mode": "translate", "menu_visibility": true, "mode": "view", "name": null, "object_ids": [], "rendering_steps": 1, "screenshot": "", "screenshot_scale": 2, "snapshot": "", "snapshot_include_js": true, "time": 0, "voxel_paint_color": 0 } }, "9b943e42dd0440a2ba9db1675f53ff7d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }