[vtkusers] Offscreen rendering with Python: Segmentation fault

Андрей Траченко goodrone at gmail.com
Mon Sep 6 12:30:36 EDT 2010


Unfortunately I haven't solved this issue yet. If my problem is not
clear enough, please let me know and I'll complete it with any
requested details. I've already tried the latest version from
repository without success.

I can provide root access to the Ubuntu server if needed for
experiments. Please help me with offscreen rendering in Python!

--
Andrew

2010/8/29 Андрей Траченко <goodrone at gmail.com>:
> Hello,
>
> I've spent some time trying to run offscreen rendering in Python
> (Linux) and I'm ready to provide some relatively clean results leading
> to segfault. See also a related thread [2].
>
> For my experiments I've installed a new cloud server with Ubuntu
> Server 10.04 x64. I assume it's a relatively clean installation
> (however it has a patched kernel).
>
> Then I aptitude install:
> * g++
> * cmake-curses-gui
> * python-dev
> * tk-dev
> * libosmesa6-dev
> * libgl1-mesa-dev
>
> I use the latest VTK archive (5.6.0):
> * BUILD_SHARED_LIBS=ON
> * BUILD_TESTING=OFF
> * VTK_OPENGL_HAS_OSMESA=ON
> * VTK_WRAP_PYTHON
>
> Then I export the required paths:
> * export LD_LIBRARY_PATH=~/VTK/build/bin
> * export PYTHONPATH=~/VTK/Wrapping/Python:~/VTK/build/bin
> (where ~ is substituted with my home directory)
>
> I verify that VTK Offscreen rendering actually works (in C++), by
> compiling and running the OffScreenRendering example [1]. It produces
> a correct screenshot.png image. But I'm interested in offscreen
> rendering in Python.
>
> I've converted the C++ example to a Python script:
>
> from vtk import *
>
> gf = vtkGraphicsFactory
> gf.SetOffScreenOnlyMode(1)
> gf.SetUseMesaClasses(1)
> if_ = vtkImagingFactory
> if_.SetUseMesaClasses(1)
>
> sphereSource = vtkSphereSource()
> mapper = vtkPolyDataMapper()
> mapper.SetInputConnection(sphereSource.GetOutputPort())
> actor = vtkActor()
> actor.SetMapper(mapper)
> renderer = vtkRenderer()
> renderWindow = vtkRenderWindow()
> renderWindow.SetOffScreenRendering(1)
> renderWindow.AddRenderer(renderer)
> renderer.AddActor(actor)
> renderer.SetBackground(1, 1, 1)
> renderWindow.Render() # <--- Segmentation fault
> wif = vtkWindowToImageFilter()
> wif.SetInput(renderWindow)
> wif.Update()
> writer = vtkPNGWriter()
> writer.SetFileName("python-screenshot.png")
> writer.SetInput(wif.GetOutput())
> writer.Write()
>
> It is a correct translation, because I've run it on my Windows box and
> got the same PNG image. However, it crashes with segfault on rendering
> in Linux.
>
> gdb's backtrace says (I skip a lot):
> #0  0x00007ffff6a43216 in ?? () from /lib/libc.so.6
> #1  0x00007ffff6a31e60 in ?? () from /lib/libc.so.6
> #2  0x00007ffff6a25c25 in vsscanf () from /lib/libc.so.6
> #3  0x00007ffff6a130e8 in sscanf () from /lib/libc.so.6
> #4  0x00007fffeedb3dfd in
> vtkOpenGLExtensionManager::ReadOpenGLExtensions() () from
> /root/VTK/build/bin/libvtkRendering.so.5.6
> #14 0x00007fffeed01257 in vtkRenderWindow::Render() () from
> /root/VTK/build/bin/libvtkRendering.so.5.6
> #29 0x00000000004a7c5e in PyEval_EvalFrameEx ()
>
> Does anybody have a working Python VTK wrapping with correct offscreen
> wrapping? Have I missed something in installing packages or
> configuring VTK? Should I try an older version of VTK? Does it worth
> trying the same on a non-patched linux box? Should I compile in Debug
> mode and run it with gdb again? Should I give up and just shoot in my
> foot with C++?
>
> I'm sorry for too many words. Please help! Thank you.
>
>  [1] http://www.vtk.org/Wiki/VTK/Examples/Utilities/OffScreenRendering
>  [2] http://www.vtk.org/pipermail/vtkusers/2009-June/101492.html
>
> --
> Andrew
>



More information about the vtkusers mailing list