Python Cython-尝试访问指向结构的指针的内容时出错

Python Cython-尝试访问指向结构的指针的内容时出错,python,c,pointers,struct,cython,Python,C,Pointers,Struct,Cython,我在Cython有一个cdefed类,看起来非常类似于: cdef class AprilTagDetector: cdef capriltag.apriltag_detector_t* _apriltag_detector def __cinit__(self): self._apriltag_detector = capriltag.apriltag_detector_create(); # standard null checks

我在Cython有一个
cdef
ed类,看起来非常类似于:

cdef class AprilTagDetector:
    cdef capriltag.apriltag_detector_t* _apriltag_detector

    def __cinit__(self):
        self._apriltag_detector = capriltag.apriltag_detector_create();
        # standard null checks
    # standard __dealloc__(self) here

    property quad_decimate:
        def __get__(self):
            return self._apriltag_detector.quad_decimate
相应的
.pxd
文件如下所示:

cdef extern from "apriltag.h":
    # The detector itself
    ctypedef struct apriltag_detector_t:
        pass

    # Detector constructor and destructor
    apriltag_detector_t* apriltag_detector_create()
    void apriltag_detector_destroy(apriltag_detector_t* td);
问题是,当我编译这段代码时,它会抛出以下错误:

property quad_decimate:
    def __get__(self):
        return self._apriltag_detector.quad_decimate             ^
------------------------------------------------------------

apriltags.pyx:47:14: Cannot convert 'apriltag_detector_t *' to Python object

这是怎么回事?我还没能从Cython医生那里弄明白

谢天谢地,我是在与一位朋友在黑客空间进行这个项目时发现这个问题的。 问题出在
ctypedef struct apriltag\u detector\t
块中。 当我在块中编写
pass
时,我认为Cython会自动计算出结构的内部内容,并让我访问我需要的元素-这里是
quad\u decimate

不是这样。 要让Cython理解结构的内容,您必须告诉它结构中有什么:

ctypedef struct apriltag_detector_t:
    float quad_decimate