I should note in the last code example, I manually change the integer and
the recompile. i.e. the python arguments passed to the function are
irrelevant.
Chris

On Thu, May 28, 2009 at 1:00 AM, Chris Colbert <[email protected]> wrote:

> I think I'm starting to narrow it down.
>
> I made the following python extension module by hand and it works. I can
> pass any value (0, 1, 2, or 3) to the function exttest.test() in python and
> they all work properly.
>
> #------------- exttest.c ---------------------#
>
> #include "Python.h"
> #include "highgui.h"
> #include "cxcore.h"
> #include "cv.h"
>
> static PyObject* run_test(PyObject* self, PyObject* args)
> {
>     int val;
>     if (!PyArg_ParseTuple(args, "i", &val)){
>         return NULL;
>     }
>     IplImage* img = cvLoadImage("2.bmp", 1);
>     IplImage* img2 = cvCreateImage(cvSize(640, 480), img->depth,
> img->nChannels);
>     cvResize(img, img2, val);
>     cvNamedWindow("test", 1);
>     cvShowImage("test", img2);
>     cvWaitKey(0);
>     cvDestroyAllWindows();
>     cvReleaseImage(&img);
>     cvReleaseImage(&img2);
>     Py_RETURN_NONE;
> }
>
> static PyMethodDef exttestMethods[] =
> {{"test", run_test, METH_VARARGS, "some test"},{NULL, NULL, 0, NULL}};
>
> PyMODINIT_FUNC initexttest(void)
> {
>     (void) Py_InitModule("exttest", exttestMethods);
> }
>
>
>
>
> #------------------ setup.py build ---------------------#
> from distutils.core import setup, Extension
>
> library_dirs=["C:\\OpenCVsvn\\build\\lib"]
> include_dirs=["C:\\OpenCVsvn\\build\\include\\opencv"]
> libraries = ["highgui110", "cxcore110", "cv110"]
>
> module1 = Extension('exttest', sources = ['exttest.c'],
> libraries=libraries,
> library_dirs=library_dirs, include_dirs=include_dirs)
>
> setup (ext_modules = [module1])
>
>
>
>
> Now, If I go back to the Cython generated .c file and copy this into its
> body (removing all other code), and build the .c file with an equivalent
> setup.py  it still fails on integers 1 and 2 (but not 0 and 3)
>
> #------------ code substituted into cython c file -------------- #
>
> static PyObject *__pyx_pf_5cy_cv_cvResize(PyObject *__pyx_self, PyObject
> *__pyx_args, PyObject *__pyx_kwds)
> {
>     int val = 1;
>     IplImage* img = cvLoadImage("2.bmp", 1);
>     IplImage* img2 = cvCreateImage(cvSize(640, 480), img->depth,
> img->nChannels);
>     cvResize(img, img2, val);
>     cvNamedWindow("test", 1);
>     cvShowImage("test", img2);
>     cvWaitKey(0);
>     cvDestroyAllWindows();
>     cvReleaseImage(&img);
>     cvReleaseImage(&img2);
>     Py_RETURN_NONE;
> }
>
>
> So, I think I've ruled out a compiler issue. Any pointers on where to look
> now?
>
> Cheers!
>
> Chris
>
>
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to