isl-org / isl-org/Open3D

search_radius_vector_3d crashes when using a kdtree retured by a function

Open
#5,012 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](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### Describe the issue

I've been writing code to find the intersection of a line and a pointcloud. For this I iterate over the line segment and do a search_radius_vector_3d at each point on the line. This resulted in the code just stopping. No return, no error, it just ends.

The problem occurs when building the kdtree inside a function and returning it. This causes the search_radius_vector_3d to only return something in 10% of the times it ran, and just crash without any error or return in 90% of the times it ran.

When building the kdtree directly without any functions it works 100% of the time.

### Steps to reproduce the bug

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

#### Works 100% of the time ####
pcd = o3d.io.read_point_cloud('Databases/Pointclouds/nissan.ply')
downpcd = pcd.voxel_down_sample(voxel_size = 10)
kdtree = o3d.geometry.KDTreeFlann(downpcd)

point = np.array([0,500,100] , dtype = np.float64)
result = kdtree.search_hybrid_vector_3d(point, 48, 1)
print(result)

#### Works 10% of the time ####
def import_pointcloud(filepath, detail):
pcd = o3d.io.read_point_cloud(filepath)
downpcd = pcd.voxel_down_sample(voxel_size = detail)
kdtree = o3d.geometry.KDTreeFlann(downpcd)

return kdtree

kdtree = import_pointcloud('Databases/Pointclouds/nissan.ply', 10)

point = np.array([0,500,100] , dtype = np.float64)
result = kdtree.search_hybrid_vector_3d(point, 48, 1)
print(result)
```

### Error message

No error message at all.

### Expected behavior

_No response_

### Open3D, Python and System information

```markdown
- Operating system: Windows 11 64-bit
- Python version: 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
- Open3D version: 0.15.1
- System architecture: 64 bit (AMD64)
- Is this a remote workstation?: no
- How did you install Open3D?: pip
```

### Additional information

_No response_

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.