ok, maybe it wasnt your method. Something weird is going on, I removed the
inheritance from the class and it still compiled fine but drew errors when
importing from python.

Here are the relevant .pxd and .pxy files:


/********* .pxd ***********/
cimport c_cxcore
cimport c_highgui

cdef class CvArr:
    cdef c_cxcore.CvArr* handle(self)

cdef class IplImage:
    cdef c_cxcore.IplImage* thisptr
    cdef int needs_free
    cdef c_cxcore.CvArr* handle(self)


/******** .pxy ***********/

cimport c_cxcore
cimport c_highgui

cdef class CvArr:

    cdef c_cxcore.CvArr* handle(self):
        raise NotImplementedError

cdef class IplImage:

    cdef c_cxcore.CvArr* handle(self):
        return <c_cxcore.CvArr*>(self.thisptr)

/********** python import error **********/

>>> import cyopencv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cyopencv.pyx", line 2, in cyopencv (cyopencv.c:1062)
    from cy_cxcore import *
  File "cy_cvtypes.pxd", line 6, in cy_cxcore (cy_cxcore.c:821)

ValueError: cy_cvtypes.IplImage does not appear to be the correct type
object


/****** line 821 in cy_cxcore.c *********/

 /*--- Type import code ---*/
  __pyx_ptype_10cy_cvtypes_IplImage = __Pyx_ImportType("cy_cvtypes",
"IplImage", sizeof(struct __pyx_obj_10cy_cvtypes_IplImage)); if
(unlikely(!__pyx_ptype_10cy_cvtypes_IplImage)) {__pyx_filename = __pyx_f[1];
__pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

/******** line 1062 in cyopencv.c *************/

__pyx_1 = __Pyx_Import(__pyx_kp_cy_cxcore, ((PyObject *)__pyx_t_1)); if
(unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2;
__pyx_clineno = __LINE__; goto __pyx_L1_error;}





I don't know why its saying the object is unlikely the right type..

Chris




On Fri, May 22, 2009 at 11:58 AM, Chris Colbert <[email protected]> wrote:

> well, i tried your way Lisandro, and it compiled fine, but upon importing
> the module, it raised an error along the lines of "it appears IplImage is
> not of the right type".
>
> Dag's method works, but I'm still gonna try to find something cleaner.
>
> Chris
>
>
> On Fri, May 22, 2009 at 11:05 AM, Chris Colbert <[email protected]>wrote:
>
>> Ok, I get what your saying. that's a good idea and I think it's a little
>> cleaner than casting during the call.
>>
>> Thanks!
>>
>> Chris
>>
>>
>> On Fri, May 22, 2009 at 10:17 AM, Lisandro Dalcin <[email protected]>wrote:
>>
>>> On Fri, May 22, 2009 at 1:49 AM, Chris Colbert <[email protected]>
>>> wrote:
>>> > is 'handle()' a method that is called internally when passing extension
>>> > types as parameters?
>>> >
>>>
>>> No, it is a "polymorphic" method you have to manually call yourself.
>>> Instead of doing "self.thisptr", you do "self.handle()", just to extra
>>> parents.
>>>
>>> > I'm exposing a C function to Python as follows:
>>> >
>>> > def cvSomeFunction(CvArr image):  #image should be able to be CvArr
>>> IplImage
>>> > or CvMat
>>> >      c_lib.cvSomeFunction(image.thisptr)    # C func prototype = void
>>> > cvSomeFunction(CvArr* image) and image can be CvArr* IplImage* or
>>> CvMat*
>>> >
>>>
>>> If you use my trick, the functions should be implemented like this:
>>>
>>> def cvSomeFunction(CvArr image):
>>>    c_lib.cvSomeFunction(image.handle())
>>>
>>> Did you get the idea ?? Perhaps I'm not being clear enough.
>>>
>>> --
>>> 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
>>>
>>
>>
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to