我有一個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