So I'm wrapping the OpenCV library in Cython and its coming along quite
nicely (thanks to everyone here for getting me up to speed!), but today I've
run across a strange issue where a wrapped function fails for certain values
of integer arguments, but a pure c implementation testing the same thing
with the same arguments works.
Here is the code excerpts im using:
#---------- .pyx ------------------#
def cvResize(cy_cvtypes.CvArr src, cy_cvtypes.CvArr dst, interpolation):
cdef c_cxcore.CvArr* c_src = src.handle()
cdef c_cxcore.CvArr* c_dst = dst.handle()
cdef int c_interpolation = interpolation
with nogil:
c_cv.cvResize(c_src, c_dst, c_interpolation)
#-------- c_cv.pxd -----------------#
cdef extern from "cv.h":
void cvResize(CvArr* src, CvArr* dst, int interpolation) nogil
#--------- test.py -----------------#
from cyopencv import *
if __name__=='__main__':
img = cvLoadImage('2.bmp')
img2 = cvCreateImage((640, 480), img.depth, img.nChannels)
cvResize(img, img2, 3)
img2.show()
#--------- pureC.c -----------#
#include "highgui.h"
#include "cv.h"
#include "cxcore.h"
#include "cxtypes.h"
int main(void)
{
IplImage* img, *img2;
img = cvLoadImage("2.bmp", 1);
img2 = cvCreateImage(cvSize(640, 480), img->depth, img->nChannels);
cvResize(img, img2, 3);
cvNamedWindow("test", 1);
cvShowImage("test", img2);
cvWaitKey(0);
cvDestroyAllWindows();
cvReleaseImage(&img);
cvReleaseImage(&img2);
}
valid integers for the argument 'interpolation' are 0, 1, 2, 3, 4 (as tested
with the C function). My Cython wrapper fails with a Python crash for
integer values 1 & 2. Values of 0,1,4 work properly and the output image
matches the output image of the C test function under the same conditions.
I've looked at the generated Cython code and everything seems in order, I
just can't think of what could be causing this behavior.
Any thoughts?
Cheers!
Chris
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev