Skip to content

Commit 503ad5c

Browse files
Mesh 3D function added
1 parent f798773 commit 503ad5c

7 files changed

+63
-38
lines changed

1_frame_information.ipynb

+23-15
Large diffs are not rendered by default.

2_frame_transformations.ipynb

+12-16
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@
8282
"name": "stderr",
8383
"output_type": "stream",
8484
"text": [
85-
"/opt/anaconda3/envs/mp-iv/lib/python3.7/site-packages/traittypes/traittypes.py:101: UserWarning: Given trait value dtype \"float64\" does not match required type \"float32\". A coerced copy has been created.\n",
85+
"/opt/anaconda3/envs/view-of-delft-env/lib/python3.7/site-packages/traittypes/traittypes.py:101: UserWarning: Given trait value dtype \"float64\" does not match required type \"float32\". A coerced copy has been created.\n",
8686
" np.dtype(self.dtype).name))\n"
8787
]
8888
},
8989
{
9090
"data": {
9191
"application/vnd.jupyter.widget-view+json": {
92-
"model_id": "dccc0e1a192f4b15825e8c5bc8dc20bd",
92+
"model_id": "ed098796e3fb4f01b9cbbba80966be90",
9393
"version_major": 2,
9494
"version_minor": 0
9595
},
@@ -149,13 +149,14 @@
149149
}
150150
},
151151
"source": [
152-
"The class contains the homogenous transform matrices as properties, with the following convention: `t_target_origin`:\n",
153-
"- t_camera_lidar: homogeneous transform matrix from the lidar frame, to the camera frame.\n",
154-
"- t_camera_radar homogeneous transform matrix from the radar frame, to the camera frame.\n",
155-
"- t_lidar_camera: homogeneous transform matrix from the camera frame, to the lidar frame.\n",
156-
"- t_radar_camera: homogeneous transform matrix from the camera frame, to the radar frame.\n",
157-
"- t_lidar_radar: homogeneous transform matrix from the radar frame, to the lidar frame.\n",
158-
"- t_radar_lidar: homogeneous transform matrix from the lidar frame, to the radar frame.\n",
152+
"The class contains the homogenous transform matrices as properties, that takes a point cloud which is in the source frame, and transforms\n",
153+
" it to the target frame: `t_target_source`:\n",
154+
"- t_camera_lidar: from the lidar source frame, to the camera target frame.\n",
155+
"- t_camera_radar: from the lidar source frame, to the camera target frame.\n",
156+
"- t_lidar_camera: from the lidar source frame, to the camera target frame.\n",
157+
"- t_radar_camera: from the lidar source frame, to the camera target frame.\n",
158+
"- t_lidar_radar: from the lidar source frame, to the camera target frame.\n",
159+
"- t_radar_lidar: from the lidar source frame, to the camera target frame.\n",
159160
"\n",
160161
"The camera projection matrix is also available using `camera_projection_matrix`."
161162
]
@@ -191,12 +192,7 @@
191192
"name": "#%% md\n"
192193
}
193194
},
194-
"source": [
195-
"There are also a number of helper functions included, which can help the transformations:\n",
196-
"- `homogeneous_coordinates`: Add description!\n",
197-
"- `homogeneous_transformation`:\n",
198-
"- `project_3d_to_2d`:"
199-
]
195+
"source": []
200196
},
201197
{
202198
"cell_type": "code",
@@ -331,4 +327,4 @@
331327
},
332328
"nbformat": 4,
333329
"nbformat_minor": 1
334-
}
330+
}

3_2d_visualization.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,4 @@
270270
},
271271
"nbformat": 4,
272272
"nbformat_minor": 1
273-
}
273+
}

example_output01201.png

1.52 MB
Loading

vod/configuration/file_locations.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22

3-
43
class KittiLocations:
54
"""
65
This class contains the information regarding the locations of data for the dataset.

vod/visualization/helpers.py

+21
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,27 @@ def k3d_get_axes(hom_transform_matrix=np.eye(4, dtype=float), axis_length=1.0):
192192
return pose_axes
193193

194194

195+
def k3d_plot_mesh(plot, box_corners, color):
196+
box_mesh_index = np.asarray([
197+
[0, 1, 2], # bottom
198+
[0, 2, 3], # bottom
199+
[0, 1, 5], # front
200+
[0, 5, 4], # front
201+
[2, 3, 7], # back
202+
[2, 7, 6], # back
203+
[1, 2, 6], # right
204+
[1, 6, 5], # right
205+
[0, 3, 7], # left
206+
[0, 7, 4], # left
207+
[4, 5, 6], # top
208+
[4, 6, 7], # top
209+
[0, 1, 5], # front twice to be darker when opaque
210+
[0, 5, 4], # front
211+
], dtype=np.uint32)
212+
213+
plot += k3d.mesh(vertices=box_corners[:, 0:3], indices=box_mesh_index, color=color, opacity=0.25)
214+
215+
195216
def k3d_plot_box(plot, box_corners, color, width):
196217
lines = [[0, 1, 2, 3, 0], [4, 5, 6, 7, 4], [0, 4], [1, 5], [3, 7], [2, 6]]
197218

vod/visualization/vis_3d.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import k3d
22
import numpy as np
33
from .helpers import k3d_get_axes, get_transformed_3d_label_corners, k3d_plot_box, \
4-
get_radar_velocity_vectors, get_default_camera
4+
get_radar_velocity_vectors, get_default_camera, k3d_plot_mesh
55
from vod.frame import FrameDataLoader, FrameTransformMatrix, FrameLabels, transform_pcl
66
from .settings import *
77

@@ -180,12 +180,14 @@ def plot_annotations(self, class_colors=label_color_palette_3d, class_width=labe
180180
for box in bboxes:
181181
object_class = box['label_class']
182182

183-
object_class_color = class_colors[object_class]
184-
object_class_width = class_width[object_class]
183+
if object_class in class_colors:
184+
object_class_color = class_colors[object_class]
185+
else:
186+
object_class_color = 0xAAAAAA
185187

186188
corners_object = box['corners_3d_transformed']
187189

188-
k3d_plot_box(self.plot, corners_object, object_class_color, object_class_width)
190+
k3d_plot_mesh(self.plot, corners_object, object_class_color)
189191

190192
def draw_plot(self,
191193
radar_origin_plot: bool = False,
@@ -250,4 +252,3 @@ def draw_plot(self,
250252

251253
with open(f'{html_name}.html', 'w') as f:
252254
f.write(data)
253-

0 commit comments

Comments
 (0)