Shortcuts

Source code for mmdet3d.structures.points.depth_points

# Copyright (c) OpenMMLab. All rights reserved.
from typing import Optional, Sequence, Union

import numpy as np
from torch import Tensor

from .base_points import BasePoints


[docs]class DepthPoints(BasePoints): """Points of instances in DEPTH 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. attribute_dims (dict, optional): Dictionary to indicate the meaning of extra dimension. Defaults to None. Attributes: tensor (Tensor): Float matrix with shape (N, points_dim). points_dim (int): Integer indicating the dimension of a point. Each row is (x, y, z, ...). attribute_dims (dict, optional): Dictionary to indicate the meaning of extra dimension. Defaults to None. rotation_axis (int): Default rotation axis for points rotation. """ def __init__(self, tensor: Union[Tensor, np.ndarray, Sequence[Sequence[float]]], points_dim: int = 3, attribute_dims: Optional[dict] = None) -> None: super(DepthPoints, self).__init__( tensor, points_dim=points_dim, attribute_dims=attribute_dims) self.rotation_axis = 2
[docs] def flip(self, bev_direction: str = 'horizontal') -> None: """Flip the points along given BEV direction. Args: bev_direction (str): Flip direction (horizontal or vertical). Defaults to 'horizontal'. """ assert bev_direction in ('horizontal', 'vertical') if bev_direction == 'horizontal': self.tensor[:, 0] = -self.tensor[:, 0] elif bev_direction == 'vertical': self.tensor[:, 1] = -self.tensor[:, 1]
[docs] def convert_to(self, dst: int, rt_mat: Optional[Union[Tensor, np.ndarray]] = None) -> 'BasePoints': """Convert self to ``dst`` mode. Args: dst (int): The target Point mode. rt_mat (Tensor or np.ndarray, optional): The rotation and translation matrix between different coordinates. Defaults to None. The conversion from ``src`` coordinates to ``dst`` coordinates usually comes along the change of sensors, e.g., from camera to LiDAR. This requires a transformation matrix. Returns: :obj:`BasePoints`: The converted point of the same type in the ``dst`` mode. """ from mmdet3d.structures.bbox_3d import Coord3DMode return Coord3DMode.convert_point( point=self, src=Coord3DMode.DEPTH, dst=dst, rt_mat=rt_mat)
Read the Docs v: stable
Versions
latest
stable
v1.4.0
v1.3.0
v1.2.0
v1.1.1
v1.1.0
v1.0.0rc1
v1.0.0rc0
v0.18.1
v0.18.0
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.0
v0.15.0
v0.14.0
v0.13.0
v0.12.0
v0.11.0
v0.10.0
v0.9.0
dev-1.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.