Unverified Commit 7c623352 authored by ChaimZhu's avatar ChaimZhu Committed by GitHub
Browse files

[Doc] Add coords system Chinese doc and fix English doc (#1001)

* add coords Chinese doc and fix en doc

* fix typos

* fix typos and change latex insert methods

* fix image show error

* change coords image link

* fix typos

* fix typos

* fix some typos

* fix typos
parent 94c2d862
# Coordinate System Tutorial # Tutorial 6: Coordinate System
## Overview ## Overview
...@@ -32,7 +32,7 @@ Despite the variety of datasets and equipment, by summarizing the line of works ...@@ -32,7 +32,7 @@ Despite the variety of datasets and equipment, by summarizing the line of works
|/ |/
y left <------ 0 ------ right y left <------ 0 ------ right
``` ```
- Depth coordinate system, the coordinate system used by VoteNet, H3DNet, etc., in which the negative direction of the z-axis points to the ground, the positive direction of the x-axis points to the right, and the positive direction of the y-axis points to the front. - Depth coordinate system -- the coordinate system used by VoteNet, H3DNet, etc., in which the negative direction of the z-axis points to the ground, the positive direction of the x-axis points to the right, and the positive direction of the y-axis points to the front.
``` ```
z up y front z up y front
^ ^ ^ ^
...@@ -43,11 +43,11 @@ Despite the variety of datasets and equipment, by summarizing the line of works ...@@ -43,11 +43,11 @@ Despite the variety of datasets and equipment, by summarizing the line of works
left ------ 0 ------> x right left ------ 0 ------> x right
``` ```
The definition of coordinate systems in this tutorial is actually **more than just defining the three axes**. For a box in the form of <img src="https://render.githubusercontent.com/render/math?math=(x, y, z, dx, dy, dz, r)">, our coordinate systems also define how to interpret the box dimensions <img src="https://render.githubusercontent.com/render/math?math=(dx, dy, dz)"> and the yaw angle <img src="https://render.githubusercontent.com/render/math?math=r">. The definition of coordinate systems in this tutorial is actually **more than just defining the three axes**. For a box in the form of ``$$`(x, y, z, dx, dy, dz, r)`$$``, our coordinate systems also define how to interpret the box dimensions ``$$`(dx, dy, dz)`$$`` and the yaw angle ``$$`r`$$``.
The illustration of the three coordinate systems is shown below: The illustration of the three coordinate systems is shown below:
![coord_sys_all](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/resources/coord_sys_all.png) ![](https://raw.githubusercontent.com/open-mmlab/mmdetection3d/v1.0.0.dev0/resources/coord_sys_all.png)
The three figures above are the 3D coordinate systems while the three figures below are the bird's eye view. The three figures above are the 3D coordinate systems while the three figures below are the bird's eye view.
...@@ -55,13 +55,13 @@ We will stick to the three coordinate systems defined in this tutorial in the fu ...@@ -55,13 +55,13 @@ We will stick to the three coordinate systems defined in this tutorial in the fu
## Definition of the yaw angle ## Definition of the yaw angle
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 <img src="https://render.githubusercontent.com/render/math?math=\Pi"> perpendicular to the gravity axis, then the reference direction has a yaw angle of 0, and other directions on <img src="https://render.githubusercontent.com/render/math?math=\Pi"> have non-zero yaw angles depending on its angle with the reference direction. 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.
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. 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.
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). 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).
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 <img src="https://render.githubusercontent.com/render/math?math=\frac{\pi}{2}">. 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}`$$``.
``` ```
z up y front (yaw=0.5*pi) z up y front (yaw=0.5*pi)
...@@ -92,9 +92,9 @@ __|____|____|____|______\ x right ...@@ -92,9 +92,9 @@ __|____|____|____|______\ x right
## Definition of the box dimensions ## Definition of the box dimensions
The definition of the box dimensions cannot be disentangled with the definition of the yaw angle. In the previous section, we said that the direction of a box is defined to be parallel with the x-axis if its yaw angle is 0. Then naturally, the dimension of a box which corresponds to the x-axis should be <img src="https://render.githubusercontent.com/render/math?math=dx">. However, this is not always the case in some datasets (we will address that later). The definition of the box dimensions cannot be disentangled with the definition of the yaw angle. In the previous section, we said that the direction of a box is defined to be parallel with the x-axis if its yaw angle is 0. Then naturally, the dimension of a box which corresponds to the x-axis should be ``$$`dx`$$``. However, this is not always the case in some datasets (we will address that later).
The following figures show the meaning of the correspondence between the x-axis and <img src="https://render.githubusercontent.com/render/math?math=dx">, and between the y-axis and <img src="https://render.githubusercontent.com/render/math?math=dy">. The following figures show the meaning of the correspondence between the x-axis and ``$$`dx`$$``, and between the y-axis and ``$$`dy`$$``.
``` ```
y front y front
...@@ -111,7 +111,7 @@ __|____|____|____|______\ x right ...@@ -111,7 +111,7 @@ __|____|____|____|______\ x right
| dy | dy
``` ```
Note that the box direction is always parallel with the edge <img src="https://render.githubusercontent.com/render/math?math=dx">. Note that the box direction is always parallel with the edge ``$$`dx`$$``.
``` ```
y front y front
...@@ -132,20 +132,20 @@ __|____|____|____|_________\ x right ...@@ -132,20 +132,20 @@ __|____|____|____|_________\ x right
### KITTI ### KITTI
The raw annotation of KITTI is under Camera coordinate system, see [get_label_anno](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/tools/data_converter/kitti_data_utils.py). In MMDetection3D, to train models on KITTI, the data is first converted from camera to LiDAR, see [get_ann_info](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/datasets/kitti_dataset.py). The raw annotation of KITTI is under camera coordinate system, see [get_label_anno](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/tools/data_converter/kitti_data_utils.py). In MMDetection3D, to train LiDAR-based models on KITTI, the data is first converted from camera coordinate system to LiDAR coordinate system, see [get_ann_info](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/datasets/kitti_dataset.py). For training vision-based models, the data is kept in the camera coordinate system.
In SECOND, the LiDAR coordinate system for a box is defined as follows (a bird's eye view): In SECOND, the LiDAR coordinate system for a box is defined as follows (a bird's eye view):
![lidar](https://raw.githubusercontent.com/traveller59/second.pytorch/master/images/kittibox.png) ![](https://raw.githubusercontent.com/traveller59/second.pytorch/master/images/kittibox.png)
For each box, the dimensions are <img src="https://render.githubusercontent.com/render/math?math=(w, l, h)">, and the reference direction for the yaw angle is the positive direction of the y axis. For more details, refer to the [repo](https://github.com/traveller59/second.pytorch#concepts). For each box, the dimensions are ``$$`(w, l, h)`$$``, and the reference direction for the yaw angle is the positive direction of the y axis. For more details, refer to the [repo](https://github.com/traveller59/second.pytorch#concepts).
Our LiDAR coordinate system has two changes: Our LiDAR coordinate system has two changes:
- The yaw angle is defined to be right-handed instead of left-handed for consistency; - The yaw angle is defined to be right-handed instead of left-handed for consistency;
- The box dimensions are <img src="https://render.githubusercontent.com/render/math?math=(l, w, h)"> instead of <img src="https://render.githubusercontent.com/render/math?math=(w, l, h)">, since <img src="https://render.githubusercontent.com/render/math?math=w"> corresponds to <img src="https://render.githubusercontent.com/render/math?math=dy"> and <img src="https://render.githubusercontent.com/render/math?math=l"> corresponds to <img src="https://render.githubusercontent.com/render/math?math=dx"> in KITTI. - The box dimensions are ``$$`(l, w, h)`$$`` instead of ``$$`(w, l, h)`$$``, since ``$$`w`$$`` corresponds to ``$$`dy`$$`` and ``$$`l`$$`` corresponds to ``$$`dx`$$`` in KITTI.
### Waymo ### Waymo
...@@ -153,7 +153,7 @@ We use the KITTI-format data of Waymo dataset. Therefore, KITTI and Waymo also s ...@@ -153,7 +153,7 @@ We use the KITTI-format data of Waymo dataset. Therefore, KITTI and Waymo also s
### NuScenes ### NuScenes
NuScenes provides a toolkit for evaluation, in which each box is wrapped into a `Box` instance. The coordinate system of `Box` is different from our LiDAR coordinate system in that the first two elements of the box dimension correspond to <img src="https://render.githubusercontent.com/render/math?math=(dy, dx)">, or <img src="https://render.githubusercontent.com/render/math?math=(w, l)">, respectively, instead of the reverse. For more details, please refer to the NuScenes [tutorial](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/docs/datasets/nuscenes_det.md#notes). NuScenes provides a toolkit for evaluation, in which each box is wrapped into a `Box` instance. The coordinate system of `Box` is different from our LiDAR coordinate system in that the first two elements of the box dimension correspond to ``$$`(dy, dx)`$$``, or ``$$`(w, l)`$$``, respectively, instead of the reverse. For more details, please refer to the NuScenes [tutorial](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/docs/datasets/nuscenes_det.md#notes).
Readers may refer to the [NuScenes development kit](https://github.com/nutonomy/nuscenes-devkit/tree/master/python-sdk/nuscenes/eval/detection) for the definition of a [NuScenes box](https://github.com/nutonomy/nuscenes-devkit/blob/2c6a752319f23910d5f55cc995abc547a9e54142/python-sdk/nuscenes/utils/data_classes.py#L457) and implementation of [NuScenes evaluation](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/eval/detection/evaluate.py). Readers may refer to the [NuScenes development kit](https://github.com/nutonomy/nuscenes-devkit/tree/master/python-sdk/nuscenes/eval/detection) for the definition of a [NuScenes box](https://github.com/nutonomy/nuscenes-devkit/blob/2c6a752319f23910d5f55cc995abc547a9e54142/python-sdk/nuscenes/utils/data_classes.py#L457) and implementation of [NuScenes evaluation](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/eval/detection/evaluate.py).
...@@ -185,25 +185,25 @@ Take the conversion between our Camera coordinate system and LiDAR coordinate sy ...@@ -185,25 +185,25 @@ Take the conversion between our Camera coordinate system and LiDAR coordinate sy
First, for points and box centers, the coordinates before and after the conversion satisfy the following relationship: First, for points and box centers, the coordinates before and after the conversion satisfy the following relationship:
- <img src="https://render.githubusercontent.com/render/math?math=x_{LiDAR}=z_{camera}"> - ``$$`x_{LiDAR}=z_{camera}`$$``
- <img src="https://render.githubusercontent.com/render/math?math=y_{LiDAR}=-x_{camera}"> - ``$$`y_{LiDAR}=-x_{camera}`$$``
- <img src="https://render.githubusercontent.com/render/math?math=z_{LiDAR}=-y_{camera}"> - ``$$`z_{LiDAR}=-y_{camera}`$$``
Then, the box dimensions before and after the conversion satisfy the following relationship: Then, the box dimensions before and after the conversion satisfy the following relationship:
- <img src="https://render.githubusercontent.com/render/math?math=dx_{LiDAR}=dz_{camera}"> - ``$$`dx_{LiDAR}=dx_{camera}`$$``
- <img src="https://render.githubusercontent.com/render/math?math=dy_{LiDAR}=dx_{camera}"> - ``$$`dy_{LiDAR}=dz_{camera}`$$``
- <img src="https://render.githubusercontent.com/render/math?math=dz_{LiDAR}=dy_{camera}"> - ``$$`dz_{LiDAR}=dy_{camera}`$$``
Finally, the yaw angle should also be converted: Finally, the yaw angle should also be converted:
- <img src="https://render.githubusercontent.com/render/math?math=r_{LiDAR}=-\frac{\pi}{2}-r_{camera}"> - ``$$`r_{LiDAR}=-\frac{\pi}{2}-r_{camera}`$$``
See the code [here](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/box_3d_mode.py) for more details. See the code [here](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/box_3d_mode.py) for more details.
### Bird's Eye View ### Bird's Eye View
The BEV of a camera coordinate system box is <img src="https://render.githubusercontent.com/render/math?math=(x, z, dx, dz, -r)"> if the 3D box is <img src="https://render.githubusercontent.com/render/math?math=(x, y, z, dx, dy, dz, r)">. The inversion of the sign of the yaw angle is because the positive direction of the gravity axis of the Camera coordinate system points to the ground. The BEV of a camera coordinate system box is ``$$`(x, z, dx, dz, -r)`$$`` if the 3D box is ``$$`(x, y, z, dx, dy, dz, r)`$$``. The inversion of the sign of the yaw angle is because the positive direction of the gravity axis of the Camera coordinate system points to the ground.
See the code [here](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/cam_box3d.py) for more details. See the code [here](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/cam_box3d.py) for more details.
...@@ -225,18 +225,18 @@ For each box related op, we have marked the type of boxes to which we can apply ...@@ -225,18 +225,18 @@ For each box related op, we have marked the type of boxes to which we can apply
No. For example, in KITTI, we need a calibration matrix when converting from Camera coordinate system to LiDAR coordinate system. No. For example, in KITTI, we need a calibration matrix when converting from Camera coordinate system to LiDAR coordinate system.
#### Q3: How does a phase difference of <img src="https://render.githubusercontent.com/render/math?math=2\pi"> in the yaw angle of a box affect evaluation? #### Q3: How does a phase difference of ``$$`2\pi`$$`` in the yaw angle of a box affect evaluation?
For IoU calculation, a phase difference of <img src="https://render.githubusercontent.com/render/math?math=2\pi"> in the yaw angle will result in the same box, thus not affecting evaluation. For IoU calculation, a phase difference of ``$$`2\pi`$$`` in the yaw angle will result in the same box, thus not affecting evaluation.
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 will not change the result. 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.
#### Q4: How does a phase difference of <img src="https://render.githubusercontent.com/render/math?math=\pi"> in the yaw angle of a box affect evaluation? #### Q4: How does a phase difference of ``$$`\pi`$$`` in the yaw angle of a box affect evaluation?
For IoU calculation, a phase difference of <img src="https://render.githubusercontent.com/render/math?math=\pi"> in the yaw angle will result in the same box, thus not affecting evaluation. For IoU calculation, a phase difference of ``$$`\pi`$$`` in the yaw angle will result in the same box, thus not affecting evaluation.
However, for angle prediction evaluation, this will result in the exact opposite direction. However, for angle prediction evaluation, this will result in the exact opposite direction.
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 <img src="https://render.githubusercontent.com/render/math?math=\pi"> to this angle, the car front will become the car rear. 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.
For categories such as barrier, the front and the rear have no difference, therefore a phase difference of <img src="https://render.githubusercontent.com/render/math?math=\pi"> will not affect the angle prediction score. 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.
# 坐标系教程 # 教程 6: 坐标系
## 概述
MMDetection3D 使用 3 种不同的坐标系。3D 目标检测领域中不同坐标系的存在是非常有必要的,因为对于各种 3D 数据采集设备来说,如激光雷达、深度相机等,使用的坐标系是不一致的,不同的 3D 数据集也遵循不同的数据格式。早期的工作,比如 SECOND、VoteNet 将原始数据转换为另一种格式,形成了一些后来的工作也遵循的约定,使得不同坐标系的之间的转换变得更加复杂。
尽管数据集和设备的多种多样,但是通过总结 3D 目标检测的工作线,我们可以将坐标系大致分为三类:
- 相机坐标系 -- 大多数相机的坐标系,在该坐标系中 y 轴正方向指向地面,x 轴正方向指向右侧,z 轴正方向指向前方。
```
上 z 前
| ^
| /
| /
| /
|/
左 ------ 0 ------> x 右
|
|
|
|
v
y 下
```
- 激光雷达坐标系 -- 众多激光雷达的坐标系,在该坐标系中 z 轴负方向指向地面,x 轴正方向指向前方,y 轴正方向指向左侧。
```
z 上 x 前
^ ^
| /
| /
| /
|/
y 左 <------ 0 ------ 右
```
- 深度坐标系 -- VoteNet,H3DNet 等模型使用的坐标系,在该坐标系中 z 轴负方向指向地面,x 轴正方向指向右侧,y 轴正方向指向前方。
```
z 上 y 前
^ ^
| /
| /
| /
|/
左 ------ 0 ------> x 右
```
该教程中的坐标系的定义实际上**不仅仅是定义三个轴**。对于形如 ``$$`(x, y, z, dx, dy, dz, r)`$$`` 的框来说,我们的坐标系也定义了如何解释框的尺寸 ``$$`(dx, dy, dz)`$$`` 和 转向角 (yaw) 角度``$$`r`$$``
**注意**: yaw 角也被翻译为偏航角,这里为了契合自动驾驶场景,在 MMDetection3D 文档中我们称之为转向角。
三个坐标系的图示如下:
![](https://raw.githubusercontent.com/open-mmlab/mmdetection3d/v1.0.0.dev0/resources/coord_sys_all.png)
上面三张图是 3D 坐标系,下面三张图是鸟瞰图。
以后我们将坚持使用本教程中定义的三个坐标系。
## 转向角 (yaw) 的定义
请参考 [维基百科](https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles) 了解转向角的标准定义。在目标检测中,我们选择一个轴作为重力轴,并在垂直于重力轴的平面 ``$$`\Pi`$$`` 上选取一个参考方向,那么参考方向的转向角为 0,在 ``$$`\Pi`$$`` 上的其他方向有非零的转向角,其角度取决于其与参考方向的角度。
目前,对于所有支持的数据集,标注不包括俯仰角 (pitch) 和滚动角 (roll),这意味着我们在预测框和计算框之间的重叠时只需要考虑转向角 (yaw)。
在 MMDetection3D 中,所有三个坐标系都是右手坐标系,这意味着如果从重力轴的负方向(轴的正方向对着人眼)看,转向角 (yaw) 的沿着逆时针方向增加的。
下图显示,在右手坐标系中,如果我们设定 x 轴正方向为参考方向,那么 y 轴正方向的转向角 (yaw) 为 ``$$`\frac{\pi}{2}`$$``
```
z 上 y 前 (yaw=0.5*pi)
^ ^
| /
| /
| /
|/
左 (yaw=pi) ------ 0 ------> x 右 (yaw=0)
```
对于一个框来说,其转向角 (yaw) 的值等于其方向减去一个参考方向。在 MMDetection3D 的所有三个坐标系中,参考方向总是 x 轴的正方向,而如果一个框的转向角 (yaw) 为 0,则其方向被定义为与 x 轴平行。框的转向角 (yaw) 的定义如下图所示。
```
y 前
^ 框的方向 (yaw=0.5*pi)
/|\ ^
| /|\
| ____|____
| | | |
| | | |
__|____|____|____|______\ x 右
| | | | /
| | | |
| |____|____|
|
```
## 框尺寸的定义
框尺寸的定义与转向角 (yaw) 的定义是分不开的。在上一节中,我们说如果一个框的转向角 (yaw) 为 0,它的方向就被定义为与 x 轴平行。那么自然地,一个框对应于 x 轴的尺寸就应该是 ``$$`dx`$$``,但是,这在某些数据集中并非总是如此(我们稍后会解决这个问题)。
下图展示了 x 轴和 ``$$`dx`$$`` ,y 轴和 ``$$`dy`$$`` 对应的含义。
```
y 前
^ 框的方向 (yaw=0.5*pi)
/|\ ^
| /|\
| ____|____
| | | |
| | | | dx
__|____|____|____|______\ x 右
| | | | /
| | | |
| |____|____|
| dy
```
注意框的方向总是和 ``$$`dx`$$`` 边平行。
```
y 前
^ _________
/|\ | | |
| | | |
| | | | dy
| |____|____|____\ 框的方向 (yaw=0)
| | | | /
__|____|____|____|_________\ x 右
| | | | /
| |____|____|
| dx
|
```
## 与支持的数据集的原始坐标系的关系
KITTI 数据集的原始标注是在相机坐标系下的,见 [get_label_anno](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/tools/data_converter/kitti_data_utils.py)。在 MMDetection3D 中,为了在 KITTI 数据集上训练基于激光雷达的模型,首先将数据从相机坐标系转换到激光雷达坐标,见 [get_ann_info](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/datasets/kitti_dataset.py),对于训练基于视觉的模型,数据保持在相机坐标系不变。
在 SECOND 中,框的激光雷达坐标系定义如下(鸟瞰图):
![](https://raw.githubusercontent.com/traveller59/second.pytorch/master/images/kittibox.png)
对于每个框来说,尺寸为 ``$$`(w, l, h)`$$``,转向角 (yaw) 的参考方向 y 轴正方向。更多细节请参考 [代码库](https://github.com/traveller59/second.pytorch#concepts)
我们的激光雷达坐标系有两处改变:
- 转向角 (yaw) 被定义为右手而非左手,从而保证一致性;
- 框的尺寸为 ``$$`(l, w, h)`$$``, 而非 ``$$`(w, l, h)`$$``,由于在 KITTI 数据集中 ``$$`w`$$`` 对应于 ``$$`dy`$$````$$`l`$$`` 对应 ``$$`dx`$$``
### Waymo
我们使用 Waymo 数据集的 KITTI 格式数据。因此,在我们的实现中 KITTI 和 Waymo 也共用相同的坐标系。
### NuScenes
NuScense 提供了一个评估工具包,其中每个框都被包装为一个 `Box` 实例。`Box` 的坐标系不同于我们的激光雷达坐标系,在 `Box` 坐标系中,前两个表示框尺寸的元素分别对应 ``$$`(dy, dx)`$$`` 或者 ``$$`(w, l)`$$``,和我们的表示方法相反。更多细节请参照 NuScenes [教程](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/docs/datasets/nuscenes_det.md#notes)
读者可以参考 [NuScenes 开发工具](https://github.com/nutonomy/nuscenes-devkit/tree/master/python-sdk/nuscenes/eval/detection),了解 [NuScenes 框](https://github.com/nutonomy/nuscenes-devkit/blob/2c6a752319f23910d5f55cc995abc547a9e54142/python-sdk/nuscenes/utils/data_classes.py#L457) 的定义和 [NuScenes 评估](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/eval/detection/evaluate.py) 的过程。
### Lyft
就涉及坐标系而言,Lyft 和 nuScenes 共用相同的数据格式。
请参考 [官方网站](https://www.kaggle.com/c/3d-object-detection-for-autonomous-vehicles/data) 获取更多信息。
### ScanNet
ScanNet 的原始数据不是点云而是网格,需要在我们的深度坐标系下进行采样得到点云数据。对于 ScanNet 检测任务,框标注是轴对齐的,并且转向角 (yaw) 始终为 0。因此,我们的深度坐标系中的转向角 (yaw) 的方向对 ScanNet 没有影响。
### SUN RGB-D
SUN RGB-D 的原始数据不是点云而是 RGB-D 图像,我们通过反投影,可以得每张图像的对应的点云,其在我们的深度坐标系下。但是,数据集的标注并不在我们的系统中,所以需要进行转换。
将原始标注转换为我们的深度坐标系下的标注的转换过程请参考 [sunrgbd_data_utils.py](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/tools/data_converter/sunrgbd_data_utils.py)
### S3DIS
在我们的实现中,S3DIS 与 ScanNet 共用相同的坐标系。然而,S3DIS 是一个仅限于分割任务的数据集,因此没有标注是坐标系敏感的。
## 例子
### 框(在不同坐标系间)转换
拿相机坐标系和激光雷达坐标系间的转换为例:
首先,对于点和框中心,坐标转换前后满足下列关系:
- ``$$`x_{LiDAR}=z_{camera}`$$``
- ``$$`y_{LiDAR}=-x_{camera}`$$``
- ``$$`z_{LiDAR}=-y_{camera}`$$``
然后,框的尺寸转换前后满足下列关系:
- ``$$`dx_{LiDAR}=dx_{camera}`$$``
- ``$$`dy_{LiDAR}=dz_{camera}`$$``
- ``$$`dz_{LiDAR}=dy_{camera}`$$``
最后,转向角 (yaw) 也应该被转换:
- ``$$`r_{LiDAR}=-\frac{\pi}{2}-r_{camera}`$$``
详见代码 [这里](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/box_3d_mode.py) 了解更多细节。
### 鸟瞰图
如果 3D 框是 ``$$`(x, y, z, dx, dy, dz, r)`$$``, 相机坐标系框的 BEV 是 ``$$`(x, z, dx, dz, -r)`$$``。转向角 (yaw) 的符号取反是因为相机坐标系的重力轴正方向指向地面。
详见代码 [这里](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/cam_box3d.py) 了解更多细节。
### 框的旋转
我们将各种框的旋转设定为绕着重力轴逆时针旋转。因此,为了旋转一个 3D 框,我们首先需要计算新的框的中心,然后将旋转角添加到转向角 (yaw)。
详见代码 [这里](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/bbox/structures/cam_box3d.py) 了解更多细节。
## 常见问题
#### Q1: 与框相关的算子是否适用于所有坐标系类型?
否,例如:在 [该文件夹](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/ops/roiaware_pool3d) 下的算子只适用于深度坐标系和激光雷达坐标系下的框。由于如果从上方看的话,旋转是顺时针的,所以KITTI 数据集 [这里](https://github.com/open-mmlab/mmdetection3d/blob/v1.0.0.dev0/mmdet3d/core/evaluation/kitti_utils) 的评估函数仅仅适用于相机坐标系下的框。
对于每一个和框相关的算子,我们标注了其所适用的框的类型。
#### Q2: 在每个坐标系中,三个轴是否分别准确指向右侧、正面和地面?
否,例如:在 KITTI 中,从相机坐标系转换为激光雷达坐标系时,我们需要一个校准矩阵。
#### Q3: 框中转向角 (yaw) ``$$`2\pi`$$`` 的相位差如何影响评估?
对于交并比 (IoU) 计算,转向角 (yaw) 有 ``$$`2\pi`$$`` 的相位差的两个框是相同的,所以不会影响评估。
对于角度预测评估,比如 NuScenes 中的 NDS 指标和 KITTI 中的 AOS 指标,会先对预测框的角度进行标准化,因此 ``$$`2\pi`$$`` 的相位差不会改变结果。
#### Q4: 框中转向角 (yaw) ``$$`\pi`$$`` 的相位差如何影响评估?
对于交并比 (IoU) 计算,转向角 (yaw) 有 ``$$`\pi`$$`` 的相位差的两个框是相同的,所以不会影响评估。
然而,对于角度预测评估,这会导致完全相反的方向。
考虑一辆汽车,转向角 (yaw) 是汽车前部方向与 x 轴正方向之间的夹角。如果我们将该角度增加 ``$$`\pi`$$``,车前部将成为车后部。
对于某些类别,例如障碍物,前后没有区别,所以``$$`\pi`$$`` 的相位差不会对角度预测分数产生影响。
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment