我有一个C回调具有下列原型:ctypes的回调被忽略
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)
我再尝试实例化正确的ARG和restypes的功能之后的回调与
BUFCCDUSB_InstallFrameHooker(0, CMPFUNC): (frame_callback and cb for the respective callback codes)
连接,但回调不会被调用。我希望有人能指出我对任何可能的错误
你好frank_x,我想在python for mightex相机上做一些编程。你介意与我分享你的代码吗?我真的很感激它! – Gardener85