Skip to content

Commit e753ecb

Browse files
[Enhance] Speed up loading text file for indoor datasets. (open-mmlab#2585)
* Update indoor3d_util.py Changed data load function. Dataset parsing was accelerated from about 5 hours to 10 minutes. * Added pandas import * minor fix * fix markdown --------- Co-authored-by: JingweiZhang12 <zjw18@mails.tsinghua.edu.cn>
1 parent 3fa0e8b commit e753ecb

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

data/s3dis/indoor3d_util.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from os import path as osp
33

44
import numpy as np
5+
import pandas as pd
56

67
# -----------------------------------------------------------------------------
78
# CONSTANTS
@@ -39,7 +40,7 @@ def export(anno_path, out_filename):
3940
one_class = osp.basename(f).split('_')[0]
4041
if one_class not in class_names: # some rooms have 'staris' class
4142
one_class = 'clutter'
42-
points = np.loadtxt(f)
43+
points = pd.read_csv(f, header=None, sep=' ').to_numpy()
4344
labels = np.ones((points.shape[0], 1)) * class2label[one_class]
4445
ins_labels = np.ones((points.shape[0], 1)) * ins_idx
4546
ins_idx += 1

docs/en/user_guides/coord_sys_tutorial.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ We will stick to the three coordinate systems defined in this tutorial in the fu
6060

6161
## Definition of the yaw angle
6262

63-
Please refer to [wikipedia](https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles) for the standard definition of the yaw angle. In object detection, we choose an axis as the gravity axis, and a reference direction on the plane $\Pi$ perpendicular to the gravity axis, then the reference direction has a yaw angle of 0, and other directions on $\Pi$ have non-zero yaw angles depending on its angle with the reference direction.
63+
Please refer to [wikipedia](https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles) for the standard definition of the yaw angle. In object detection, we choose an axis as the gravity axis, and a reference direction on the plane $\\Pi$ perpendicular to the gravity axis, then the reference direction has a yaw angle of 0, and other directions on $\\Pi$ have non-zero yaw angles depending on its angle with the reference direction.
6464

6565
Currently, for all supported datasets, annotations do not include pitch angle and roll angle, which means we need only consider the yaw angle when predicting boxes and calculating overlap between boxes.
6666

6767
In MMDetection3D, all three coordinate systems are right-handed coordinate systems, which means the ascending direction of the yaw angle is counter-clockwise if viewed from the negative direction of the gravity axis (the axis is pointing at one's eyes).
6868

69-
The figure below shows that, in this right-handed coordinate system, if we set the positive direction of the x-axis as a reference direction, then the positive direction of the y-axis has a yaw angle of $\frac{\pi}{2}$.
69+
The figure below shows that, in this right-handed coordinate system, if we set the positive direction of the x-axis as a reference direction, then the positive direction of the y-axis has a yaw angle of $\\frac{\\pi}{2}$.
7070

7171
```
7272
z up y front (yaw=0.5*pi)
@@ -200,7 +200,7 @@ Then, the box dimensions before and after the conversion satisfy the following r
200200

201201
Finally, the yaw angle should also be converted:
202202

203-
- $r\_{LiDAR}=-\frac{\pi}{2}-r\_{camera}$
203+
- $r\_{LiDAR}=-\\frac{\\pi}{2}-r\_{camera}$
204204

205205
See the code [here](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/core/bbox/structures/box_3d_mode.py) for more details.
206206

@@ -228,18 +228,18 @@ For each box related op, we have marked the type of boxes to which we can apply
228228

229229
No. For example, in KITTI, we need a calibration matrix when converting from Camera coordinate system to LiDAR coordinate system.
230230

231-
#### Q3: How does a phase difference of $2\pi$ in the yaw angle of a box affect evaluation?
231+
#### Q3: How does a phase difference of $2\\pi$ in the yaw angle of a box affect evaluation?
232232

233-
For IoU calculation, a phase difference of $2\pi$ in the yaw angle will result in the same box, thus not affecting evaluation.
233+
For IoU calculation, a phase difference of $2\\pi$ in the yaw angle will result in the same box, thus not affecting evaluation.
234234

235-
For angle prediction evaluation such as the NDS metric in NuScenes and the AOS metric in KITTI, the angle of predicted boxes will be first standardized, so the phase difference of $2\pi$ will not change the result.
235+
For angle prediction evaluation such as the NDS metric in NuScenes and the AOS metric in KITTI, the angle of predicted boxes will be first standardized, so the phase difference of $2\\pi$ will not change the result.
236236

237-
#### Q4: How does a phase difference of $\pi$ in the yaw angle of a box affect evaluation?
237+
#### Q4: How does a phase difference of $\\pi$ in the yaw angle of a box affect evaluation?
238238

239-
For IoU calculation, a phase difference of $\pi$ in the yaw angle will result in the same box, thus not affecting evaluation.
239+
For IoU calculation, a phase difference of $\\pi$ in the yaw angle will result in the same box, thus not affecting evaluation.
240240

241241
However, for angle prediction evaluation, this will result in the exact opposite direction.
242242

243-
Just think about a car. The yaw angle is the angle between the direction of the car front and the positive direction of the x-axis. If we add $\pi$ to this angle, the car front will become the car rear.
243+
Just think about a car. The yaw angle is the angle between the direction of the car front and the positive direction of the x-axis. If we add $\\pi$ to this angle, the car front will become the car rear.
244244

245-
For categories such as barrier, the front and the rear have no difference, therefore a phase difference of $\pi$ will not affect the angle prediction score.
245+
For categories such as barrier, the front and the rear have no difference, therefore a phase difference of $\\pi$ will not affect the angle prediction score.

docs/zh_cn/user_guides/coord_sys_tutorial.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ MMDetection3D 使用 3 种不同的坐标系。3D 目标检测领域中不同坐
6060

6161
## 转向角 (yaw) 的定义
6262

63-
请参考[维基百科](https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles)了解转向角的标准定义。在目标检测中,我们选择一个轴作为重力轴,并在垂直于重力轴的平面 $\Pi$ 上选取一个参考方向,那么参考方向的转向角为 0,在 $\Pi$ 上的其他方向有非零的转向角,其角度取决于其与参考方向的角度。
63+
请参考[维基百科](https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles)了解转向角的标准定义。在目标检测中,我们选择一个轴作为重力轴,并在垂直于重力轴的平面 $\\Pi$ 上选取一个参考方向,那么参考方向的转向角为 0,在 $\\Pi$ 上的其他方向有非零的转向角,其角度取决于其与参考方向的角度。
6464

6565
目前,对于所有支持的数据集,标注不包括俯仰角 (pitch) 和滚动角 (roll),这意味着我们在预测框和计算框之间的重叠时只需考虑转向角 (yaw)。
6666

6767
在 MMDetection3D 中,所有坐标系都是右手坐标系,这意味着如果从重力轴的负方向(轴的正方向指向人眼)看,转向角 (yaw) 沿着逆时针方向增加。
6868

69-
下图显示,在右手坐标系中,如果我们设定 x 轴正方向为参考方向,那么 y 轴正方向的转向角 (yaw) 为 $\frac{\pi}{2}$。
69+
下图显示,在右手坐标系中,如果我们设定 x 轴正方向为参考方向,那么 y 轴正方向的转向角 (yaw) 为 $\\frac{\\pi}{2}$。
7070

7171
```
7272
z 上 y 前 (yaw=0.5*pi)
@@ -200,7 +200,7 @@ SUN RGB-D 的原始数据不是点云而是 RGB-D 图像。我们通过反投影
200200

201201
最后,转向角 (yaw) 也应该被转换:
202202

203-
- $r\_{LiDAR}=-\frac{\pi}{2}-r\_{camera}$
203+
- $r\_{LiDAR}=-\\frac{\\pi}{2}-r\_{camera}$
204204

205205
详见[此处](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/core/bbox/structures/box_3d_mode.py)代码了解更多细节。
206206

@@ -228,18 +228,18 @@ SUN RGB-D 的原始数据不是点云而是 RGB-D 图像。我们通过反投影
228228

229229
否。例如在 KITTI 中,从相机坐标系转换为激光雷达坐标系时,我们需要一个校准矩阵。
230230

231-
#### Q3: 框中转向角 (yaw) $2\pi$ 的相位差如何影响评估?
231+
#### Q3: 框中转向角 (yaw) $2\\pi$ 的相位差如何影响评估?
232232

233-
对于交并比 (IoU) 计算,转向角 (yaw) 有 $2\pi$ 的相位差的两个框是相同的,所以不会影响评估。
233+
对于交并比 (IoU) 计算,转向角 (yaw) 有 $2\\pi$ 的相位差的两个框是相同的,所以不会影响评估。
234234

235-
对于角度预测评估,例如 NuScenes 中的 NDS 指标和 KITTI 中的 AOS 指标,会先对预测框的角度进行标准化,因此 $2\pi$ 的相位差不会改变结果。
235+
对于角度预测评估,例如 NuScenes 中的 NDS 指标和 KITTI 中的 AOS 指标,会先对预测框的角度进行标准化,因此 $2\\pi$ 的相位差不会改变结果。
236236

237-
#### Q4: 框中转向角 (yaw) $\pi$ 的相位差如何影响评估?
237+
#### Q4: 框中转向角 (yaw) $\\pi$ 的相位差如何影响评估?
238238

239-
对于交并比 (IoU) 计算,转向角 (yaw) 有 $\pi$ 的相位差的两个框是相同的,所以不会影响评估。
239+
对于交并比 (IoU) 计算,转向角 (yaw) 有 $\\pi$ 的相位差的两个框是相同的,所以不会影响评估。
240240

241241
然而,对于角度预测评估,这会导致完全相反的方向。
242242

243-
考虑一辆汽车,转向角 (yaw) 是汽车前部方向与 x 轴正方向之间的夹角。如果我们将该角度增加 $\pi$,车前部将变成车后部。
243+
考虑一辆汽车,转向角 (yaw) 是汽车前部方向与 x 轴正方向之间的夹角。如果我们将该角度增加 $\\pi$,车前部将变成车后部。
244244

245-
对于某些类别,例如障碍物,前后没有区别,因此 $\pi$ 的相位差不会对角度预测分数产生影响。
245+
对于某些类别,例如障碍物,前后没有区别,因此 $\\pi$ 的相位差不会对角度预测分数产生影响。

0 commit comments

Comments
 (0)