isl-org / isl-org/Open3D

No bounds are set when moving an AxisAlignedBoundingBox instance to a different device

Open
#6,721 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### Describe the issue

Hi, thanks for the excellent work you've done. Today, I found an unnecessary warning displayed when I try to move an instance of `AxisAlignedBoundingBox` from CPU to CUDA though `min_bound` is indeed smaller than `max_bound`, which causes no values set to the returned `bbox`.

After reviewing the source code (in `cpp/open3d/t/geometry/BoundingVolume.cpp`), I guess the reason is when calling `To()` method, it creates an instance on the specific device with `min_bound` as well as `max_bound` set to 0 first, then `SetMinBound()` and `SetMaxBound()` will check if `max_bound_` and `min_bound_` are valid before setting by comparing it with the initial value, i.e., 0 in this case.

Since the only requirement for a bounding box specified by min/max bound is `min_bound` is less than `max_bound` strictly and when an instance calls `To()`, it's already valid, I believe data checking in `To()` is redundant.

### Steps to reproduce the bug

```python
import numpy as np
import open3d as o3d

device = o3d.core.Device('CUDA:0')

min_bound = np.array([-1, 1, -1], dtype=np.float64)
max_bound = np.array([-0.5, 2, 0.5], dtype=np.float64)
bbox = o3d.t.geometry.AxisAlignedBoundingBox(min_bound, max_bound).to(device)
print(bbox)
```

### Error message

[Open3D WARNING] Invalid axis-aligned bounding box. Please make sure all the elements in max bound are larger than min bound.
[Open3D WARNING] Invalid axis-aligned bounding box. Please make sure all the elements in min bound are smaller than max bound.
AxisAlignedBoundingBox[[0 0 0] - [0 0 0], Float32, CUDA:0]

### Expected behavior

`min_bound` and `max_bound` should be set successfully (without any warnings) to `bbox` which is an instance of `AxisAlignedBoundingBox` stored in CUDA.

### Open3D, Python and System information

```markdown
- Operating system: Ubuntu 20.04
- Python version: Python 3.10
- Open3D version: 0.18.0
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc
```

### Additional information

This problem can be sidestepped by creating `min_bound` as well as `max_bound` in the desired device, then there is no need to call `to()` method. But I do hope it can be solved in the source code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.