Configuration of o3d.visualization.Visualizer for bigger window sizes does not work
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
**Describe the bug**
Received `[Open3D WARNING] [ViewControl] ConvertFromPinholeCameraParameters() failed because window height and width do not match.`, when setting the window size of `o3d.visualization.Visualizer()` to values bigger than `(2501, 1326)`
**To Reproduce**
Download the [fountain dataset](https://storage.googleapis.com/isl-datasets/open3d-dev/fountain.zip), extract it and set the variable `o3d_dataset_idp` in the following script to `path/to/fountain/fountain_small`
Then, run the script
```
import open3d as o3d
import re
import os
import copy
from cto.ext.o3d.file import get_file_list
# Taken from http://www.open3d.org/docs/release/tutorial/Advanced/color_map_optimization.html
def sorted_alphanum(file_list_ordered):
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(file_list_ordered, key=alphanum_key)
# Taken from http://www.open3d.org/docs/release/tutorial/Advanced/color_map_optimization.html
def get_file_list(path, extension=None):
if extension is None:
file_list = [path + f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
else:
file_list = [
path + f
for f in os.listdir(path)
if os.path.isfile(os.path.join(path, f)) and os.path.splitext(f)[1] == extension
]
file_list = sorted_alphanum(file_list)
return file_list
# Taken from http://www.open3d.org/docs/release/tutorial/Advanced/color_map_optimization.html
def parse_o3d_data(depth_image_idp, color_image_idp):
depth_image_ifp_list = get_file_list(
depth_image_idp, extension=".png")
color_image_ifp_list = get_file_list(
color_image_idp, extension=".jpg")
assert (len(depth_image_ifp_list) == len(color_image_ifp_list))
rgbd_images = []
for i in range(len(depth_image_ifp_list)):
depth = o3d.io.read_image(os.path.join(depth_image_ifp_list[i]))
color = o3d.io.read_image(os.path.join(color_image_ifp_list[i]))
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
color, depth, depth_scale=1000.0)
rgbd_images.append(rgbd_image)
return rgbd_images
def render_test(mesh,
camera_trajectory,
show_rendering=False):
vis = o3d.visualization.Visualizer()
camera_parameter_list = camera_trajectory.parameters
for camera_parameters in camera_parameter_list:
width = 2501 # this fails here, but works with the default height
height = 1326 # this fails here, but works with the default width
focal_length = 500
cx = width / 2.0 - 0.5
cy = height / 2.0 - 0.5
vis.create_window(
width=width,
height=height,
# left=0, # 50
# top=0, # 50
visible=show_rendering)
vis.add_geometry(mesh)
view_control = vis.get_view_control()
render_compatible_camera_parameters = copy.deepcopy(camera_parameters)
render_compatible_camera_parameters.intrinsic.set_intrinsics(
width, height, focal_length, focal_length, cx, cy)
view_control.convert_from_pinhole_camera_parameters(
render_compatible_camera_parameters)
vis.poll_events()
vis.update_renderer()
if __name__ == '__main__':
# https://storage.googleapis.com/isl-datasets/open3d-dev/fountain.zip
o3d_dataset_idp = 'path/to/fountain/fountain_small'
depth_image_idp = os.path.join(o3d_dataset_idp, "depth/")
color_image_idp = os.path.join(o3d_dataset_idp, "image/")
camera_traj_ifp = os.path.join(o3d_dataset_idp, "scene/key.log")
mesh_ifp = os.path.join(o3d_dataset_idp, "scene", "integrated.ply")
camera_trajectory = o3d.io.read_pinhole_camera_trajectory(camera_traj_ifp)
rgbd_images = parse_o3d_data(depth_image_idp, color_image_idp)
mesh = o3d.io.read_triangle_mesh(mesh_ifp)
render_test(
mesh,
camera_trajectory,
show_rendering=True)
```
**Expected behavior**
`ConvertFromPinholeCameraParameters() `should not fail, because of different window sizes.
**Environment**
- Operating system: (e.g., Ubuntu 18.04)
- Python version: (e.g. Python 3.7.4)
- Open3D version: 0.10.0.0
- Is this remote workstation?: no
- How did you install Open3D?: pip
**Additional context**
Parameter set 1: (default parameter, this works)
width = 1920
height = 1080
Parameter set 2: (this fails)
width = 1920
height = 1327 # 1326 works, 1327 fails
Parameter set 3: (this fails)
width = 2502 # 2501 works, 2502 fails
height = 1080
Parameter set 4: (this fails => the problem is not independent of both parameters)
width = 2501 # this fails here, but works with the default height
height = 1326 # this fails here, but works with the default width
This could be the same issue than #1164, however in the script above the intrinsic camera parameters are definitively correctly set.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.