Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

`capture_screen_image` crashes

Open walchko opened this issue 6 years ago • 4 comments

IMPORTANT: Please use the following template to report the bug.


Describe the bug

I am new to open3d. I was trying to render off screen (no window) and just save directly to an image. When I run a very simple case, render a sphere, it crashed

To Reproduce Steps to reproduce the behavior:

Python 3.7.5 (default, Nov 20 2019, 09:21:52) 
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import open3d as o3d
>>> 
>>> s = o3d.geometry.TriangleMesh.create_sphere(5.0)
>>> 
>>> vv=o3d.visualization.Visualizer()
>>> vv.add_geometry(s)
False
>>> vv.capture_screen_image("test.png", True)
zsh: segmentation fault (core dumped)  python

Expected behavior

An image of a sphere would be saved

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Ubuntu 19.10
  • Python version: 3.7
  • Open3D version: from pip 0.9.0.0
  • Is this remote workstation?: no
  • How did you install Open3D?: pip

walchko avatar Apr 15 '20 16:04 walchko

before vv.add_geometry(s) write vv.create_window() something like this


import open3d
mesh=open3d.geometry.TriangleMesh()
s=mesh.create_sphere(5)
vis=open3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(s)
vis.run()
vis.capture_screen_image('test.png',True)

so vis.add_geometry(s) will return True insted of False

after rotating with cursor while you close window it will capture image before what you see in window before closing.

edit: i am getting nothing with vis.create_window(visible=False)

g2ragrawal avatar Apr 15 '20 17:04 g2ragrawal

Thanks. I was trying to render off screen (no window) and just save directly to an image ... sorry for not being clear on that. If I set vis.create_window(visible=False) like your edit, then after I enter vis.run(), the command line just hangs and I have to kill the terminal. If I don't put visible=False in, then a window pops up. I wanted to automate the generation of some renderings and, since I am new to open3d, I was using this as a very simple test case. Thanks again.

walchko avatar Apr 15 '20 18:04 walchko

python3 << EOF
import open3d
import numpy
import matplotlib.pyplot as plt
mesh=open3d.geometry.TriangleMesh()
s=mesh.create_sphere(5)
vis=open3d.visualization.Visualizer()
vis.create_window(visible=False)
vis.add_geometry(s)
def move_forward(vis):
  image = vis.capture_screen_float_buffer(False)
  image=numpy.asarray(image) 
  plt.imsave("test.png",image)
  vis.register_animation_callback(None)
  vis.destroy_window()
  return False
vis.register_animation_callback(move_forward)

vis.run()
EOF

you can refer this it will give you image edit : if you want to generate rotation in ( x,y) plane and need some help and stuck than how much you wanted rotate than mention your rotation requirment

g2ragrawal avatar Apr 15 '20 19:04 g2ragrawal

@g2ragrawal Hi, do you know how to set rotation of a point cloud and show(and save) each frame at the same time?

CaptainEven avatar Jun 11 '21 03:06 CaptainEven