Dag,
I've listed the code below and added the memory cleanup to the Cython file.
Behavior is the same.
#-------the pure C code which doesnt crash-----------#
#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, CV_INTER_LINEAR);
cvNamedWindow("test", 1);
cvShowImage("test", img2);
cvWaitKey(0);
cvDestroyAllWindows();
cvReleaseImage(&img);
cvReleaseImage(&img2);
}
#-------the corresponding "identical" Cython file which does crash:-------#
cimport c_cxcore
cimport c_highgui
cimport c_cv
cimport c_constants
cdef tester():
cdef c_cxcore.IplImage* img
cdef c_cxcore.IplImage* img2
img = c_highgui.cvLoadImage("2.bmp", 1)
img2 = c_cxcore.cvCreateImage(c_cxcore.cvSize(640, 480), img.depth,
img.nChannels)
c_cv.cvResize(img, img2, c_constants.CV_INTER_LINEAR)
c_highgui.cvNamedWindow("test", 1)
c_highgui.cvShowImage("test", img2)
c_highgui.cvWaitKey(0)
c_highgui.cvDestroyAllWindows()
c_cxcore.cvReleaseImage(&img)
c_cxcore.cvReleaseImage(&img2)
def test():
tester()
#--------- Cython Generated C - Code (implementation only)---------------#
#include "cxtypes.h"
#include "cxcore.h"
#include "highgui.h"
#include "cv.h"
#include "cvtypes.h"
/* Implementation of purecythontest */
static char __pyx_k___main__[] = "__main__";
static PyObject *__pyx_kp___main__;
static char __pyx_k_1[] = "2.bmp";
static char __pyx_k_2[] = "test";
static char __pyx_k_3[] = "test";
static PyObject *__pyx_f_14purecythontest_tester(void) {
IplImage *__pyx_v_img;
IplImage *__pyx_v_img2;
PyObject *__pyx_r = NULL;
__Pyx_SetupRefcountContext("tester");
__pyx_v_img = cvLoadImage(__pyx_k_1, 1);
__pyx_v_img2 = cvCreateImage(cvSize(640, 480), __pyx_v_img->depth,
__pyx_v_img->nChannels);
cvResize(__pyx_v_img, __pyx_v_img2, CV_INTER_LINEAR);
cvNamedWindow(__pyx_k_2, 1);
cvShowImage(__pyx_k_3, __pyx_v_img2);
cvWaitKey(0);
cvDestroyAllWindows();
cvReleaseImage((&__pyx_v_img));
cvReleaseImage((&__pyx_v_img2));
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_FinishRefcountContext();
return __pyx_r;
}
To me, the two C files look equivalent. Do you notice anything out of the
ordinary?
Cheers!
Chris
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev