menpo3d
makes manipulating 3D mesh data a simple task. In particular, this package provides the ability to import, visualize and rasterize 3D meshes. Although 3D meshes can be created within the main menpo
package, this package adds the real functionality for working with 3D data.
Visualizing 3D objects
menpo3d adds support for viewing 3D objects through
Mayavi, which is based on VTK.
One of the main reasons menpo3d is a seperate project to the menpo core
library is to isolate the more complex dependencies that this brings to the
project. 3D visualization is not yet supported in the browser, so we rely on
platform-specific viewing mechanisms like QT
or WX
. It also limits menpo3d
to
be Python 2 only, as VTK
does not yet support Python 3.
In order to view 3D items you will need to first use the %matplotlib qt
IPython magic command to set up QT
for rendering (you do this instead of
%matplotlib inline
which is what is needed for using the usual Menpo
Widgets). As a complete example, to view a mesh in IPython
you
would run something like:
import menpo3d
mesh = menpo3d.io.import_builtin_asset('james.obj')
%matplotlib qt
mesh.view()
If you are on Linux and get an error like:
ValueError: API 'QString' has already been set to version 1
Try adding the following to your .bashrc
file:
export QT_API=pyqt
export ETS_TOOLKIT=qt4
Open a new terminal and re-run IPython notebook in here, this should fix the issue.
If you are running Windows and recieve this error, try:
set QT_API=pyqt
set ETS_TOOLKIT=qt4
Alternatively, try installing wxPython:
conda install wxpython
and using %matplotlib wx
.