According to the docs,
http://opencv.willowgarage.com/wiki/CvReference#Sampling.2CInterpolationandGeometricalTransforms,
There are 4 possible values (you mention 5). Is that OpenCV
documentation dated? IMHO, you should use them. To expose these
constants in Cython code (likely in some pxd), you can do this:

cdef extern from ....:

    enum: CV_INTER_NN
    enum: CV_INTER_LINEAR
    enum: CV_INTER_AREA
    enum: CV_INTER_CUBIC



On Wed, May 27, 2009 at 12:57 AM, Chris Colbert <[email protected]> wrote:
> 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
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to