"You can probably skip the "write my functions in a pure C source
file" step and write them directly in Cython.
- Robert"
i tried doing that today and was running into boat loads of trouble
resolving the IplImage data type and header dependencies.
This is actually turning out to be quite difficult.
The C function I am testing is this:
#include "highgui.h"
int test(char* file){
IplImage* img = cvLoadImage(file, 1);
cvNamedWindow("Test", CV_WINDOW_AUTOSIZE);
cvShowImage("Test", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Test");
}
my equivalent (and horribly wrong) cython implementation is this:
cdef extern from "cxtypes.h":
ctypedef struct IplImage:
pass
cdef extern from "highgui.h":
cdef IplImage* cvLoadImage(char* file, int iscolor)
cdef int cvNamedWindow(char* name, int flag)
cdef void cvShowImage(char* name, IplImage* img)
cdef int cvWaitKey(int delay)
cdef int test(char* file):
cdef IplImage* img = cvLoadImage(file, 1)
cvNamedWindow("Test", 1)
cvShowImage("Test", img)
cvWaitKey(0)
return 0
def myinterface(char* file):
test(file)
and i'm compiling with this command on mingw:
gcc -shared -fPIC -fwrapv -O2 -fno-strict-aliasing -IC:\Python25\include
-IC:\OpenCV\cxcore\include -IC:\OpenCV\otherlibs\highgui -LC:\OpenCV\lib -o
opencvcython.pyd opencvcython.c -lhighgui -lcxcore
and i get all sorts of undefined _pyobject references.
the main reason i'm doing all of this is so i can chain together a bunch of
calls that can run outside of the gil. I don't mind writing the functions in
C if i have to. In fact, i compiled the intial C code into a dll and called
it from ctypes without trouble.
any ideas to make this not-broke?
Thanks for the help!
Chris
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev