From 7d918a3fcf46fea36a8526521cbea63dae84a2a7 Mon Sep 17 00:00:00 2001 From: "Sajjad P. Savoji" Date: Mon, 12 Feb 2024 14:36:30 -0500 Subject: [PATCH] Update mono_det3d_inferencer.py remove dependancy to lidar for mono det3D inferencer --- .../apis/inferencers/mono_det3d_inferencer.py | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/mmdet3d/apis/inferencers/mono_det3d_inferencer.py b/mmdet3d/apis/inferencers/mono_det3d_inferencer.py index 22863ae16..7fb29196f 100644 --- a/mmdet3d/apis/inferencers/mono_det3d_inferencer.py +++ b/mmdet3d/apis/inferencers/mono_det3d_inferencer.py @@ -114,18 +114,19 @@ def _inputs_to_list(self, f'the info file of {img_path} is not provided.') cam2img = np.asarray( data_info['images'][cam_type]['cam2img'], dtype=np.float32) - lidar2cam = np.asarray( - data_info['images'][cam_type]['lidar2cam'], - dtype=np.float32) - if 'lidar2img' in data_info['images'][cam_type]: - lidar2img = np.asarray( - data_info['images'][cam_type]['lidar2img'], + if 'lidar2cam' in data_info['images'][cam_type]: + lidar2cam = np.asarray( + data_info['images'][cam_type]['lidar2cam'], dtype=np.float32) - else: - lidar2img = cam2img @ lidar2cam + if 'lidar2img' in data_info['images'][cam_type]: + lidar2img = np.asarray( + data_info['images'][cam_type]['lidar2img'], + dtype=np.float32) + else: + lidar2img = cam2img @ lidar2cam + input['lidar2cam'] = lidar2cam + input['lidar2img'] = lidar2img input['cam2img'] = cam2img - input['lidar2cam'] = lidar2cam - input['lidar2img'] = lidar2img elif isinstance(inputs, (list, tuple)): # get cam2img, lidar2cam and lidar2img from infos for input in inputs: @@ -142,18 +143,20 @@ def _inputs_to_list(self, f'the info file of {img_path} is not provided.') cam2img = np.asarray( data_info['images'][cam_type]['cam2img'], dtype=np.float32) - lidar2cam = np.asarray( - data_info['images'][cam_type]['lidar2cam'], - dtype=np.float32) - if 'lidar2img' in data_info['images'][cam_type]: - lidar2img = np.asarray( - data_info['images'][cam_type]['lidar2img'], + if 'lidar2cam' in data_info['images'][cam_type]: + lidar2cam = np.asarray( + data_info['images'][cam_type]['lidar2cam'], dtype=np.float32) - else: - lidar2img = cam2img @ lidar2cam + if 'lidar2img' in data_info['images'][cam_type]: + lidar2img = np.asarray( + data_info['images'][cam_type]['lidar2img'], + dtype=np.float32) + else: + lidar2img = cam2img @ lidar2cam + + input['lidar2cam'] = lidar2cam + input['lidar2img'] = lidar2img input['cam2img'] = cam2img - input['lidar2cam'] = lidar2cam - input['lidar2img'] = lidar2img return list(inputs)