我有以下原型的 ac 回调:
typedef void (* FrameDataCallBack)( TProcessedDataProperty* Attributes, unsigned char *BytePtr );
此回调函数是用户定义的,并通过以下函数附加到相机。
BUFCCDUSB_InstallFrameHooker( int FrameType, FrameDataCallBack FrameHooker );
我尝试过多种方式对回调进行原型设计:
1.
def frame_callback(attributes, frame):
for i in xrange(480*640): #Reads bytes and stores them in an array for future use
frame_buffer[i/640][i%640] = frame[i*config.bin_no]
print "hi"
CMPFUNC = ctypes.CFUNCTYPE(None,
ctypes.POINTER(TProcessedDataProperty),
ctypes.POINTER(ctypes.c_ubyte))(frame_callback)
2.
CMPFUNC = ctypes.CFUNCTYPE(None,
ctypes.POINTER(TProcessedDataProperty),
ctypes.POINTER(ctypes.c_ubyte))
@CMPFUNC
def frame_callback....
#function declaration
3.
CMPFUNC = ctypes.CFUNCTYPE(None,
ctypes.POINTER(TProcessedDataProperty),
ctypes.POINTER(ctypes.c_ubyte))
cbfunc = CMPFUNC(frame_callback)
然后我尝试附加回调
BUFCCDUSB_InstallFrameHooker(0, CMPFUNC): (frame_callback and cb for the respective callback codes)
在为函数实例化正确的 arg 和 restypes 之后,永远不会调用回调。我希望有人能指出我任何可能的错误