Commit 53435c62 authored by Yezhen Cong's avatar Yezhen Cong Committed by Tai-Wang
Browse files

[Refactor] Refactor code structure and docstrings (#803)

* refactor points_in_boxes

* Merge same functions of three boxes

* More docstring fixes and unify x/y/z size

* Add "optional" and fix "Default"

* Add "optional" and fix "Default"

* Add "optional" and fix "Default"

* Add "optional" and fix "Default"

* Add "optional" and fix "Default"

* Remove None in function param type

* Fix unittest

* Add comments for NMS functions

* Merge methods of Points

* Add unittest

* Add optional and default value

* Fix box conversion and add unittest

* Fix comments

* Add unit test

* Indent

* Fix CI

* Remove useless \\

* Remove useless \\

* Remove useless \\

* Remove useless \\

* Remove useless \\

* Add unit test for box bev

* More unit tests and refine docstrings in box_np_ops

* Fix comment

* Add deprecation warning
parent 4f36084f
...@@ -291,7 +291,8 @@ def rotate_iou_kernel_eval(N, ...@@ -291,7 +291,8 @@ def rotate_iou_kernel_eval(N,
dev_query_boxes, dev_query_boxes,
dev_iou, dev_iou,
criterion=-1): criterion=-1):
"""Kernel of computing rotated iou. """Kernel of computing rotated IoU. This function is for bev boxes in
camera coordinate system ONLY (the rotation is clockwise).
Args: Args:
N (int): The number of boxes. N (int): The number of boxes.
...@@ -343,10 +344,14 @@ def rotate_iou_gpu_eval(boxes, query_boxes, criterion=-1, device_id=0): ...@@ -343,10 +344,14 @@ def rotate_iou_gpu_eval(boxes, query_boxes, criterion=-1, device_id=0):
in one example with numba.cuda code). convert from [this project]( in one example with numba.cuda code). convert from [this project](
https://github.com/hongzhenwang/RRPN-revise/tree/master/lib/rotation). https://github.com/hongzhenwang/RRPN-revise/tree/master/lib/rotation).
This function is for bev boxes in camera coordinate system ONLY
(the rotation is clockwise).
Args: Args:
boxes (torch.Tensor): rbboxes. format: centers, dims, boxes (torch.Tensor): rbboxes. format: centers, dims,
angles(clockwise when positive) with the shape of [N, 5]. angles(clockwise when positive) with the shape of [N, 5].
query_boxes (float tensor: [K, 5]): rbboxes to compute iou with boxes. query_boxes (torch.FloatTensor, shape=(K, 5)):
rbboxes to compute iou with boxes.
device_id (int, optional): Defaults to 0. Device to use. device_id (int, optional): Defaults to 0. Device to use.
criterion (int, optional): Indicate different type of iou. criterion (int, optional): Indicate different type of iou.
-1 indicate `area_inter / (area1 + area2 - area_inter)`, -1 indicate `area_inter / (area1 + area2 - area_inter)`,
......
...@@ -18,7 +18,7 @@ def load_lyft_gts(lyft, data_root, eval_split, logger=None): ...@@ -18,7 +18,7 @@ def load_lyft_gts(lyft, data_root, eval_split, logger=None):
lyft (:obj:`LyftDataset`): Lyft class in the sdk. lyft (:obj:`LyftDataset`): Lyft class in the sdk.
data_root (str): Root of data for reading splits. data_root (str): Root of data for reading splits.
eval_split (str): Name of the split for evaluation. eval_split (str): Name of the split for evaluation.
logger (logging.Logger | str | None): Logger used for printing logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Default: None. related information during evaluation. Default: None.
Returns: Returns:
...@@ -96,7 +96,7 @@ def lyft_eval(lyft, data_root, res_path, eval_set, output_dir, logger=None): ...@@ -96,7 +96,7 @@ def lyft_eval(lyft, data_root, res_path, eval_set, output_dir, logger=None):
res_path (str): Path of result json file recording detections. res_path (str): Path of result json file recording detections.
eval_set (str): Name of the split for evaluation. eval_set (str): Name of the split for evaluation.
output_dir (str): Output directory for output json files. output_dir (str): Output directory for output json files.
logger (logging.Logger | str | None): Logger used for printing logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Default: None. related information during evaluation. Default: None.
Returns: Returns:
...@@ -202,9 +202,9 @@ def get_single_class_aps(gt, predictions, iou_thresholds): ...@@ -202,9 +202,9 @@ def get_single_class_aps(gt, predictions, iou_thresholds):
Args: Args:
gt (list[dict]): list of dictionaries in the format described above. gt (list[dict]): list of dictionaries in the format described above.
predictions (list[dict]): list of dictionaries in the format \ predictions (list[dict]): list of dictionaries in the format
described below. described below.
iou_thresholds (list[float]): IOU thresholds used to calculate \ iou_thresholds (list[float]): IOU thresholds used to calculate
TP / FN TP / FN
Returns: Returns:
......
...@@ -77,7 +77,7 @@ def seg_eval(gt_labels, seg_preds, label2cat, ignore_index, logger=None): ...@@ -77,7 +77,7 @@ def seg_eval(gt_labels, seg_preds, label2cat, ignore_index, logger=None):
seg_preds (list[torch.Tensor]): Predictions. seg_preds (list[torch.Tensor]): Predictions.
label2cat (dict): Map from label to category name. label2cat (dict): Map from label to category name.
ignore_index (int): Index that will be ignored in evaluation. ignore_index (int): Index that will be ignored in evaluation.
logger (logging.Logger | str | None): The way to print the mAP logger (logging.Logger | str, optional): The way to print the mAP
summary. See `mmdet.utils.print_log()` for details. Default: None. summary. See `mmdet.utils.print_log()` for details. Default: None.
Returns: Returns:
......
...@@ -114,7 +114,7 @@ class KITTI2Waymo(object): ...@@ -114,7 +114,7 @@ class KITTI2Waymo(object):
instance_idx (int): Index of the instance to be converted. instance_idx (int): Index of the instance to be converted.
Returns: Returns:
:obj:`Object`: Predicted instance in waymo dataset \ :obj:`Object`: Predicted instance in waymo dataset
Object proto. Object proto.
""" """
cls = kitti_result['name'][instance_idx] cls = kitti_result['name'][instance_idx]
......
...@@ -12,17 +12,17 @@ class BasePoints(object): ...@@ -12,17 +12,17 @@ class BasePoints(object):
Args: Args:
tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix. tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix.
points_dim (int): Number of the dimension of a point. points_dim (int, optional): Number of the dimension of a point.
Each row is (x, y, z). Default to 3. Each row is (x, y, z). Defaults to 3.
attribute_dims (dict): Dictionary to indicate the meaning of extra attribute_dims (dict, optional): Dictionary to indicate the
dimension. Default to None. meaning of extra dimension. Defaults to None.
Attributes: Attributes:
tensor (torch.Tensor): Float matrix of N x points_dim. tensor (torch.Tensor): Float matrix of N x points_dim.
points_dim (int): Integer indicating the dimension of a point. points_dim (int): Integer indicating the dimension of a point.
Each row is (x, y, z, ...). Each row is (x, y, z, ...).
attribute_dims (bool): Dictionary to indicate the meaning of extra attribute_dims (bool): Dictionary to indicate the meaning of extra
dimension. Default to None. dimension. Defaults to None.
rotation_axis (int): Default rotation axis for points rotation. rotation_axis (int): Default rotation axis for points rotation.
""" """
...@@ -47,7 +47,7 @@ class BasePoints(object): ...@@ -47,7 +47,7 @@ class BasePoints(object):
@property @property
def coord(self): def coord(self):
"""torch.Tensor: Coordinates of each point with size (N, 3).""" """torch.Tensor: Coordinates of each point in shape (N, 3)."""
return self.tensor[:, :3] return self.tensor[:, :3]
@coord.setter @coord.setter
...@@ -63,7 +63,8 @@ class BasePoints(object): ...@@ -63,7 +63,8 @@ class BasePoints(object):
@property @property
def height(self): def height(self):
"""torch.Tensor: A vector with height of each point.""" """torch.Tensor:
A vector with height of each point in shape (N, 1), or None."""
if self.attribute_dims is not None and \ if self.attribute_dims is not None and \
'height' in self.attribute_dims.keys(): 'height' in self.attribute_dims.keys():
return self.tensor[:, self.attribute_dims['height']] return self.tensor[:, self.attribute_dims['height']]
...@@ -93,7 +94,8 @@ class BasePoints(object): ...@@ -93,7 +94,8 @@ class BasePoints(object):
@property @property
def color(self): def color(self):
"""torch.Tensor: A vector with color of each point.""" """torch.Tensor:
A vector with color of each point in shape (N, 3), or None."""
if self.attribute_dims is not None and \ if self.attribute_dims is not None and \
'color' in self.attribute_dims.keys(): 'color' in self.attribute_dims.keys():
return self.tensor[:, self.attribute_dims['color']] return self.tensor[:, self.attribute_dims['color']]
...@@ -145,7 +147,7 @@ class BasePoints(object): ...@@ -145,7 +147,7 @@ class BasePoints(object):
Args: Args:
rotation (float | np.ndarray | torch.Tensor): Rotation matrix rotation (float | np.ndarray | torch.Tensor): Rotation matrix
or angle. or angle.
axis (int): Axis to rotate at. Defaults to None. axis (int, optional): Axis to rotate at. Defaults to None.
""" """
if not isinstance(rotation, torch.Tensor): if not isinstance(rotation, torch.Tensor):
rotation = self.tensor.new_tensor(rotation) rotation = self.tensor.new_tensor(rotation)
...@@ -169,7 +171,11 @@ class BasePoints(object): ...@@ -169,7 +171,11 @@ class BasePoints(object):
@abstractmethod @abstractmethod
def flip(self, bev_direction='horizontal'): def flip(self, bev_direction='horizontal'):
"""Flip the points in BEV along given BEV direction.""" """Flip the points along given BEV direction.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
"""
pass pass
def translate(self, trans_vector): def translate(self, trans_vector):
...@@ -206,7 +212,7 @@ class BasePoints(object): ...@@ -206,7 +212,7 @@ class BasePoints(object):
polygon, we try to reduce the burden for simpler cases. polygon, we try to reduce the burden for simpler cases.
Returns: Returns:
torch.Tensor: A binary vector indicating whether each point is \ torch.Tensor: A binary vector indicating whether each point is
inside the reference range. inside the reference range.
""" """
in_range_flags = ((self.tensor[:, 0] > point_range[0]) in_range_flags = ((self.tensor[:, 0] > point_range[0])
...@@ -217,7 +223,11 @@ class BasePoints(object): ...@@ -217,7 +223,11 @@ class BasePoints(object):
& (self.tensor[:, 2] < point_range[5])) & (self.tensor[:, 2] < point_range[5]))
return in_range_flags return in_range_flags
@abstractmethod @property
def bev(self):
"""torch.Tensor: BEV of the points in shape (N, 2)."""
return self.tensor[:, [0, 1]]
def in_range_bev(self, point_range): def in_range_bev(self, point_range):
"""Check whether the points are in the given range. """Check whether the points are in the given range.
...@@ -226,10 +236,14 @@ class BasePoints(object): ...@@ -226,10 +236,14 @@ class BasePoints(object):
in order of (x_min, y_min, x_max, y_max). in order of (x_min, y_min, x_max, y_max).
Returns: Returns:
torch.Tensor: Indicating whether each point is inside \ torch.Tensor: Indicating whether each point is inside
the reference range. the reference range.
""" """
pass in_range_flags = ((self.bev[:, 0] > point_range[0])
& (self.bev[:, 1] > point_range[1])
& (self.bev[:, 1] < point_range[2])
& (self.bev[:, 1] < point_range[3]))
return in_range_flags
@abstractmethod @abstractmethod
def convert_to(self, dst, rt_mat=None): def convert_to(self, dst, rt_mat=None):
...@@ -237,14 +251,15 @@ class BasePoints(object): ...@@ -237,14 +251,15 @@ class BasePoints(object):
Args: Args:
dst (:obj:`CoordMode`): The target Box mode. dst (:obj:`CoordMode`): The target Box mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation rt_mat (np.ndarray | torch.Tensor, optional): The rotation and
matrix between different coordinates. Defaults to None. translation matrix between different coordinates.
Defaults to None.
The conversion from `src` coordinates to `dst` coordinates The conversion from `src` coordinates to `dst` coordinates
usually comes along the change of sensors, e.g., from camera usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix. to LiDAR. This requires a transformation matrix.
Returns: Returns:
:obj:`BasePoints`: The converted box of the same type \ :obj:`BasePoints`: The converted box of the same type
in the `dst` mode. in the `dst` mode.
""" """
pass pass
...@@ -276,7 +291,7 @@ class BasePoints(object): ...@@ -276,7 +291,7 @@ class BasePoints(object):
subject to Pytorch's indexing semantics. subject to Pytorch's indexing semantics.
Returns: Returns:
:obj:`BasePoints`: A new object of \ :obj:`BasePoints`: A new object of
:class:`BasePoints` after indexing. :class:`BasePoints` after indexing.
""" """
original_type = type(self) original_type = type(self)
...@@ -367,7 +382,7 @@ class BasePoints(object): ...@@ -367,7 +382,7 @@ class BasePoints(object):
device (str | :obj:`torch.device`): The name of the device. device (str | :obj:`torch.device`): The name of the device.
Returns: Returns:
:obj:`BasePoints`: A new boxes object on the \ :obj:`BasePoints`: A new boxes object on the
specific device. specific device.
""" """
original_type = type(self) original_type = type(self)
...@@ -380,7 +395,7 @@ class BasePoints(object): ...@@ -380,7 +395,7 @@ class BasePoints(object):
"""Clone the Points. """Clone the Points.
Returns: Returns:
:obj:`BasePoints`: Box object with the same properties \ :obj:`BasePoints`: Box object with the same properties
as self. as self.
""" """
original_type = type(self) original_type = type(self)
...@@ -405,14 +420,14 @@ class BasePoints(object): ...@@ -405,14 +420,14 @@ class BasePoints(object):
def new_point(self, data): def new_point(self, data):
"""Create a new point object with data. """Create a new point object with data.
The new point and its tensor has the similar properties \ The new point and its tensor has the similar properties
as self and self.tensor, respectively. as self and self.tensor, respectively.
Args: Args:
data (torch.Tensor | numpy.array | list): Data to be copied. data (torch.Tensor | numpy.array | list): Data to be copied.
Returns: Returns:
:obj:`BasePoints`: A new point object with ``data``, \ :obj:`BasePoints`: A new point object with ``data``,
the object's other properties are similar to ``self``. the object's other properties are similar to ``self``.
""" """
new_tensor = self.tensor.new_tensor(data) \ new_tensor = self.tensor.new_tensor(data) \
......
...@@ -7,17 +7,17 @@ class CameraPoints(BasePoints): ...@@ -7,17 +7,17 @@ class CameraPoints(BasePoints):
Args: Args:
tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix. tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix.
points_dim (int): Number of the dimension of a point. points_dim (int, optional): Number of the dimension of a point.
Each row is (x, y, z). Default to 3. Each row is (x, y, z). Defaults to 3.
attribute_dims (dict): Dictionary to indicate the meaning of extra attribute_dims (dict, optional): Dictionary to indicate the
dimension. Default to None. meaning of extra dimension. Defaults to None.
Attributes: Attributes:
tensor (torch.Tensor): Float matrix of N x points_dim. tensor (torch.Tensor): Float matrix of N x points_dim.
points_dim (int): Integer indicating the dimension of a point. points_dim (int): Integer indicating the dimension of a point.
Each row is (x, y, z, ...). Each row is (x, y, z, ...).
attribute_dims (bool): Dictionary to indicate the meaning of extra attribute_dims (bool): Dictionary to indicate the meaning of extra
dimension. Default to None. dimension. Defaults to None.
rotation_axis (int): Default rotation axis for points rotation. rotation_axis (int): Default rotation axis for points rotation.
""" """
...@@ -27,42 +27,35 @@ class CameraPoints(BasePoints): ...@@ -27,42 +27,35 @@ class CameraPoints(BasePoints):
self.rotation_axis = 1 self.rotation_axis = 1
def flip(self, bev_direction='horizontal'): def flip(self, bev_direction='horizontal'):
"""Flip the boxes in BEV along given BEV direction.""" """Flip the points along given BEV direction.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
"""
if bev_direction == 'horizontal': if bev_direction == 'horizontal':
self.tensor[:, 0] = -self.tensor[:, 0] self.tensor[:, 0] = -self.tensor[:, 0]
elif bev_direction == 'vertical': elif bev_direction == 'vertical':
self.tensor[:, 2] = -self.tensor[:, 2] self.tensor[:, 2] = -self.tensor[:, 2]
def in_range_bev(self, point_range): @property
"""Check whether the points are in the given range. def bev(self):
"""torch.Tensor: BEV of the points in shape (N, 2)."""
Args: return self.tensor[:, [0, 2]]
point_range (list | torch.Tensor): The range of point
in order of (x_min, y_min, x_max, y_max).
Returns:
torch.Tensor: Indicating whether each point is inside \
the reference range.
"""
in_range_flags = ((self.tensor[:, 0] > point_range[0])
& (self.tensor[:, 2] > point_range[1])
& (self.tensor[:, 0] < point_range[2])
& (self.tensor[:, 2] < point_range[3]))
return in_range_flags
def convert_to(self, dst, rt_mat=None): def convert_to(self, dst, rt_mat=None):
"""Convert self to ``dst`` mode. """Convert self to ``dst`` mode.
Args: Args:
dst (:obj:`CoordMode`): The target Point mode. dst (:obj:`CoordMode`): The target Point mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation rt_mat (np.ndarray | torch.Tensor, optional): The rotation and
matrix between different coordinates. Defaults to None. translation matrix between different coordinates.
Defaults to None.
The conversion from `src` coordinates to `dst` coordinates The conversion from `src` coordinates to `dst` coordinates
usually comes along the change of sensors, e.g., from camera usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix. to LiDAR. This requires a transformation matrix.
Returns: Returns:
:obj:`BasePoints`: The converted point of the same type \ :obj:`BasePoints`: The converted point of the same type
in the `dst` mode. in the `dst` mode.
""" """
from mmdet3d.core.bbox import Coord3DMode from mmdet3d.core.bbox import Coord3DMode
......
...@@ -7,17 +7,17 @@ class DepthPoints(BasePoints): ...@@ -7,17 +7,17 @@ class DepthPoints(BasePoints):
Args: Args:
tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix. tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix.
points_dim (int): Number of the dimension of a point. points_dim (int, optional): Number of the dimension of a point.
Each row is (x, y, z). Default to 3. Each row is (x, y, z). Defaults to 3.
attribute_dims (dict): Dictionary to indicate the meaning of extra attribute_dims (dict, optional): Dictionary to indicate the
dimension. Default to None. meaning of extra dimension. Defaults to None.
Attributes: Attributes:
tensor (torch.Tensor): Float matrix of N x points_dim. tensor (torch.Tensor): Float matrix of N x points_dim.
points_dim (int): Integer indicating the dimension of a point. points_dim (int): Integer indicating the dimension of a point.
Each row is (x, y, z, ...). Each row is (x, y, z, ...).
attribute_dims (bool): Dictionary to indicate the meaning of extra attribute_dims (bool): Dictionary to indicate the meaning of extra
dimension. Default to None. dimension. Defaults to None.
rotation_axis (int): Default rotation axis for points rotation. rotation_axis (int): Default rotation axis for points rotation.
""" """
...@@ -27,42 +27,30 @@ class DepthPoints(BasePoints): ...@@ -27,42 +27,30 @@ class DepthPoints(BasePoints):
self.rotation_axis = 2 self.rotation_axis = 2
def flip(self, bev_direction='horizontal'): def flip(self, bev_direction='horizontal'):
"""Flip the boxes in BEV along given BEV direction.""" """Flip the points along given BEV direction.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
"""
if bev_direction == 'horizontal': if bev_direction == 'horizontal':
self.tensor[:, 0] = -self.tensor[:, 0] self.tensor[:, 0] = -self.tensor[:, 0]
elif bev_direction == 'vertical': elif bev_direction == 'vertical':
self.tensor[:, 1] = -self.tensor[:, 1] self.tensor[:, 1] = -self.tensor[:, 1]
def in_range_bev(self, point_range):
"""Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
in order of (x_min, y_min, x_max, y_max).
Returns:
torch.Tensor: Indicating whether each point is inside \
the reference range.
"""
in_range_flags = ((self.tensor[:, 0] > point_range[0])
& (self.tensor[:, 1] > point_range[1])
& (self.tensor[:, 0] < point_range[2])
& (self.tensor[:, 1] < point_range[3]))
return in_range_flags
def convert_to(self, dst, rt_mat=None): def convert_to(self, dst, rt_mat=None):
"""Convert self to ``dst`` mode. """Convert self to ``dst`` mode.
Args: Args:
dst (:obj:`CoordMode`): The target Point mode. dst (:obj:`CoordMode`): The target Point mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation rt_mat (np.ndarray | torch.Tensor, optional): The rotation and
matrix between different coordinates. Defaults to None. translation matrix between different coordinates.
Defaults to None.
The conversion from `src` coordinates to `dst` coordinates The conversion from `src` coordinates to `dst` coordinates
usually comes along the change of sensors, e.g., from camera usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix. to LiDAR. This requires a transformation matrix.
Returns: Returns:
:obj:`BasePoints`: The converted point of the same type \ :obj:`BasePoints`: The converted point of the same type
in the `dst` mode. in the `dst` mode.
""" """
from mmdet3d.core.bbox import Coord3DMode from mmdet3d.core.bbox import Coord3DMode
......
...@@ -7,17 +7,17 @@ class LiDARPoints(BasePoints): ...@@ -7,17 +7,17 @@ class LiDARPoints(BasePoints):
Args: Args:
tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix. tensor (torch.Tensor | np.ndarray | list): a N x points_dim matrix.
points_dim (int): Number of the dimension of a point. points_dim (int, optional): Number of the dimension of a point.
Each row is (x, y, z). Default to 3. Each row is (x, y, z). Defaults to 3.
attribute_dims (dict): Dictionary to indicate the meaning of extra attribute_dims (dict, optional): Dictionary to indicate the
dimension. Default to None. meaning of extra dimension. Defaults to None.
Attributes: Attributes:
tensor (torch.Tensor): Float matrix of N x points_dim. tensor (torch.Tensor): Float matrix of N x points_dim.
points_dim (int): Integer indicating the dimension of a point. points_dim (int): Integer indicating the dimension of a point.
Each row is (x, y, z, ...). Each row is (x, y, z, ...).
attribute_dims (bool): Dictionary to indicate the meaning of extra attribute_dims (bool): Dictionary to indicate the meaning of extra
dimension. Default to None. dimension. Defaults to None.
rotation_axis (int): Default rotation axis for points rotation. rotation_axis (int): Default rotation axis for points rotation.
""" """
...@@ -27,42 +27,30 @@ class LiDARPoints(BasePoints): ...@@ -27,42 +27,30 @@ class LiDARPoints(BasePoints):
self.rotation_axis = 2 self.rotation_axis = 2
def flip(self, bev_direction='horizontal'): def flip(self, bev_direction='horizontal'):
"""Flip the boxes in BEV along given BEV direction.""" """Flip the points along given BEV direction.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
"""
if bev_direction == 'horizontal': if bev_direction == 'horizontal':
self.tensor[:, 1] = -self.tensor[:, 1] self.tensor[:, 1] = -self.tensor[:, 1]
elif bev_direction == 'vertical': elif bev_direction == 'vertical':
self.tensor[:, 0] = -self.tensor[:, 0] self.tensor[:, 0] = -self.tensor[:, 0]
def in_range_bev(self, point_range):
"""Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
in order of (x_min, y_min, x_max, y_max).
Returns:
torch.Tensor: Indicating whether each point is inside \
the reference range.
"""
in_range_flags = ((self.tensor[:, 0] > point_range[0])
& (self.tensor[:, 1] > point_range[1])
& (self.tensor[:, 0] < point_range[2])
& (self.tensor[:, 1] < point_range[3]))
return in_range_flags
def convert_to(self, dst, rt_mat=None): def convert_to(self, dst, rt_mat=None):
"""Convert self to ``dst`` mode. """Convert self to ``dst`` mode.
Args: Args:
dst (:obj:`CoordMode`): The target Point mode. dst (:obj:`CoordMode`): The target Point mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation rt_mat (np.ndarray | torch.Tensor, optional): The rotation and
matrix between different coordinates. Defaults to None. translation matrix between different coordinates.
Defaults to None.
The conversion from `src` coordinates to `dst` coordinates The conversion from `src` coordinates to `dst` coordinates
usually comes along the change of sensors, e.g., from camera usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix. to LiDAR. This requires a transformation matrix.
Returns: Returns:
:obj:`BasePoints`: The converted point of the same type \ :obj:`BasePoints`: The converted point of the same type
in the `dst` mode. in the `dst` mode.
""" """
from mmdet3d.core.bbox import Coord3DMode from mmdet3d.core.bbox import Coord3DMode
......
...@@ -15,13 +15,15 @@ def box3d_multiclass_nms(mlvl_bboxes, ...@@ -15,13 +15,15 @@ def box3d_multiclass_nms(mlvl_bboxes,
mlvl_dir_scores=None, mlvl_dir_scores=None,
mlvl_attr_scores=None, mlvl_attr_scores=None,
mlvl_bboxes2d=None): mlvl_bboxes2d=None):
"""Multi-class nms for 3D boxes. """Multi-class NMS for 3D boxes. The IoU used for NMS is defined as the 2D
IoU between BEV boxes.
Args: Args:
mlvl_bboxes (torch.Tensor): Multi-level boxes with shape (N, M). mlvl_bboxes (torch.Tensor): Multi-level boxes with shape (N, M).
M is the dimensions of boxes. M is the dimensions of boxes.
mlvl_bboxes_for_nms (torch.Tensor): Multi-level boxes with shape mlvl_bboxes_for_nms (torch.Tensor): Multi-level boxes with shape
(N, 5) ([x1, y1, x2, y2, ry]). N is the number of boxes. (N, 5) ([x1, y1, x2, y2, ry]). N is the number of boxes.
The coordinate system of the BEV boxes is counterclockwise.
mlvl_scores (torch.Tensor): Multi-level boxes with shape mlvl_scores (torch.Tensor): Multi-level boxes with shape
(N, C + 1). N is the number of boxes. C is the number of classes. (N, C + 1). N is the number of boxes. C is the number of classes.
score_thr (float): Score thredhold to filter boxes with low score_thr (float): Score thredhold to filter boxes with low
...@@ -36,8 +38,8 @@ def box3d_multiclass_nms(mlvl_bboxes, ...@@ -36,8 +38,8 @@ def box3d_multiclass_nms(mlvl_bboxes,
boxes. Defaults to None. boxes. Defaults to None.
Returns: Returns:
tuple[torch.Tensor]: Return results after nms, including 3D \ tuple[torch.Tensor]: Return results after nms, including 3D
bounding boxes, scores, labels, direction scores, attribute \ bounding boxes, scores, labels, direction scores, attribute
scores (optional) and 2D bounding boxes (optional). scores (optional) and 2D bounding boxes (optional).
""" """
# do multi class nms # do multi class nms
...@@ -128,13 +130,13 @@ def box3d_multiclass_nms(mlvl_bboxes, ...@@ -128,13 +130,13 @@ def box3d_multiclass_nms(mlvl_bboxes,
def aligned_3d_nms(boxes, scores, classes, thresh): def aligned_3d_nms(boxes, scores, classes, thresh):
"""3d nms for aligned boxes. """3D NMS for aligned boxes.
Args: Args:
boxes (torch.Tensor): Aligned box with shape [n, 6]. boxes (torch.Tensor): Aligned box with shape [n, 6].
scores (torch.Tensor): Scores of each box. scores (torch.Tensor): Scores of each box.
classes (torch.Tensor): Class of each box. classes (torch.Tensor): Class of each box.
thresh (float): Iou threshold for nms. thresh (float): IoU threshold for nms.
Returns: Returns:
torch.Tensor: Indices of selected boxes. torch.Tensor: Indices of selected boxes.
...@@ -188,8 +190,8 @@ def circle_nms(dets, thresh, post_max_size=83): ...@@ -188,8 +190,8 @@ def circle_nms(dets, thresh, post_max_size=83):
Args: Args:
dets (torch.Tensor): Detection results with the shape of [N, 3]. dets (torch.Tensor): Detection results with the shape of [N, 3].
thresh (float): Value of threshold. thresh (float): Value of threshold.
post_max_size (int): Max number of prediction to be kept. Defaults post_max_size (int, optional): Max number of prediction to be kept.
to 83 Defaults to 83.
Returns: Returns:
torch.Tensor: Indexes of the detections to be kept. torch.Tensor: Indexes of the detections to be kept.
......
...@@ -11,19 +11,20 @@ def array_converter(to_torch=True, ...@@ -11,19 +11,20 @@ def array_converter(to_torch=True,
"""Wrapper function for data-type agnostic processing. """Wrapper function for data-type agnostic processing.
First converts input arrays to PyTorch tensors or NumPy ndarrays First converts input arrays to PyTorch tensors or NumPy ndarrays
for middle calculation, then convert output to original data-type. for middle calculation, then convert output to original data-type if
`recover=True`.
Args: Args:
to_torch (Bool): Whether convert to PyTorch tensors to_torch (Bool, optional): Whether convert to PyTorch tensors
for middle calculation. Defaults to True. for middle calculation. Defaults to True.
apply_to (tuple[str]): The arguments to which we apply data-type apply_to (tuple[str], optional): The arguments to which we apply
conversion. Defaults to an empty tuple. data-type conversion. Defaults to an empty tuple.
template_arg_name_ (str): Argument serving as the template ( template_arg_name_ (str, optional): Argument serving as the template (
return arrays should have the same dtype and device return arrays should have the same dtype and device
as the template). Defaults to None. If None, we will use the as the template). Defaults to None. If None, we will use the
first argument in `apply_to` as the template argument. first argument in `apply_to` as the template argument.
recover (Bool): Whether or not recover the wrapped function outputs recover (Bool, optional): Whether or not recover the wrapped function
to the `template_arg_name_` type. Defaults to True. outputs to the `template_arg_name_` type. Defaults to True.
Raises: Raises:
ValueError: When template_arg_name_ is not among all args, or ValueError: When template_arg_name_ is not among all args, or
...@@ -254,9 +255,10 @@ class ArrayConverter: ...@@ -254,9 +255,10 @@ class ArrayConverter:
input_array (tuple | list | np.ndarray | input_array (tuple | list | np.ndarray |
torch.Tensor | int | float ): torch.Tensor | int | float ):
Input array. Defaults to None. Input array. Defaults to None.
target_type (<class 'np.ndarray'> | <class 'torch.Tensor'>): target_type (<class 'np.ndarray'> | <class 'torch.Tensor'>,
optional):
Type to which input array is converted. Defaults to None. Type to which input array is converted. Defaults to None.
target_array (np.ndarray | torch.Tensor): target_array (np.ndarray | torch.Tensor, optional):
Template array to which input array is converted. Template array to which input array is converted.
Defaults to None. Defaults to None.
......
...@@ -8,7 +8,7 @@ def gaussian_2d(shape, sigma=1): ...@@ -8,7 +8,7 @@ def gaussian_2d(shape, sigma=1):
Args: Args:
shape (list[int]): Shape of the map. shape (list[int]): Shape of the map.
sigma (float): Sigma to generate gaussian map. sigma (float, optional): Sigma to generate gaussian map.
Defaults to 1. Defaults to 1.
Returns: Returns:
...@@ -29,7 +29,7 @@ def draw_heatmap_gaussian(heatmap, center, radius, k=1): ...@@ -29,7 +29,7 @@ def draw_heatmap_gaussian(heatmap, center, radius, k=1):
heatmap (torch.Tensor): Heatmap to be masked. heatmap (torch.Tensor): Heatmap to be masked.
center (torch.Tensor): Center coord of the heatmap. center (torch.Tensor): Center coord of the heatmap.
radius (int): Radius of gausian. radius (int): Radius of gausian.
K (int): Multiple of masked_gaussian. Defaults to 1. K (int, optional): Multiple of masked_gaussian. Defaults to 1.
Returns: Returns:
torch.Tensor: Masked heatmap. torch.Tensor: Masked heatmap.
...@@ -59,7 +59,7 @@ def gaussian_radius(det_size, min_overlap=0.5): ...@@ -59,7 +59,7 @@ def gaussian_radius(det_size, min_overlap=0.5):
Args: Args:
det_size (tuple[torch.Tensor]): Size of the detection result. det_size (tuple[torch.Tensor]): Size of the detection result.
min_overlap (float): Gaussian_overlap. Defaults to 0.5. min_overlap (float, optional): Gaussian_overlap. Defaults to 0.5.
Returns: Returns:
torch.Tensor: Computed radius. torch.Tensor: Computed radius.
......
...@@ -18,7 +18,7 @@ def project_pts_on_img(points, ...@@ -18,7 +18,7 @@ def project_pts_on_img(points,
raw_img (numpy.array): The numpy array of image. raw_img (numpy.array): The numpy array of image.
lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix
according to the camera intrinsic parameters. according to the camera intrinsic parameters.
max_distance (float): the max distance of the points cloud. max_distance (float, optional): the max distance of the points cloud.
Default: 70. Default: 70.
thickness (int, optional): The thickness of 2D points. Default: -1. thickness (int, optional): The thickness of 2D points. Default: -1.
""" """
...@@ -69,7 +69,8 @@ def plot_rect3d_on_img(img, ...@@ -69,7 +69,8 @@ def plot_rect3d_on_img(img,
num_rects (int): Number of 3D rectangulars. num_rects (int): Number of 3D rectangulars.
rect_corners (numpy.array): Coordinates of the corners of 3D rect_corners (numpy.array): Coordinates of the corners of 3D
rectangulars. Should be in the shape of [num_rect, 8, 2]. rectangulars. Should be in the shape of [num_rect, 8, 2].
color (tuple[int]): The color to draw bboxes. Default: (0, 255, 0). color (tuple[int], optional): The color to draw bboxes.
Default: (0, 255, 0).
thickness (int, optional): The thickness of bboxes. Default: 1. thickness (int, optional): The thickness of bboxes. Default: 1.
""" """
line_indices = ((0, 1), (0, 3), (0, 4), (1, 2), (1, 5), (3, 2), (3, 7), line_indices = ((0, 1), (0, 3), (0, 4), (1, 2), (1, 5), (3, 2), (3, 7),
...@@ -99,7 +100,8 @@ def draw_lidar_bbox3d_on_img(bboxes3d, ...@@ -99,7 +100,8 @@ def draw_lidar_bbox3d_on_img(bboxes3d,
lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix
according to the camera intrinsic parameters. according to the camera intrinsic parameters.
img_metas (dict): Useless here. img_metas (dict): Useless here.
color (tuple[int]): The color to draw bboxes. Default: (0, 255, 0). color (tuple[int], optional): The color to draw bboxes.
Default: (0, 255, 0).
thickness (int, optional): The thickness of bboxes. Default: 1. thickness (int, optional): The thickness of bboxes. Default: 1.
""" """
img = raw_img.copy() img = raw_img.copy()
...@@ -136,7 +138,8 @@ def draw_depth_bbox3d_on_img(bboxes3d, ...@@ -136,7 +138,8 @@ def draw_depth_bbox3d_on_img(bboxes3d,
raw_img (numpy.array): The numpy array of image. raw_img (numpy.array): The numpy array of image.
calibs (dict): Camera calibration information, Rt and K. calibs (dict): Camera calibration information, Rt and K.
img_metas (dict): Used in coordinates transformation. img_metas (dict): Used in coordinates transformation.
color (tuple[int]): The color to draw bboxes. Default: (0, 255, 0). color (tuple[int], optional): The color to draw bboxes.
Default: (0, 255, 0).
thickness (int, optional): The thickness of bboxes. Default: 1. thickness (int, optional): The thickness of bboxes. Default: 1.
""" """
from mmdet3d.core.bbox import points_cam2img from mmdet3d.core.bbox import points_cam2img
...@@ -176,7 +179,8 @@ def draw_camera_bbox3d_on_img(bboxes3d, ...@@ -176,7 +179,8 @@ def draw_camera_bbox3d_on_img(bboxes3d,
cam2img (dict): Camera intrinsic matrix, cam2img (dict): Camera intrinsic matrix,
denoted as `K` in depth bbox coordinate system. denoted as `K` in depth bbox coordinate system.
img_metas (dict): Useless here. img_metas (dict): Useless here.
color (tuple[int]): The color to draw bboxes. Default: (0, 255, 0). color (tuple[int], optional): The color to draw bboxes.
Default: (0, 255, 0).
thickness (int, optional): The thickness of bboxes. Default: 1. thickness (int, optional): The thickness of bboxes. Default: 1.
""" """
from mmdet3d.core.bbox import points_cam2img from mmdet3d.core.bbox import points_cam2img
......
...@@ -22,12 +22,12 @@ def _draw_points(points, ...@@ -22,12 +22,12 @@ def _draw_points(points,
points (numpy.array | torch.tensor, shape=[N, 3+C]): points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize. points to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer. vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
points_size (int): the size of points to show on visualizer. points_size (int, optional): the size of points to show on visualizer.
Default: 2. Default: 2.
point_color (tuple[float]): the color of points. point_color (tuple[float], optional): the color of points.
Default: (0.5, 0.5, 0.5). Default: (0.5, 0.5, 0.5).
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points,
['xyz', 'xyzrgb']. Default: 'xyz'. available mode ['xyz', 'xyzrgb']. Default: 'xyz'.
Returns: Returns:
tuple: points, color of each point. tuple: points, color of each point.
...@@ -69,19 +69,21 @@ def _draw_bboxes(bbox3d, ...@@ -69,19 +69,21 @@ def _draw_bboxes(bbox3d,
Args: Args:
bbox3d (numpy.array | torch.tensor, shape=[M, 7]): bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize. 3d bbox (x, y, z, x_size, y_size, z_size, yaw) to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer. vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
points_colors (numpy.array): color of each points. points_colors (numpy.array): color of each points.
pcd (:obj:`open3d.geometry.PointCloud`): point cloud. Default: None. pcd (:obj:`open3d.geometry.PointCloud`, optional): point cloud.
bbox_color (tuple[float]): the color of bbox. Default: (0, 1, 0). Default: None.
points_in_box_color (tuple[float]): bbox_color (tuple[float], optional): the color of bbox.
Default: (0, 1, 0).
points_in_box_color (tuple[float], optional):
the color of points inside bbox3d. Default: (1, 0, 0). the color of points inside bbox3d. Default: (1, 0, 0).
rot_axis (int): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool): indicate the center of bbox is bottom center center_mode (bool, optional): indicate the center of bbox is
or gravity center. avaliable mode bottom center or gravity center. avaliable mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points,
['xyz', 'xyzrgb']. Default: 'xyz'. avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
if isinstance(bbox3d, torch.Tensor): if isinstance(bbox3d, torch.Tensor):
bbox3d = bbox3d.cpu().numpy() bbox3d = bbox3d.cpu().numpy()
...@@ -135,23 +137,27 @@ def show_pts_boxes(points, ...@@ -135,23 +137,27 @@ def show_pts_boxes(points,
Args: Args:
points (numpy.array | torch.tensor, shape=[N, 3+C]): points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize. points to visualize.
bbox3d (numpy.array | torch.tensor, shape=[M, 7]): bbox3d (numpy.array | torch.tensor, shape=[M, 7], optional):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize. Default: None. 3D bbox (x, y, z, x_size, y_size, z_size, yaw) to visualize.
show (bool): whether to show the visualization results. Default: True. Defaults to None.
save_path (str): path to save visualized results. Default: None. show (bool, optional): whether to show the visualization results.
points_size (int): the size of points to show on visualizer. Default: True.
save_path (str, optional): path to save visualized results.
Default: None.
points_size (int, optional): the size of points to show on visualizer.
Default: 2. Default: 2.
point_color (tuple[float]): the color of points. point_color (tuple[float], optional): the color of points.
Default: (0.5, 0.5, 0.5). Default: (0.5, 0.5, 0.5).
bbox_color (tuple[float]): the color of bbox. Default: (0, 1, 0). bbox_color (tuple[float], optional): the color of bbox.
points_in_box_color (tuple[float]): Default: (0, 1, 0).
points_in_box_color (tuple[float], optional):
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool): indicate the center of bbox is bottom center center_mode (bool, optional): indicate the center of bbox is bottom
or gravity center. avaliable mode center or gravity center. avaliable mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points, avaliable
['xyz', 'xyzrgb']. Default: 'xyz'. mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
# TODO: support score and class info # TODO: support score and class info
assert 0 <= rot_axis <= 2 assert 0 <= rot_axis <= 2
...@@ -196,21 +202,23 @@ def _draw_bboxes_ind(bbox3d, ...@@ -196,21 +202,23 @@ def _draw_bboxes_ind(bbox3d,
Args: Args:
bbox3d (numpy.array | torch.tensor, shape=[M, 7]): bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize. 3d bbox (x, y, z, x_size, y_size, z_size, yaw) to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer. vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
indices (numpy.array | torch.tensor, shape=[N, M]): indices (numpy.array | torch.tensor, shape=[N, M]):
indicate which bbox3d that each point lies in. indicate which bbox3d that each point lies in.
points_colors (numpy.array): color of each points. points_colors (numpy.array): color of each points.
pcd (:obj:`open3d.geometry.PointCloud`): point cloud. Default: None. pcd (:obj:`open3d.geometry.PointCloud`, optional): point cloud.
bbox_color (tuple[float]): the color of bbox. Default: (0, 1, 0). Default: None.
points_in_box_color (tuple[float]): bbox_color (tuple[float], optional): the color of bbox.
Default: (0, 1, 0).
points_in_box_color (tuple[float], optional):
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool): indicate the center of bbox is bottom center center_mode (bool, optional): indicate the center of bbox is
or gravity center. avaliable mode bottom center or gravity center. avaliable mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points,
['xyz', 'xyzrgb']. Default: 'xyz'. avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
if isinstance(bbox3d, torch.Tensor): if isinstance(bbox3d, torch.Tensor):
bbox3d = bbox3d.cpu().numpy() bbox3d = bbox3d.cpu().numpy()
...@@ -270,24 +278,28 @@ def show_pts_index_boxes(points, ...@@ -270,24 +278,28 @@ def show_pts_index_boxes(points,
points (numpy.array | torch.tensor, shape=[N, 3+C]): points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize. points to visualize.
bbox3d (numpy.array | torch.tensor, shape=[M, 7]): bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize. Default: None. 3D bbox (x, y, z, x_size, y_size, z_size, yaw) to visualize.
show (bool): whether to show the visualization results. Default: True. Defaults to None.
indices (numpy.array | torch.tensor, shape=[N, M]): show (bool, optional): whether to show the visualization results.
Default: True.
indices (numpy.array | torch.tensor, shape=[N, M], optional):
indicate which bbox3d that each point lies in. Default: None. indicate which bbox3d that each point lies in. Default: None.
save_path (str): path to save visualized results. Default: None. save_path (str, optional): path to save visualized results.
points_size (int): the size of points to show on visualizer. Default: None.
points_size (int, optional): the size of points to show on visualizer.
Default: 2. Default: 2.
point_color (tuple[float]): the color of points. point_color (tuple[float], optional): the color of points.
Default: (0.5, 0.5, 0.5). Default: (0.5, 0.5, 0.5).
bbox_color (tuple[float]): the color of bbox. Default: (0, 1, 0). bbox_color (tuple[float], optional): the color of bbox.
points_in_box_color (tuple[float]): Default: (0, 1, 0).
points_in_box_color (tuple[float], optional):
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool): indicate the center of bbox is bottom center center_mode (bool, optional): indicate the center of bbox is
or gravity center. avaliable mode bottom center or gravity center. avaliable mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points,
['xyz', 'xyzrgb']. Default: 'xyz'. avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
# TODO: support score and class info # TODO: support score and class info
assert 0 <= rot_axis <= 2 assert 0 <= rot_axis <= 2
...@@ -324,24 +336,27 @@ class Visualizer(object): ...@@ -324,24 +336,27 @@ class Visualizer(object):
points (numpy.array, shape=[N, 3+C]): Points to visualize. The Points points (numpy.array, shape=[N, 3+C]): Points to visualize. The Points
cloud is in mode of Coord3DMode.DEPTH (please refer to cloud is in mode of Coord3DMode.DEPTH (please refer to
core.structures.coord_3d_mode). core.structures.coord_3d_mode).
bbox3d (numpy.array, shape=[M, 7]): 3d bbox (x, y, z, dx, dy, dz, yaw) bbox3d (numpy.array, shape=[M, 7], optional): 3D bbox
to visualize. The 3d bbox is in mode of Box3DMode.DEPTH with (x, y, z, x_size, y_size, z_size, yaw) to visualize.
The 3D bbox is in mode of Box3DMode.DEPTH with
gravity_center (please refer to core.structures.box_3d_mode). gravity_center (please refer to core.structures.box_3d_mode).
Default: None. Default: None.
save_path (str): path to save visualized results. Default: None. save_path (str, optional): path to save visualized results.
points_size (int): the size of points to show on visualizer. Default: None.
points_size (int, optional): the size of points to show on visualizer.
Default: 2. Default: 2.
point_color (tuple[float]): the color of points. point_color (tuple[float], optional): the color of points.
Default: (0.5, 0.5, 0.5). Default: (0.5, 0.5, 0.5).
bbox_color (tuple[float]): the color of bbox. Default: (0, 1, 0). bbox_color (tuple[float], optional): the color of bbox.
points_in_box_color (tuple[float]): Default: (0, 1, 0).
points_in_box_color (tuple[float], optional):
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool): indicate the center of bbox is bottom center center_mode (bool, optional): indicate the center of bbox is
or gravity center. avaliable mode bottom center or gravity center. avaliable mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str): indicate type of the input points, avaliable mode mode (str, optional): indicate type of the input points,
['xyz', 'xyzrgb']. Default: 'xyz'. avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
def __init__(self, def __init__(self,
...@@ -390,9 +405,10 @@ class Visualizer(object): ...@@ -390,9 +405,10 @@ class Visualizer(object):
Args: Args:
bbox3d (numpy.array, shape=[M, 7]): bbox3d (numpy.array, shape=[M, 7]):
3D bbox (x, y, z, dx, dy, dz, yaw) to be visualized. 3D bbox (x, y, z, x_size, y_size, z_size, yaw)
The 3d bbox is in mode of Box3DMode.DEPTH with to be visualized. The 3d bbox is in mode of
gravity_center (please refer to core.structures.box_3d_mode). Box3DMode.DEPTH with gravity_center (please refer to
core.structures.box_3d_mode).
bbox_color (tuple[float]): the color of bbox. Defaule: None. bbox_color (tuple[float]): the color of bbox. Defaule: None.
points_in_box_color (tuple[float]): the color of points which points_in_box_color (tuple[float]): the color of points which
are in bbox3d. Defaule: None. are in bbox3d. Defaule: None.
...@@ -431,7 +447,7 @@ class Visualizer(object): ...@@ -431,7 +447,7 @@ class Visualizer(object):
"""Visualize the points cloud. """Visualize the points cloud.
Args: Args:
save_path (str): path to save image. Default: None. save_path (str, optional): path to save image. Default: None.
""" """
self.o3d_visualizer.run() self.o3d_visualizer.run()
......
...@@ -35,7 +35,7 @@ def _write_oriented_bbox(scene_bbox, out_filename): ...@@ -35,7 +35,7 @@ def _write_oriented_bbox(scene_bbox, out_filename):
Args: Args:
scene_bbox(list[ndarray] or ndarray): xyz pos of center and scene_bbox(list[ndarray] or ndarray): xyz pos of center and
3 lengths (dx,dy,dz) and heading angle around Z axis. 3 lengths (x_size, y_size, z_size) and heading angle around Z axis.
Y forward, X right, Z upward. heading angle of positive X is 0, Y forward, X right, Z upward. heading angle of positive X is 0,
heading angle of positive Y is 90 degrees. heading angle of positive Y is 90 degrees.
out_filename(str): Filename. out_filename(str): Filename.
...@@ -87,8 +87,10 @@ def show_result(points, ...@@ -87,8 +87,10 @@ def show_result(points,
pred_bboxes (np.ndarray): Predicted boxes. pred_bboxes (np.ndarray): Predicted boxes.
out_dir (str): Path of output directory out_dir (str): Path of output directory
filename (str): Filename of the current frame. filename (str): Filename of the current frame.
show (bool): Visualize the results online. Defaults to False. show (bool, optional): Visualize the results online.
snapshot (bool): Whether to save the online results. Defaults to False. Defaults to False.
snapshot (bool, optional): Whether to save the online results.
Defaults to False.
""" """
result_path = osp.join(out_dir, filename) result_path = osp.join(out_dir, filename)
mmcv.mkdir_or_exist(result_path) mmcv.mkdir_or_exist(result_path)
...@@ -141,10 +143,10 @@ def show_seg_result(points, ...@@ -141,10 +143,10 @@ def show_seg_result(points,
out_dir (str): Path of output directory out_dir (str): Path of output directory
filename (str): Filename of the current frame. filename (str): Filename of the current frame.
palette (np.ndarray): Mapping between class labels and colors. palette (np.ndarray): Mapping between class labels and colors.
ignore_index (int, optional): The label index to be ignored, e.g. \ ignore_index (int, optional): The label index to be ignored, e.g.
unannotated points. Defaults to None. unannotated points. Defaults to None.
show (bool, optional): Visualize the results online. Defaults to False. show (bool, optional): Visualize the results online. Defaults to False.
snapshot (bool, optional): Whether to save the online results. \ snapshot (bool, optional): Whether to save the online results.
Defaults to False. Defaults to False.
""" """
# we need 3D coordinates to visualize segmentation mask # we need 3D coordinates to visualize segmentation mask
...@@ -219,14 +221,16 @@ def show_multi_modality_result(img, ...@@ -219,14 +221,16 @@ def show_multi_modality_result(img,
according to the camera intrinsic parameters. according to the camera intrinsic parameters.
out_dir (str): Path of output directory. out_dir (str): Path of output directory.
filename (str): Filename of the current frame. filename (str): Filename of the current frame.
box_mode (str): Coordinate system the boxes are in. Should be one of box_mode (str, optional): Coordinate system the boxes are in.
'depth', 'lidar' and 'camera'. Defaults to 'lidar'. Should be one of 'depth', 'lidar' and 'camera'.
img_metas (dict): Used in projecting depth bbox. Defaults to 'lidar'.
show (bool): Visualize the results online. Defaults to False. img_metas (dict, optional): Used in projecting depth bbox.
gt_bbox_color (str or tuple(int)): Color of bbox lines. Defaults to None.
The tuple of color should be in BGR order. Default: (255, 102, 61) show (bool, optional): Visualize the results online. Defaults to False.
pred_bbox_color (str or tuple(int)): Color of bbox lines. gt_bbox_color (str or tuple(int), optional): Color of bbox lines.
The tuple of color should be in BGR order. Default: (72, 101, 241) The tuple of color should be in BGR order. Default: (255, 102, 61).
pred_bbox_color (str or tuple(int), optional): Color of bbox lines.
The tuple of color should be in BGR order. Default: (72, 101, 241).
""" """
if box_mode == 'depth': if box_mode == 'depth':
draw_bbox = draw_depth_bbox3d_on_img draw_bbox = draw_depth_bbox3d_on_img
......
...@@ -82,18 +82,18 @@ def points_to_voxel(points, ...@@ -82,18 +82,18 @@ def points_to_voxel(points,
"""convert kitti points(N, >=3) to voxels. """convert kitti points(N, >=3) to voxels.
Args: Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and \ points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points[:, 3:] contain other information such as reflectivity. points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
coors_range (list[float | tuple[float] | ndarray]): Voxel range. \ coors_range (list[float | tuple[float] | ndarray]): Voxel range.
format: xyzxyz, minmax format: xyzxyz, minmax
max_points (int): Indicate maximum points contained in a voxel. max_points (int): Indicate maximum points contained in a voxel.
reverse_index (bool): Whether return reversed coordinates. \ reverse_index (bool): Whether return reversed coordinates.
if points has xyz format and reverse_index is True, output \ if points has xyz format and reverse_index is True, output
coordinates will be zyx format, but points in features always \ coordinates will be zyx format, but points in features always
xyz format. xyz format.
max_voxels (int): Maximum number of voxels this function creates. \ max_voxels (int): Maximum number of voxels this function creates.
For second, 20000 is a good choice. Points should be shuffled for \ For second, 20000 is a good choice. Points should be shuffled for
randomness before this function because max_voxels drops points. randomness before this function because max_voxels drops points.
Returns: Returns:
...@@ -147,20 +147,20 @@ def _points_to_voxel_reverse_kernel(points, ...@@ -147,20 +147,20 @@ def _points_to_voxel_reverse_kernel(points,
"""convert kitti points(N, >=3) to voxels. """convert kitti points(N, >=3) to voxels.
Args: Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and \ points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points[:, 3:] contain other information such as reflectivity. points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size \ voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
coors_range (list[float | tuple[float] | ndarray]): Range of voxels. \ coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
format: xyzxyz, minmax format: xyzxyz, minmax
num_points_per_voxel (int): Number of points per voxel. num_points_per_voxel (int): Number of points per voxel.
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W), \ coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
which has the same shape as the complete voxel map. It indicates \ which has the same shape as the complete voxel map. It indicates
the index of each corresponding voxel. the index of each corresponding voxel.
voxels (np.ndarray): Created empty voxels. voxels (np.ndarray): Created empty voxels.
coors (np.ndarray): Created coordinates of each voxel. coors (np.ndarray): Created coordinates of each voxel.
max_points (int): Indicate maximum points contained in a voxel. max_points (int): Indicate maximum points contained in a voxel.
max_voxels (int): Maximum number of voxels this function create. \ max_voxels (int): Maximum number of voxels this function create.
for second, 20000 is a good choice. Points should be shuffled for \ for second, 20000 is a good choice. Points should be shuffled for
randomness before this function because max_voxels drops points. randomness before this function because max_voxels drops points.
Returns: Returns:
...@@ -221,20 +221,20 @@ def _points_to_voxel_kernel(points, ...@@ -221,20 +221,20 @@ def _points_to_voxel_kernel(points,
"""convert kitti points(N, >=3) to voxels. """convert kitti points(N, >=3) to voxels.
Args: Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and \ points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points[:, 3:] contain other information such as reflectivity. points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size. voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size.
coors_range (list[float | tuple[float] | ndarray]): Range of voxels. \ coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
format: xyzxyz, minmax format: xyzxyz, minmax
num_points_per_voxel (int): Number of points per voxel. num_points_per_voxel (int): Number of points per voxel.
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W), \ coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
which has the same shape as the complete voxel map. It indicates \ which has the same shape as the complete voxel map. It indicates
the index of each corresponding voxel. the index of each corresponding voxel.
voxels (np.ndarray): Created empty voxels. voxels (np.ndarray): Created empty voxels.
coors (np.ndarray): Created coordinates of each voxel. coors (np.ndarray): Created coordinates of each voxel.
max_points (int): Indicate maximum points contained in a voxel. max_points (int): Indicate maximum points contained in a voxel.
max_voxels (int): Maximum number of voxels this function create. \ max_voxels (int): Maximum number of voxels this function create.
for second, 20000 is a good choice. Points should be shuffled for \ for second, 20000 is a good choice. Points should be shuffled for
randomness before this function because max_voxels drops points. randomness before this function because max_voxels drops points.
Returns: Returns:
......
...@@ -88,7 +88,7 @@ class Custom3DDataset(Dataset): ...@@ -88,7 +88,7 @@ class Custom3DDataset(Dataset):
index (int): Index of the sample data to get. index (int): Index of the sample data to get.
Returns: Returns:
dict: Data information that will be passed to the data \ dict: Data information that will be passed to the data
preprocessing pipelines. It includes the following keys: preprocessing pipelines. It includes the following keys:
- sample_idx (str): Sample index. - sample_idx (str): Sample index.
...@@ -177,7 +177,7 @@ class Custom3DDataset(Dataset): ...@@ -177,7 +177,7 @@ class Custom3DDataset(Dataset):
"""Get class names of current dataset. """Get class names of current dataset.
Args: Args:
classes (Sequence[str] | str | None): If classes is None, use classes (Sequence[str] | str): If classes is None, use
default CLASSES defined by builtin dataset. If classes is a default CLASSES defined by builtin dataset. If classes is a
string, take it as a file name. The file contains the name of string, take it as a file name. The file contains the name of
classes where each line contains one class name. If classes is classes where each line contains one class name. If classes is
...@@ -207,13 +207,13 @@ class Custom3DDataset(Dataset): ...@@ -207,13 +207,13 @@ class Custom3DDataset(Dataset):
Args: Args:
outputs (list[dict]): Testing results of the dataset. outputs (list[dict]): Testing results of the dataset.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str): The prefix of pkl files. It includes
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
Returns: Returns:
tuple: (outputs, tmp_dir), outputs is the detection results, \ tuple: (outputs, tmp_dir), outputs is the detection results,
tmp_dir is the temporal directory created for saving json \ tmp_dir is the temporal directory created for saving json
files when ``jsonfile_prefix`` is not specified. files when ``jsonfile_prefix`` is not specified.
""" """
if pklfile_prefix is None: if pklfile_prefix is None:
...@@ -237,11 +237,14 @@ class Custom3DDataset(Dataset): ...@@ -237,11 +237,14 @@ class Custom3DDataset(Dataset):
Args: Args:
results (list[dict]): List of results. results (list[dict]): List of results.
metric (str | list[str]): Metrics to be evaluated. metric (str | list[str], optional): Metrics to be evaluated.
iou_thr (list[float]): AP IoU thresholds. Defaults to None.
show (bool): Whether to visualize. iou_thr (list[float]): AP IoU thresholds. Defaults to (0.25, 0.5).
logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Defaults to None.
show (bool, optional): Whether to visualize.
Default: False. Default: False.
out_dir (str): Path to save the visualization results. out_dir (str, optional): Path to save the visualization results.
Default: None. Default: None.
pipeline (list[dict], optional): raw data loading for showing. pipeline (list[dict], optional): raw data loading for showing.
Default: None. Default: None.
...@@ -281,7 +284,7 @@ class Custom3DDataset(Dataset): ...@@ -281,7 +284,7 @@ class Custom3DDataset(Dataset):
"""Get data loading pipeline in self.show/evaluate function. """Get data loading pipeline in self.show/evaluate function.
Args: Args:
pipeline (list[dict] | None): Input pipeline. If None is given, \ pipeline (list[dict]): Input pipeline. If None is given,
get from self.pipeline. get from self.pipeline.
""" """
if pipeline is None: if pipeline is None:
......
...@@ -32,7 +32,7 @@ class Custom3DSegDataset(Dataset): ...@@ -32,7 +32,7 @@ class Custom3DSegDataset(Dataset):
as input. Defaults to None. as input. Defaults to None.
test_mode (bool, optional): Whether the dataset is in test mode. test_mode (bool, optional): Whether the dataset is in test mode.
Defaults to False. Defaults to False.
ignore_index (int, optional): The label index to be ignored, e.g. \ ignore_index (int, optional): The label index to be ignored, e.g.
unannotated points. If None is given, set to len(self.CLASSES) to unannotated points. If None is given, set to len(self.CLASSES) to
be consistent with PointSegClassMapping function in pipeline. be consistent with PointSegClassMapping function in pipeline.
Defaults to None. Defaults to None.
...@@ -102,7 +102,7 @@ class Custom3DSegDataset(Dataset): ...@@ -102,7 +102,7 @@ class Custom3DSegDataset(Dataset):
index (int): Index of the sample data to get. index (int): Index of the sample data to get.
Returns: Returns:
dict: Data information that will be passed to the data \ dict: Data information that will be passed to the data
preprocessing pipelines. It includes the following keys: preprocessing pipelines. It includes the following keys:
- sample_idx (str): Sample index. - sample_idx (str): Sample index.
...@@ -179,13 +179,13 @@ class Custom3DSegDataset(Dataset): ...@@ -179,13 +179,13 @@ class Custom3DSegDataset(Dataset):
This function is taken from MMSegmentation. This function is taken from MMSegmentation.
Args: Args:
classes (Sequence[str] | str | None): If classes is None, use classes (Sequence[str] | str): If classes is None, use
default CLASSES defined by builtin dataset. If classes is a default CLASSES defined by builtin dataset. If classes is a
string, take it as a file name. The file contains the name of string, take it as a file name. The file contains the name of
classes where each line contains one class name. If classes is classes where each line contains one class name. If classes is
a tuple or list, override the CLASSES defined by the dataset. a tuple or list, override the CLASSES defined by the dataset.
Defaults to None. Defaults to None.
palette (Sequence[Sequence[int]]] | np.ndarray | None): palette (Sequence[Sequence[int]]] | np.ndarray):
The palette of segmentation map. If None is given, random The palette of segmentation map. If None is given, random
palette will be generated. Defaults to None. palette will be generated. Defaults to None.
""" """
...@@ -276,13 +276,13 @@ class Custom3DSegDataset(Dataset): ...@@ -276,13 +276,13 @@ class Custom3DSegDataset(Dataset):
Args: Args:
outputs (list[dict]): Testing results of the dataset. outputs (list[dict]): Testing results of the dataset.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str): The prefix of pkl files. It includes
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
Returns: Returns:
tuple: (outputs, tmp_dir), outputs is the detection results, \ tuple: (outputs, tmp_dir), outputs is the detection results,
tmp_dir is the temporal directory created for saving json \ tmp_dir is the temporal directory created for saving json
files when ``jsonfile_prefix`` is not specified. files when ``jsonfile_prefix`` is not specified.
""" """
if pklfile_prefix is None: if pklfile_prefix is None:
...@@ -306,7 +306,7 @@ class Custom3DSegDataset(Dataset): ...@@ -306,7 +306,7 @@ class Custom3DSegDataset(Dataset):
Args: Args:
results (list[dict]): List of results. results (list[dict]): List of results.
metric (str | list[str]): Metrics to be evaluated. metric (str | list[str]): Metrics to be evaluated.
logger (logging.Logger | None | str): Logger used for printing logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Defaults to None. related information during evaluation. Defaults to None.
show (bool, optional): Whether to visualize. show (bool, optional): Whether to visualize.
Defaults to False. Defaults to False.
...@@ -364,7 +364,7 @@ class Custom3DSegDataset(Dataset): ...@@ -364,7 +364,7 @@ class Custom3DSegDataset(Dataset):
"""Get data loading pipeline in self.show/evaluate function. """Get data loading pipeline in self.show/evaluate function.
Args: Args:
pipeline (list[dict] | None): Input pipeline. If None is given, \ pipeline (list[dict]): Input pipeline. If None is given,
get from self.pipeline. get from self.pipeline.
""" """
if pipeline is None: if pipeline is None:
......
...@@ -206,7 +206,8 @@ class Kitti2DDataset(CustomDataset): ...@@ -206,7 +206,8 @@ class Kitti2DDataset(CustomDataset):
Args: Args:
outputs (list[np.ndarray]): List of arrays storing the inferenced outputs (list[np.ndarray]): List of arrays storing the inferenced
bounding boxes and scores. bounding boxes and scores.
out (str | None): The prefix of output file. Default: None. out (str, optional): The prefix of output file.
Default: None.
Returns: Returns:
list[dict]: A list of dictionaries with the kitti 2D format. list[dict]: A list of dictionaries with the kitti 2D format.
...@@ -222,7 +223,7 @@ class Kitti2DDataset(CustomDataset): ...@@ -222,7 +223,7 @@ class Kitti2DDataset(CustomDataset):
Args: Args:
result_files (str): Path of result files. result_files (str): Path of result files.
eval_types (str): Types of evaluation. Default: None. eval_types (str, optional): Types of evaluation. Default: None.
KITTI dataset only support 'bbox' evaluation type. KITTI dataset only support 'bbox' evaluation type.
Returns: Returns:
......
...@@ -47,8 +47,9 @@ class KittiDataset(Custom3DDataset): ...@@ -47,8 +47,9 @@ class KittiDataset(Custom3DDataset):
Defaults to True. Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode. test_mode (bool, optional): Whether the dataset is in test mode.
Defaults to False. Defaults to False.
pcd_limit_range (list): The range of point cloud used to filter pcd_limit_range (list, optional): The range of point cloud used to
invalid predicted boxes. Default: [0, -40, -3, 70.4, 40, 0.0]. filter invalid predicted boxes.
Default: [0, -40, -3, 70.4, 40, 0.0].
""" """
CLASSES = ('car', 'pedestrian', 'cyclist') CLASSES = ('car', 'pedestrian', 'cyclist')
...@@ -100,14 +101,14 @@ class KittiDataset(Custom3DDataset): ...@@ -100,14 +101,14 @@ class KittiDataset(Custom3DDataset):
index (int): Index of the sample data to get. index (int): Index of the sample data to get.
Returns: Returns:
dict: Data information that will be passed to the data \ dict: Data information that will be passed to the data
preprocessing pipelines. It includes the following keys: preprocessing pipelines. It includes the following keys:
- sample_idx (str): Sample index. - sample_idx (str): Sample index.
- pts_filename (str): Filename of point clouds. - pts_filename (str): Filename of point clouds.
- img_prefix (str | None): Prefix of image files. - img_prefix (str): Prefix of image files.
- img_info (dict): Image info. - img_info (dict): Image info.
- lidar2img (list[np.ndarray], optional): Transformations \ - lidar2img (list[np.ndarray], optional): Transformations
from lidar to different cameras. from lidar to different cameras.
- ann_info (dict): Annotation info. - ann_info (dict): Annotation info.
""" """
...@@ -145,7 +146,7 @@ class KittiDataset(Custom3DDataset): ...@@ -145,7 +146,7 @@ class KittiDataset(Custom3DDataset):
Returns: Returns:
dict: annotation information consists of the following keys: dict: annotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`): \ - gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
3D ground truth bboxes. 3D ground truth bboxes.
- gt_labels_3d (np.ndarray): Labels of ground truths. - gt_labels_3d (np.ndarray): Labels of ground truths.
- gt_bboxes (np.ndarray): 2D ground truth bboxes. - gt_bboxes (np.ndarray): 2D ground truth bboxes.
...@@ -248,17 +249,17 @@ class KittiDataset(Custom3DDataset): ...@@ -248,17 +249,17 @@ class KittiDataset(Custom3DDataset):
Args: Args:
outputs (list[dict]): Testing results of the dataset. outputs (list[dict]): Testing results of the dataset.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str): The prefix of pkl files. It includes
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str | None): The prefix of submitted files. It submission_prefix (str): The prefix of submitted files. It
includes the file path and the prefix of filename, e.g., includes the file path and the prefix of filename, e.g.,
"a/b/prefix". If not specified, a temp file will be created. "a/b/prefix". If not specified, a temp file will be created.
Default: None. Default: None.
Returns: Returns:
tuple: (result_files, tmp_dir), result_files is a dict containing \ tuple: (result_files, tmp_dir), result_files is a dict containing
the json filepaths, tmp_dir is the temporal directory created \ the json filepaths, tmp_dir is the temporal directory created
for saving json files when jsonfile_prefix is not specified. for saving json files when jsonfile_prefix is not specified.
""" """
if pklfile_prefix is None: if pklfile_prefix is None:
...@@ -308,17 +309,18 @@ class KittiDataset(Custom3DDataset): ...@@ -308,17 +309,18 @@ class KittiDataset(Custom3DDataset):
Args: Args:
results (list[dict]): Testing results of the dataset. results (list[dict]): Testing results of the dataset.
metric (str | list[str]): Metrics to be evaluated. metric (str | list[str], optional): Metrics to be evaluated.
logger (logging.Logger | str | None): Logger used for printing Default: None.
logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Default: None. related information during evaluation. Default: None.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str, optional): The prefix of pkl files, including
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str | None): The prefix of submission datas. submission_prefix (str, optional): The prefix of submission datas.
If not specified, the submission data will not be generated. If not specified, the submission data will not be generated.
show (bool): Whether to visualize. show (bool, optional): Whether to visualize.
Default: False. Default: False.
out_dir (str): Path to save the visualization results. out_dir (str, optional): Path to save the visualization results.
Default: None. Default: None.
pipeline (list[dict], optional): raw data loading for showing. pipeline (list[dict], optional): raw data loading for showing.
Default: None. Default: None.
...@@ -371,11 +373,11 @@ class KittiDataset(Custom3DDataset): ...@@ -371,11 +373,11 @@ class KittiDataset(Custom3DDataset):
submission. submission.
Args: Args:
net_outputs (list[np.ndarray]): List of array storing the \ net_outputs (list[np.ndarray]): List of array storing the
inferenced bounding boxes and scores. inferenced bounding boxes and scores.
class_names (list[String]): A list of class names. class_names (list[String]): A list of class names.
pklfile_prefix (str | None): The prefix of pkl file. pklfile_prefix (str): The prefix of pkl file.
submission_prefix (str | None): The prefix of submission file. submission_prefix (str): The prefix of submission file.
Returns: Returns:
list[dict]: A list of dictionaries with the kitti format. list[dict]: A list of dictionaries with the kitti format.
...@@ -486,11 +488,11 @@ class KittiDataset(Custom3DDataset): ...@@ -486,11 +488,11 @@ class KittiDataset(Custom3DDataset):
submission. submission.
Args: Args:
net_outputs (list[np.ndarray]): List of array storing the \ net_outputs (list[np.ndarray]): List of array storing the
inferenced bounding boxes and scores. inferenced bounding boxes and scores.
class_names (list[String]): A list of class names. class_names (list[String]): A list of class names.
pklfile_prefix (str | None): The prefix of pkl file. pklfile_prefix (str): The prefix of pkl file.
submission_prefix (str | None): The prefix of submission file. submission_prefix (str): The prefix of submission file.
Returns: Returns:
list[dict]: A list of dictionaries have the kitti format list[dict]: A list of dictionaries have the kitti format
...@@ -604,9 +606,9 @@ class KittiDataset(Custom3DDataset): ...@@ -604,9 +606,9 @@ class KittiDataset(Custom3DDataset):
dict: Valid predicted boxes. dict: Valid predicted boxes.
- bbox (np.ndarray): 2D bounding boxes. - bbox (np.ndarray): 2D bounding boxes.
- box3d_camera (np.ndarray): 3D bounding boxes in \ - box3d_camera (np.ndarray): 3D bounding boxes in
camera coordinate. camera coordinate.
- box3d_lidar (np.ndarray): 3D bounding boxes in \ - box3d_lidar (np.ndarray): 3D bounding boxes in
LiDAR coordinate. LiDAR coordinate.
- scores (np.ndarray): Scores of boxes. - scores (np.ndarray): Scores of boxes.
- label_preds (np.ndarray): Class label predictions. - label_preds (np.ndarray): Class label predictions.
......
...@@ -57,8 +57,8 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -57,8 +57,8 @@ class KittiMonoDataset(NuScenesMonoDataset):
with_mask (bool): Whether to parse mask annotations. with_mask (bool): Whether to parse mask annotations.
Returns: Returns:
dict: A dict containing the following keys: bboxes, bboxes_ignore,\ dict: A dict containing the following keys: bboxes, bboxes_ignore,
labels, masks, seg_map. "masks" are raw annotations and not \ labels, masks, seg_map. "masks" are raw annotations and not
decoded into binary masks. decoded into binary masks.
""" """
gt_bboxes = [] gt_bboxes = []
...@@ -147,17 +147,17 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -147,17 +147,17 @@ class KittiMonoDataset(NuScenesMonoDataset):
Args: Args:
outputs (list[dict]): Testing results of the dataset. outputs (list[dict]): Testing results of the dataset.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str): The prefix of pkl files. It includes
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str | None): The prefix of submitted files. It submission_prefix (str): The prefix of submitted files. It
includes the file path and the prefix of filename, e.g., includes the file path and the prefix of filename, e.g.,
"a/b/prefix". If not specified, a temp file will be created. "a/b/prefix". If not specified, a temp file will be created.
Default: None. Default: None.
Returns: Returns:
tuple: (result_files, tmp_dir), result_files is a dict containing \ tuple: (result_files, tmp_dir), result_files is a dict containing
the json filepaths, tmp_dir is the temporal directory created \ the json filepaths, tmp_dir is the temporal directory created
for saving json files when jsonfile_prefix is not specified. for saving json files when jsonfile_prefix is not specified.
""" """
if pklfile_prefix is None: if pklfile_prefix is None:
...@@ -207,17 +207,18 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -207,17 +207,18 @@ class KittiMonoDataset(NuScenesMonoDataset):
Args: Args:
results (list[dict]): Testing results of the dataset. results (list[dict]): Testing results of the dataset.
metric (str | list[str]): Metrics to be evaluated. metric (str | list[str], optional): Metrics to be evaluated.
logger (logging.Logger | str | None): Logger used for printing Defaults to None.
logger (logging.Logger | str, optional): Logger used for printing
related information during evaluation. Default: None. related information during evaluation. Default: None.
pklfile_prefix (str | None): The prefix of pkl files. It includes pklfile_prefix (str, optional): The prefix of pkl files, including
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str | None): The prefix of submission datas. submission_prefix (str, optional): The prefix of submission datas.
If not specified, the submission data will not be generated. If not specified, the submission data will not be generated.
show (bool): Whether to visualize. show (bool, optional): Whether to visualize.
Default: False. Default: False.
out_dir (str): Path to save the visualization results. out_dir (str, optional): Path to save the visualization results.
Default: None. Default: None.
Returns: Returns:
...@@ -268,11 +269,11 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -268,11 +269,11 @@ class KittiMonoDataset(NuScenesMonoDataset):
submission. submission.
Args: Args:
net_outputs (list[np.ndarray]): List of array storing the \ net_outputs (list[np.ndarray]): List of array storing the
inferenced bounding boxes and scores. inferenced bounding boxes and scores.
class_names (list[String]): A list of class names. class_names (list[String]): A list of class names.
pklfile_prefix (str | None): The prefix of pkl file. pklfile_prefix (str): The prefix of pkl file.
submission_prefix (str | None): The prefix of submission file. submission_prefix (str): The prefix of submission file.
Returns: Returns:
list[dict]: A list of dictionaries with the kitti format. list[dict]: A list of dictionaries with the kitti format.
...@@ -383,11 +384,11 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -383,11 +384,11 @@ class KittiMonoDataset(NuScenesMonoDataset):
submission. submission.
Args: Args:
net_outputs (list[np.ndarray]): List of array storing the \ net_outputs (list[np.ndarray]): List of array storing the
inferenced bounding boxes and scores. inferenced bounding boxes and scores.
class_names (list[String]): A list of class names. class_names (list[String]): A list of class names.
pklfile_prefix (str | None): The prefix of pkl file. pklfile_prefix (str): The prefix of pkl file.
submission_prefix (str | None): The prefix of submission file. submission_prefix (str): The prefix of submission file.
Returns: Returns:
list[dict]: A list of dictionaries have the kitti format list[dict]: A list of dictionaries have the kitti format
...@@ -498,7 +499,7 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -498,7 +499,7 @@ class KittiMonoDataset(NuScenesMonoDataset):
Returns: Returns:
dict: Valid predicted boxes. dict: Valid predicted boxes.
- bbox (np.ndarray): 2D bounding boxes. - bbox (np.ndarray): 2D bounding boxes.
- box3d_camera (np.ndarray): 3D bounding boxes in \ - box3d_camera (np.ndarray): 3D bounding boxes in
camera coordinate. camera coordinate.
- scores (np.ndarray): Scores of boxes. - scores (np.ndarray): Scores of boxes.
- label_preds (np.ndarray): Class label predictions. - label_preds (np.ndarray): Class label predictions.
......
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