Binding a high-performance C++ image processing library to Python



Pylene is an image processing (IP) library aiming for high genericity and performance. To accomplish its goals, it was created using C++ templates, allowing for great flexibility and no loss of performance. Pylene is one of the few IP libraries that successfully uses templates, which means it could become a staple in the IP field, but it would first have to overcome a big issue resulting from the usage of C++ templates. That issue is the usability of the library. C++ is not known for its ease of use, and by extension, this makes Pylene hard to use in concrete IP problems. Here, we try to overcome this problem through a Python version of the library. Seeing as though recreating all the library in Python would be nigh impossible, it seems sensible to instead try to bind the high level API to Python. This in itself brings up another issue: the available techniques do not answer our problems well enough, especially in regards to C++ template bindings. Since the idea behind templates of "knowing the type at compile time" doesn't exist in Python, we are faced with a gap between the static world of C++ templates, and the dynamic world of Python. We are presenting in this paper our solution to cross this static-dynamic difference: removing the templates through type-erasure and using contextual information for the type retrieval in Python.