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

• data2data(d1, d2) to convert a data d1 object into another one d2. This function will try to evaluate the input data at every location specified by the output data format when the format has a static set of configurations (this is the case for all data_io plugins). Function call: data2data(data_in, data_out).
• brdf2data(f, d) to evalute a BRDF f at the configurations defined by the data object d. This will replace the content of the data object by the values of the function at the specified locations. Function call brdf2data(func_in, data_out).
• data2stats(d1, d2) to compute the distance between two data objects d1 and d2. This function return a dictionnary containing different error metrics such as L2, Linf, RMSE, etc. You can query the value of each metric using dic['RMSE'] for example.