ALTA  alpha
Python Interface

To have access to the python interface, you need to compile the python module. This can be done using the python tag in the scons call:

$ scons python

Once the python interface (alta.[so|dll]) is compiled, you need to update the PYTHONPATH environment variable to the build directory. If not, you will not have access to the interface. On UNIX-like systems, it can be done using by sourcing the setpath.sh script. On MS-Windows, you need to update the variable by hand.

In python, the ALTA module is simply loaded using:

>>> import alta

This module contains all the functions you need to manipulate ALTA and perform operations just like in the command line version of ALTA.

However, the interface to pass command line argument is a little bit different than for ALTA softwares. Command line arguments are passed using the argument object which is a dictionnary of key values arguments as in --key value. An arguments object can be created using a dictionnary:

>>> args = alta.arguments({'foo' : 'bar', 'hello' : 'world'})

This correspond to the argument --foo bar --hello world. Similarly, a vec type can be created from a list of floatting point values:

>>> v = alta.vec([0.0, 0.0, 0.0])

You can obtain BRDF, data and fitter objects using the get_function, get_data and get_fitter functions with the name of the plugin to load as argument:

>>> func   = alta.get_function('nonlinear_function_blinn')
>>> dat    = alta.get_data('data_merl')
>>> fitter = alta.get_fitter('nonlinear_fitter_ceres')

Note that you can also provide an arguments object to set specific options for the plugin (see below).

BRDF and data objects can load from and save to files:

>>> dat = alta.get_data('data_merl')
>>> dat.load('blue_metallic_paint.binary')
>>> dat.save('blue_metallic_paint.copy.binary')

In both cases, an arguments object can be passed to control the behaviour of the load or save functions. For example, if you want to save a function in a specific format, you can use the export argument:

>>> args = alta.arguments({'export' : 'shader'})
>>> func = alta.get_function('nonlinear_function_blinn')
>>> func.save('my_function.func', args)

Some commands are available as python functions:

>>> dat1 = alta.load_data('data_merl', 'blue-metallic-paint.binary')
>>> dat2 = alta.get_data('data_utia')
>>> alta.data2data(dat1, dat2)

This will perform a data conversion from the blue-metallic-paint of the MERL database to the UTIA format.

Available commands are: