Ask Your Question

Creating Python bindings for missing functions

asked 2013-11-28 00:39:55 -0500

pyro gravatar image

updated 2013-11-28 02:18:49 -0500

berak gravatar image

What is the correct way to create Python bindings for missing functions in OpenCV? For example, considering an already wrapped simple function (say cv::calcHist() in opencv/modules/imgproc/src/histogram.cpp) as an example:

  1. Could someone explain what code changes in which files? I just expect some simple examples and further references that I can look up myself.
  2. Are there any best practices to follow when writing Python bindings for OpenCV?


edit retag flag offensive close merge delete


you mean existing opencv functions, that somehow did not get wrapped ?

berak gravatar imageberak ( 2013-11-28 02:32:13 -0500 )edit

@berak yes that's right.

pyro gravatar imagepyro ( 2013-11-28 02:44:40 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-11-29 01:09:56 -0500

Here is message about it on my blog. It is in Russian, but i believe, that list of command prompts is enough to understand how to generate Python/Java bindings. Also any automatic translation tool helps you to read the whole text.

I summary: There is some python scripts in OpenCV build system that parses header files, find special markers and generate bindings for marked functions automatically. Article was written for Java, but it is not the problem. Python bindings are generated in the same way using the same header parser. If you want to add some functions to Python/Java bindings you need to change the export macro in function definition.

CV_EXPORTSPublic symbol, not for bindings
CV_EXPORTS_WPublic symbol for bindings
CV_WRAPPublic class method for bindings. Class must be marked as CV_EXPORTS_W
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-11-28 00:39:55 -0500

Seen: 237 times

Last updated: Nov 29 '13