I am writing a Python program that reads YV12 frame data from an IP camera created by Hikvision Ltd.
In the SDK, they provided a functional call that allows me to set up a callback to retrieve the frame data.
My callback function looks like this:
def py_fDecodeCallBack(lPort, pBuffer, lSize, pFrameInfo, lReserved1, lReserved2):
print "lPort: %r" % lPort
print "lSize: %r " % lSize
print pFrameInfo
print pBuffer
print "pFrame Info: %r " % pFrameInfo.nWidth
return 0
$ The pFramInfo structure is defined as follows:
class FRAME_INFO(Structure):
_fields_ =[
('nWidth', c_long),
('nHeight', c_long),
('nStamp', c_long),
('nType', c_long),
('nFrameRate', c_long),
('dwFrameNum', wintypes.DWORD)
]
$
I use the following code to configure the callback function:
FSETDECCALLBACK = WINFUNCTYPE(c_bool, c_long, POINTER(wintypes.BYTE), c_long, POINTER(FRAME_INFO), c_long, c_long)
fSetDecCallBack = FSETDECCALLBACK(py_fDecodeCallBack)
Then the callback function is called by the SDK and displays the following:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 313, in 'calling callback function'
lPort: 0
lSize: 1382400
<mytypes.LP_FRAME_INFO object at 0x03109CB0>
<wintypes2.LP_c_byte object at 0x03109D00>
File "C:\Users\Rex\workspace\iSentry\hcnetsdkhelper.py", line 76, in py_fDecodeCallBack
print "pFrame Info: %r " % pFrameInfo.nWidth
AttributeError: 'LP_FRAME_INFO' object has no attribute 'nWidth'
Simple types, such as c_long (lPort and lSize), read correctly, but there are no fields in the pFrameInfo structure that I defined. I cannot read pFrameInfo.nWidth since it said there is no such attribute ...
:
, dll ctypes. - google, , python.org http://bugs.python.org/issue5710, , , 2009 .
, , pFrameInfo dll, c_long, pFrameInfo, pFrameInfo? pFrameInfo c_long, byte by byte c_long. . , , ...