我有一个带有以下原型的回调:
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和restype之后,但是从不调用回调。我希望有人可以指出我可能出现的任何错误
答案 0 :(得分:0)
是的,我已经在底部解决了这个问题。对于使用Mightex相机的任何人的未来参考,似乎他们的回调需要附加到GUI。我将部分代码附加到Tkinter按钮,回调工作正常。