Skip to content

Commit

Permalink
Fix: Resolve matrix dimension mismatch issue in _dispatch_kwargs
Browse files Browse the repository at this point in the history
- Updated `_dispatch_kwargs` method to handle `cam_type` and `out_dir` more robustly.
- Ensured proper handling of `cam2img` and `lidar2cam` matrix dimensions:
  - Added logic to convert 3x3 matrices to 4x4 for compatibility with downstream calculations.
  - Included validation checks for input dimensions to prevent runtime errors.
- Improved error handling for unsupported or missing `cam_type` in the dataset.
- Added debug logging to trace matrix shapes during preprocessing.

These changes resolve the ValueError related to incompatible matrix dimensions during the `matmul` operation.
  • Loading branch information
kyh980909 committed Nov 27, 2024
1 parent fe25f7a commit e452361
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demo/mono_det_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def parse_args():

call_args['inputs'] = dict(
img=call_args.pop('img'), infos=call_args.pop('infos'))
call_args.pop('cam_type')
# call_args.pop('cam_type')

if call_args['no_save_vis'] and call_args['no_save_pred']:
call_args['out_dir'] = ''
Expand Down
3 changes: 2 additions & 1 deletion mmdet3d/apis/inferencers/base_3d_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def _dispatch_kwargs(self,
kwargs['img_out_dir'] = out_dir
kwargs['pred_out_dir'] = out_dir
if cam_type != '':
kwargs['cam_type_dir'] = cam_type
kwargs['cam_type'] = cam_type
# kwargs['cam_type_dir'] = cam_type
return super()._dispatch_kwargs(**kwargs)

def __call__(self,
Expand Down
7 changes: 7 additions & 0 deletions mmdet3d/apis/inferencers/mono_det3d_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def _inputs_to_list(self,
lidar2cam = np.asarray(
data_info['images'][cam_type]['lidar2cam'],
dtype=np.float32)

if cam2img.shape == (3, 3):
cam2img_fixed = np.eye(4)
cam2img_fixed[:3, :3] = cam2img
cam2img = cam2img_fixed


if 'lidar2img' in data_info['images'][cam_type]:
lidar2img = np.asarray(
data_info['images'][cam_type]['lidar2img'],
Expand Down

0 comments on commit e452361

Please sign in to comment.