In [2]:
%matplotlib qt

In [3]:
import numpy as np
from menpo.rasterize import GLRasterizer
import matplotlib.pyplot as plt
import menpo.io as pio

RENDERING A FACE


In [4]:
mesh = pio.import_mesh('/vol/hci2/Databases/video/BU-3DFE/F0001/F0001_AN01WH_F3D.wrl')

In [5]:
%matplotlib qt
viewer = mesh.view()


/vol/atlas/homes/ja310/.virtualenvs/menpo/local/lib/python2.7/site-packages/mayavi/preferences/preference_manager.py:24: UserWarning: Module PIL was already imported from /usr/lib/python2.7/dist-packages/PIL/__init__.pyc, but /vol/atlas/homes/ja310/.virtualenvs/menpo/lib/python2.7/site-packages is being added to sys.path
  import pkg_resources

In [6]:
viewer_settings = viewer.renderer_settings

In [7]:
viewer_settings


Out[7]:
{'height': 320,
 'model_matrix': array([[ 1.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  0.],
       [ 0.,  0.,  0.,  1.]], dtype=float32),
 'projection_matrix': array([[   2.98564076,    0.        ,    0.        ,    0.        ],
       [   0.        ,    3.7320509 ,    0.        ,    0.        ],
       [   0.        ,    0.        ,   -2.04626441, -825.80908203],
       [   0.        ,    0.        ,   -1.        ,    0.        ]], dtype=float32),
 'view_matrix': array([[  8.40455949e-01,  -4.95000124e-01,  -2.20473692e-01,
         -2.99057674e+01],
       [  5.07882953e-01,   5.77732325e-01,   6.38968110e-01,
          4.12281265e+01],
       [ -1.88914508e-01,  -6.48999393e-01,   7.36960709e-01,
         -4.81009918e+02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00]], dtype=float32),
 'width': 400}

In [8]:
# build a rasterizer configured from the current view
r = GLRasterizer(**viewer_settings)

In [17]:
# rasterize to produce an RGB and shape image
rgb_img, shape_img = r.rasterize_mesh_with_f3v_interpolant(mesh, per_vertex_f3v=np.random.randn(mesh.n_points,3))

In [18]:
%matplotlib inline
rgb_img.view()
shape_img.view_new()


Out[18]:
<menpo.visualize.viewmatplotlib.MatplotlibImageViewer2d at 0x9890290>

In [14]:
rgb_img.mask.view()


Out[14]:
<menpo.visualize.viewmatplotlib.MatplotlibImageViewer2d at 0x9a8e210>

In [ ]: