From 4f59e5f28aaf6ccf467634f357a3dbcca3050528 Mon Sep 17 00:00:00 2001 From: xiangxu-0103 Date: Fri, 14 Oct 2022 18:57:55 +0800 Subject: [PATCH 1/5] fix dataset converter --- mmdet3d/datasets/convert_utils.py | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/mmdet3d/datasets/convert_utils.py b/mmdet3d/datasets/convert_utils.py index 642e4b924..afd2a77a6 100644 --- a/mmdet3d/datasets/convert_utils.py +++ b/mmdet3d/datasets/convert_utils.py @@ -198,19 +198,19 @@ def get_kitti_style_2d_boxes(info: dict, Args: info (dict): Information of the given sample data. - cam_idx (int): Camera id which the 2d / mono3d annotations to obtain - belong to. In KITTI, typically only CAM 2 will be used, + cam_idx (int, optional): Camera id which the 2d / mono3d annotations to + obtain belong to. In KITTI, typically only CAM 2 will be used, and in Waymo, multi cameras could be used. Defaults to 2. - occluded (tuple[int]): Integer (0, 1, 2, 3) indicating occlusion state: - 0 = fully visible, 1 = partly occluded, 2 = largely occluded, - 3 = unknown, -1 = DontCare. + occluded (tuple[int], optional): Integer (0, 1, 2, 3) indicating + occlusion state: 0 = fully visible, 1 = partly occluded, + 2 = largely occluded, 3 = unknown, -1 = DontCare. Defaults to (0, 1, 2, 3). - annos (dict, optional): Original annotations. - mono3d (bool): Whether to get boxes with mono3d annotation. + annos (dict, optional): Original annotations. Defaults to None. + mono3d (bool, optional): Whether to get boxes with mono3d annotation. Defaults to True. - dataset (str): Dataset name of getting 2d bboxes. - Defaults to `kitti`. + dataset (str, optional): Dataset name of getting 2d bboxes. + Defaults to 'kitti'. Return: list[dict]: List of 2d / mono3d annotation record that @@ -344,10 +344,11 @@ def post_process_coords( Args: corner_coords (list[int]): Corner coordinates of reprojected bounding box. - imsize (tuple[int]): Size of the image canvas. + imsize (tuple[int], optional): Size of the image canvas. + Defaults to (1600, 900). Return: - tuple [float]: Intersection of the convex hull of the 2D box + tuple[float]: Intersection of the convex hull of the 2D box corners and the image canvas. """ polygon_from_2d_box = MultiPoint(corner_coords).convex_hull @@ -383,11 +384,11 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float, Returns: dict: A sample 2d annotation record. - - bbox_label (int): 2d box label id - - bbox_label_3d (int): 3d box label id - - bbox (list[float]): left x, top y, right x, bottom y - of 2d box - - bbox_3d_isvalid (bool): whether the box is valid + + - bbox_label (int): 2d box label id + - bbox_label_3d (int): 3d box label id + - bbox (list[float]): left x, top y, right x, bottom y of 2d box + - bbox_3d_isvalid (bool): whether the box is valid """ if dataset == 'nuscenes': @@ -398,10 +399,6 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float, cat_name = NuScenesNameMapping[cat_name] categories = nus_categories else: - cat_name = ann_rec['name'] - if cat_name not in categories: - return None - if dataset == 'kitti': categories = kitti_categories elif dataset == 'waymo': @@ -409,6 +406,10 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float, else: raise NotImplementedError('Unsupported dataset!') + cat_name = ann_rec['name'] + if cat_name not in categories: + return None + rec = dict() rec['bbox_label'] = categories.index(cat_name) rec['bbox_label_3d'] = rec['bbox_label'] From 049879a8903ca83cedecdd46b7ce08201ebf0482 Mon Sep 17 00:00:00 2001 From: xiangxu-0103 Date: Fri, 14 Oct 2022 22:21:31 +0800 Subject: [PATCH 2/5] delete whitespace --- mmdet3d/datasets/convert_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmdet3d/datasets/convert_utils.py b/mmdet3d/datasets/convert_utils.py index afd2a77a6..d2cd5678b 100644 --- a/mmdet3d/datasets/convert_utils.py +++ b/mmdet3d/datasets/convert_utils.py @@ -384,7 +384,7 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float, Returns: dict: A sample 2d annotation record. - + - bbox_label (int): 2d box label id - bbox_label_3d (int): 3d box label id - bbox (list[float]): left x, top y, right x, bottom y of 2d box From 0c628e3822258e7713f46789dcc02c99813a9e8b Mon Sep 17 00:00:00 2001 From: xiangxu-0103 Date: Mon, 17 Oct 2022 21:28:04 +0800 Subject: [PATCH 3/5] update docs --- mmdet3d/datasets/convert_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmdet3d/datasets/convert_utils.py b/mmdet3d/datasets/convert_utils.py index d2cd5678b..97631fc54 100644 --- a/mmdet3d/datasets/convert_utils.py +++ b/mmdet3d/datasets/convert_utils.py @@ -198,8 +198,8 @@ def get_kitti_style_2d_boxes(info: dict, Args: info (dict): Information of the given sample data. - cam_idx (int, optional): Camera id which the 2d / mono3d annotations to - obtain belong to. In KITTI, typically only CAM 2 will be used, + cam_idx (int): Camera id which the 2d / mono3d annotations to obtain + belong to. In KITTI, typically only CAM 2 will be used, and in Waymo, multi cameras could be used. Defaults to 2. occluded (tuple[int], optional): Integer (0, 1, 2, 3) indicating From 7a4e19516e45111efa1ab0a224397478b1aeea7c Mon Sep 17 00:00:00 2001 From: Xiangxu-0103 Date: Tue, 18 Oct 2022 13:16:37 +0800 Subject: [PATCH 4/5] remove unnecessary optional docs --- mmdet3d/datasets/convert_utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mmdet3d/datasets/convert_utils.py b/mmdet3d/datasets/convert_utils.py index 97631fc54..d4cd235a8 100644 --- a/mmdet3d/datasets/convert_utils.py +++ b/mmdet3d/datasets/convert_utils.py @@ -202,14 +202,14 @@ def get_kitti_style_2d_boxes(info: dict, belong to. In KITTI, typically only CAM 2 will be used, and in Waymo, multi cameras could be used. Defaults to 2. - occluded (tuple[int], optional): Integer (0, 1, 2, 3) indicating - occlusion state: 0 = fully visible, 1 = partly occluded, - 2 = largely occluded, 3 = unknown, -1 = DontCare. + occluded (tuple[int]): Integer (0, 1, 2, 3) indicating occlusion state: + 0 = fully visible, 1 = partly occluded, 2 = largely occluded, + 3 = unknown, -1 = DontCare. Defaults to (0, 1, 2, 3). annos (dict, optional): Original annotations. Defaults to None. mono3d (bool, optional): Whether to get boxes with mono3d annotation. Defaults to True. - dataset (str, optional): Dataset name of getting 2d bboxes. + dataset (str): Dataset name of getting 2d bboxes. Defaults to 'kitti'. Return: @@ -344,8 +344,7 @@ def post_process_coords( Args: corner_coords (list[int]): Corner coordinates of reprojected bounding box. - imsize (tuple[int], optional): Size of the image canvas. - Defaults to (1600, 900). + imsize (tuple[int]): Size of the image canvas. Return: tuple[float]: Intersection of the convex hull of the 2D box From 8f8465e64f71622f57067a87b5046ec44b02d51b Mon Sep 17 00:00:00 2001 From: Xiangxu-0103 Date: Wed, 19 Oct 2022 17:32:40 +0800 Subject: [PATCH 5/5] update docs --- mmdet3d/datasets/convert_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mmdet3d/datasets/convert_utils.py b/mmdet3d/datasets/convert_utils.py index d4cd235a8..c05b8c3fa 100644 --- a/mmdet3d/datasets/convert_utils.py +++ b/mmdet3d/datasets/convert_utils.py @@ -207,7 +207,7 @@ def get_kitti_style_2d_boxes(info: dict, 3 = unknown, -1 = DontCare. Defaults to (0, 1, 2, 3). annos (dict, optional): Original annotations. Defaults to None. - mono3d (bool, optional): Whether to get boxes with mono3d annotation. + mono3d (bool): Whether to get boxes with mono3d annotation. Defaults to True. dataset (str): Dataset name of getting 2d bboxes. Defaults to 'kitti'. @@ -345,6 +345,7 @@ def post_process_coords( corner_coords (list[int]): Corner coordinates of reprojected bounding box. imsize (tuple[int]): Size of the image canvas. + Defaults to (1600, 900). Return: tuple[float]: Intersection of the convex hull of the 2D box