On May 17, 2009, at 1:23 PM, Chris Colbert wrote:

> How would I go about interfacing with OpenCV data types in cython?
>
> I've read the wiki on interfacing with external C code but didn't  
> fully follow.
>
> I'm currently using a ctypes wrapper for OpenCV from python and  
> doing some manipulation there, but I would like to chain together a  
> bunch of functions to run outside of the GIL on another core.
>
> From ctypes, I can pass a function a pointer to my IPLimage (the  
> opencv data).
>
> So I would imagine it would be something along the lines of:
>
> - write my functions in a pure C source file
> - declare extern functions in cython for the functions in the C source
> - compile the Cython file
> - compil the C source and compiled cython into the same pyd file
>
> The program flow would be like:
> - pass the pointer to the image to the cython function
> - forward that pointer to another function that executes with nogil  
> which calls the functions from the C library
> - return the pointer to the modified image to calling function
> - return that same pointer back to python.
>
>
> Is that about right? Or am I way off?

You can probably skip the "write my functions in a pure C source  
file" step and write them directly in Cython.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to