Points of instances in CAM coordinates. Args: tensor (Tensor or np.ndarray or Sequence[Sequence[float]]): The points data with shape (N, points_dim). points_dim (int): Integer indicating the dimension of a point. Each row is (x, y, z, ...). Defaults to 3.
| 8 | |
| 9 | |
| 10 | class CameraPoints(BasePoints): |
| 11 | """Points of instances in CAM coordinates. |
| 12 | |
| 13 | Args: |
| 14 | tensor (Tensor or np.ndarray or Sequence[Sequence[float]]): The points |
| 15 | data with shape (N, points_dim). |
| 16 | points_dim (int): Integer indicating the dimension of a point. Each row |
| 17 | is (x, y, z, ...). Defaults to 3. |
| 18 | attribute_dims (dict, optional): Dictionary to indicate the meaning of |
| 19 | extra dimension. Defaults to None. |
| 20 | |
| 21 | Attributes: |
| 22 | tensor (Tensor): Float matrix with shape (N, points_dim). |
| 23 | points_dim (int): Integer indicating the dimension of a point. Each row |
| 24 | is (x, y, z, ...). |
| 25 | attribute_dims (dict, optional): Dictionary to indicate the meaning of |
| 26 | extra dimension. Defaults to None. |
| 27 | rotation_axis (int): Default rotation axis for points rotation. |
| 28 | """ |
| 29 | |
| 30 | def __init__(self, |
| 31 | tensor: Union[Tensor, np.ndarray, Sequence[Sequence[float]]], |
| 32 | points_dim: int = 3, |
| 33 | attribute_dims: Optional[dict] = None) -> None: |
| 34 | super(CameraPoints, self).__init__(tensor, |
| 35 | points_dim=points_dim, |
| 36 | attribute_dims=attribute_dims) |
| 37 | self.rotation_axis = 1 |
| 38 | |
| 39 | def flip(self, bev_direction: str = 'horizontal') -> None: |
| 40 | """Flip the points along given BEV direction. |
| 41 | |
| 42 | Args: |
| 43 | bev_direction (str): Flip direction (horizontal or vertical). |
| 44 | Defaults to 'horizontal'. |
| 45 | """ |
| 46 | assert bev_direction in ('horizontal', 'vertical') |
| 47 | if bev_direction == 'horizontal': |
| 48 | self.tensor[:, 0] = -self.tensor[:, 0] |
| 49 | elif bev_direction == 'vertical': |
| 50 | self.tensor[:, 2] = -self.tensor[:, 2] |
| 51 | |
| 52 | @property |
| 53 | def bev(self) -> Tensor: |
| 54 | """Tensor: BEV of the points in shape (N, 2).""" |
| 55 | return self.tensor[:, [0, 2]] |
| 56 | |
| 57 | def convert_to(self, |
| 58 | dst: int, |
| 59 | rt_mat: Optional[Union[Tensor, |
| 60 | np.ndarray]] = None) -> 'BasePoints': |
| 61 | """Convert self to ``dst`` mode. |
| 62 | |
| 63 | Args: |
| 64 | dst (int): The target Point mode. |
| 65 | rt_mat (Tensor or np.ndarray, optional): The rotation and |
| 66 | translation matrix between different coordinates. |
| 67 | Defaults to None. The conversion from ``src`` coordinates to |
nothing calls this directly
no outgoing calls
no test coverage detected