isl-org / isl-org/Open3D

convert_from_pinhole_camera_parameters does not set principal point correctly

Open
#6,411 1 comment 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

When trying to set new camera parameters for the `open3d.visualization.ViewControl` object, the function `convert_from_pinhole_camera_parameters `does not set the principal point from the newly provided intrinsic matrix correctly. A subsequent call to `convert_to_pinhole_camera_parameters` shows that while new focal length is correctly set, the values of the principal point remain unchanged.

### Steps to reproduce the bug

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

pcd_data = o3d.data.PCDPointCloud()
pcd = o3d.io.read_point_cloud(pcd_data.path)
vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(pcd)

# New focal length and new principal point
intrinsic = np.array(
[[950., 0., 1000.], # <--
[ 0., 950., 600.], # <--
[ 0., 0., 1. ]]
)

extrinsic = np.array(
[[ 1., 0., 0., -2.33576],
[ 0., -1., 0., 1.78849],
[ 0., 0., -1., 3.99891],
[ 0., 0., 0., 1.]]
)

new_param = o3d.camera.PinholeCameraParameters()
new_param.intrinsic = o3d.camera.PinholeCameraIntrinsic()
new_param.intrinsic.intrinsic_matrix = intrinsic
new_param.extrinsic = extrinsic

# Set new camera parameters
ctr = vis.get_view_control()
ret = ctr.convert_from_pinhole_camera_parameters(new_param, allow_arbitrary=True)
print(ret) # True
vis.update_renderer()

# Get the camera parameters and check them
check_param = ctr.convert_to_pinhole_camera_parameters()

print(check_param.intrinsic.intrinsic_matrix) # px and py are wrong (they remain unchanged)
# Output:
# [[950. 0. 959.5] # <--
# [ 0. 950. 539.5] # <--
# [ 0. 0. 1. ]]

vis.run()
vis.destroy_window()
```

### Error message

_No response_

### Expected behavior

The expected behavior it that new values for principal point are set.

Alternatively, if this is not currently possible in Open3D, an error message should be shown.

However, the possibility of setting custom principal point is necessary, for example, when visualizing point clouds through a particular camera view obtained from a Structure from motion algorithm that refined the principal point position.

### Open3D, Python and System information

```markdown
- Operating system: Windows 10 64-bit
- Python version: Python 3.10.11
- Open3D version: 0.17.0+f1a0f3e
- System architecture: x86
- 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.