112
CONTENTS
14.2.2
Linux
On Linux systems running
/mvIMPACT_Python/setup.py
can be used to build and install the Python API in the
site-packages
sub-folder of your Python installation providing a matching compiler could be found. However one
must be familiar with Pythons
distutils
package.
Note
It is mandatory that the
python-dev
package is installed on the target Linux system, otherwise the binaries
cannot be built!
The invoking user of the script must have the rights to install the generated binaries in the python directory of
his system. If this is not the case, a recommended way to call the installation script is:
sudo -E python setup.py install
The building process may take literally a few minutes, so please be patient!
Attention
The
SWIG
generated wrapper code source file is very large! On some embedded systems or on 32-bit
systems gcc might have trouble to digest this file as it is known to consume a lot of memory per source line in
a given translation unit. When you encounter such a situation please get in touch with us!
14.3
Using
The actual API is almost the same as in C++ thus for now the C++ manual can be used as a reference and function
description. There are just some minor differences between the C++ and the Python API which shall be explained
here briefly:
• Stuff that has been declared deprecated at the time of publishing the Python API will not be available
• Simple
getter
functions may be wrapped as Python properties to have a more
Python-like
interface.
So e.g. the function
Component::isValid()
will be a property in Python
• Code that in C++ resides in sub-namespaces like e.g.
mvIMPACT::acquire::GenICam
will all end up in
acquire
in Python(this is likely to change in future versions!)
• Some functions that use Python style built-in names like
mvIMPACT::acquire::Component::type()
will use
a slightly different name in Python like
getType
in order to avoid confusion
Apart from that if someone is familiar with the C++ interface it shouldn't be too difficult to use the API. This is how
an acquisition from a user selectable device can be done:
from __future__ import print_function
import os
import platform
import string
import sys
# import all the stuff from mvIMPACT Acquire into the current scope
from mvIMPACT import acquire
# import all the mvIMPACT Acquire related helper function such as ’conditionalSetProperty’ into the current scope
# If you want to use this module in your code feel free to do so but make sure the ’Common’ folder resides in a sub-folder of your project then
from Common import *
# For systems with NO mvDisplay library support
#import ctypes
#import Image
MATRIX VISION GmbH