3D boxes of instances in Depth coordinates. We keep the "Depth" coordinate system definition in MMDet3D just for clarification of the points coordinates and the flipping augmentation. Coordinates in Depth: .. code-block:: none up z y front (alpha=0.5*pi)
| 68 | |
| 69 | |
| 70 | class EulerDepthInstance3DBoxes: |
| 71 | """3D boxes of instances in Depth coordinates. |
| 72 | |
| 73 | We keep the "Depth" coordinate system definition in MMDet3D just for |
| 74 | clarification of the points coordinates and the flipping augmentation. |
| 75 | |
| 76 | Coordinates in Depth: |
| 77 | |
| 78 | .. code-block:: none |
| 79 | |
| 80 | up z y front (alpha=0.5*pi) |
| 81 | ^ ^ |
| 82 | | / |
| 83 | | / |
| 84 | 0 ------> x right (alpha=0) |
| 85 | |
| 86 | The relative coordinate of bottom center in a Depth box is (0.5, 0.5, 0), |
| 87 | and the yaw is around the z axis, thus the rotation axis=2. |
| 88 | The yaw is 0 at the positive direction of x axis, and decreases from |
| 89 | the positive direction of x to the positive direction of y. |
| 90 | Also note that rotation of DepthInstance3DBoxes is counterclockwise, |
| 91 | which is reverse to the definition of the yaw angle (clockwise). |
| 92 | |
| 93 | Attributes: |
| 94 | tensor (torch.Tensor): Float matrix of N x box_dim. |
| 95 | box_dim (int): Integer indicates the dimension of a box |
| 96 | Each row is (x, y, z, x_size, y_size, z_size, alpha, beta, gamma). |
| 97 | with_yaw (bool): If True, the value of yaw will be set to 0 as minmax |
| 98 | boxes. |
| 99 | """ |
| 100 | |
| 101 | def __init__(self, |
| 102 | tensor, |
| 103 | box_dim=9, |
| 104 | with_yaw=True, |
| 105 | origin=(0.5, 0.5, 0.5)): |
| 106 | |
| 107 | if isinstance(tensor, torch.Tensor): |
| 108 | device = tensor.device |
| 109 | else: |
| 110 | device = torch.device('cpu') |
| 111 | tensor = torch.as_tensor(tensor, dtype=torch.float32, device=device) |
| 112 | if tensor.numel() == 0: |
| 113 | # Use reshape, so we don't end up creating a new tensor that |
| 114 | # does not depend on the inputs (and consequently confuses jit) |
| 115 | tensor = tensor.reshape((0, box_dim)).to(dtype=torch.float32, |
| 116 | device=device) |
| 117 | assert tensor.dim() == 2 and tensor.size(-1) == box_dim, tensor.size() |
| 118 | |
| 119 | if tensor.shape[-1] == 6: |
| 120 | # If the dimension of boxes is 6, we expand box_dim by padding |
| 121 | # (0, 0, 0) as a fake euler angle. |
| 122 | assert box_dim == 6 |
| 123 | fake_rot = tensor.new_zeros(tensor.shape[0], 3) |
| 124 | tensor = torch.cat((tensor, fake_rot), dim=-1) |
| 125 | self.box_dim = box_dim + 3 |
| 126 | elif tensor.shape[-1] == 7: |
| 127 | assert box_dim == 7 |