top down stereo

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

top down stereo

Fedor Baart
Hi all,

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 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

import numpy as np
import tvtk
import tvtk.tvtk_classes
import tvtk.tvtk_classes.lights_pass
import tvtk.tvtk_classes.opaque_pass
import tvtk.tvtk_classes.render_pass
import tvtk.tvtk_classes.default_pass
import tvtk.tvtk_classes.sequence_pass
import tvtk.tvtk_classes.camera_pass
import tvtk.tvtk_classes.render_pass_collection
import tvtk.tvtk_classes.renderer_delegate
import tvtk.tvtk_classes.shadow_map_pass
import tvtk.tvtk_classes.gaussian_blur_pass
import tvtk.tvtk_classes.volumetric_pass
import tvtk.tvtk_classes.translucent_pass
import tvtk.tvtk_classes.overlay_pass

import tvtk.tvtk_base

import vtk # for a subclass in the delegate option
import mayavi.api
import mayavi.core
from mayavi.preferences.api import preference_manager

# Set the custom stereo options before importing mlab
pref = preference_manager.preferences
# Default to stereo = True
pref.set('enthought.tvtk.scene.stereo', 'True')
engine = mayavi.api.Engine()
scene = engine.new_scene()

window = scene.scene.render_window
renderer = window.renderers[0]

# 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
   # 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
[hidden email]
Reply | Threaded
Open this post in threaded view

Re: top down stereo

Gael Varoquaux
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
[hidden email]