Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate opencv code #91

Open
schmk2 opened this issue Feb 23, 2016 · 2 comments
Open

Generate opencv code #91

schmk2 opened this issue Feb 23, 2016 · 2 comments
Milestone

Comments

@schmk2
Copy link

schmk2 commented Feb 23, 2016

A new feature could generate opencv source code from any process graph.

@l00mi l00mi added this to the 6.2.0 milestone Mar 20, 2017
@drzraf
Copy link
Contributor

drzraf commented Jul 2, 2018

Most opencv Python functions take a frame as their first parameter and return the transformed frame.
With the help of functools.reduce, functools.partial it's should be possible so that the json edges+steps get converted into one function call per edge, containing a list of steps, optionally wrapped by partial() and a composition with some functools magic wrapping frame passing.

In a first step Python code can end up as:

#!/usr/bin/python
pipe_edge1 = compose( webcam(),
                      partial( IPLGammaCorrection, gamma = 0.4 ),
                      partial( IPLCanny, highThreshold = 0.6, ... ),
                      frame )
pipe_edge1() # run!

And then based on an hypothetical IPL<->opencv JSON mapping + documentation, transformed as:

#!/usr/bin/python
pipe_edge1 = compose( ...
                      partial( cv2.pow, gamma = 0.4 ),
                      partial( cv2.Canny, threshold2 = 0.6, ... ),
                      frame )
pipe_edge1()

But that would be even better to do most of this directly from opencv python-binding code itself.
Inside https://github.com/opencv/opencv/blob/master/modules/python/bindings/CMakeLists.txt
it seems a pyopencv_signatures.json is generated. I couldn't get my hand on it nor build it (@skvark) but that could be and interesting file.

@l00mi
Copy link
Member

l00mi commented Jul 4, 2018

Interesting, we always were thinking of generating C++ code. But we could absolutely (also) go with a python generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants