I am trying to get mayavi working in stereo with a easy3d philips tv. This tv supports 2 ways to encode the images for the left and right eye:
Top down (left eye image above the right eye image)
Side by Side (left eye image to the left of the the right eye image)
Unfortunately there is no Top Down or Side by Side option in vtk. So I thought I have two ways to implement this:
- Implement a new stereo option
- Implement a post rendering pass on an existing stereo option
Implementing a new stereo option in vtk is possible but it requires a custom build of vtk, vtk python and tvtk. (something like http://www.earthmodels.org/software/vtk-and-paraview/compiling-paraview). So I decided to try the other option first
Implementing a render pass also looks possible. I thought of using the interlaced stereo option (which has the left and right eye, line by line) and postprocessing that into two images on top of each other.
This is what I tried in the code below, but unfortunately after introducing a the rendering passes, the stereo option stops working altogether.
Does anybody have a suggestion to get TopDown or Side by Side stereo working?
# code below also at http://pastebin.com/aLWQUTuP
import numpy as np
import vtk # for a subclass in the delegate option
from mayavi.preferences.api import preference_manager
# Set the custom stereo options before importing mlab
pref = preference_manager.preferences
# Default to stereo = True
engine = mayavi.api.Engine()
scene = engine.new_scene()
window = scene.scene.render_window
renderer = window.renderers
# We have a window and a renderer, we can now run a custom rendering pass
# and set stereo options...
option = 'multipass'
if option == 'multipass':
# Option 1: Replace the default render pass with a custom one
# According to http://www.cmake.org/Wiki/VTK/MultiPass_Rendering#Overview
# we have to rebuild the default rendering, as it will be replaced
lights = tvtk.tvtk_classes.lights_pass.LightsPass()
default = tvtk.tvtk_classes.default_pass.DefaultPass()
seq = tvtk.tvtk_classes.sequence_pass.SequencePass()
passes = tvtk.tvtk_classes.render_pass_collection.RenderPassCollection()
seq.passes = passes
camera = tvtk.tvtk_classes.camera_pass.CameraPass()
camera.delegate_pass = seq
renderer.pass_ = camera
# Unfortunately our new multipass doesn't seem to support stereo rendering....
# this doesn't have any effect with multipass
# I thought of transforming the rendered image here, by reorganizing the horizontal lines...
window.stereo_render = 1
window.stereo_type = 'interlaced'
from mayavi import mlab
fig = mlab.gcf(engine)
a = np.random.random((100,3))
cont = mlab.points3d(a[:,0],a[:,1],a[:,2], opacity=0.3,figure=fig)
Enthought-Dev mailing list
On Fri, Apr 06, 2012 at 02:56:25PM +0200, Fedor Baart wrote:
> Does anybody have a suggestion to get TopDown or Side by Side stereo working?
I am sorry, you are going beyond my expertise in VTK :$
Enthought-Dev mailing list
|Free forum by Nabble||Edit this page|