c++的 unsigned char指针,python格式为:POINTER(c_char)
ok的项目:百度网盘里,HikSDKyv12View
fRealDataCallBack_V30 = REALDATACALLBACK(_fRealDataCallBack_V30)
DECCALLBACK = CFUNCTYPE(None, c_long, POINTER(c_char), FRAME_INFO, c_long, c_long)
def _fDecCallBack(nPort, pBuf, nSize, pFrameInfo, nReserved1, nReserved2):
print(nPort, nSize, pFrameInfo.nWidth)
fDecCallBack = DECCALLBACK(_fDecCallBack)
DISPLAYCALLBACK = CFUNCTYPE(None, c_long, POINTER(c_char), c_long, c_long, c_long, c_long, c_long, c_long)
def _fDisplayCallBack(nPort, pBuf, nSize, nWidth, nHeight, nStamp, nType, nReserved):
print(nPort, nSize, nWidth, nHeight, nStamp, nType)
bbb=string_at(pBuf,nSize)
height=1080
width=1920
nparr = np.fromstring(bbb, np.uint8)
img = nparr.reshape(height* 3 // 2, width)
img2=cv2.cvtColor(img,cv2.COLOR_YUV2BGR_YV12)
# yu12 = cv2.cvtColor(img2, cv2.COLOR_BGR2YUV_YV12)
# print("time",time.time()-start)
cv2.imshow("sadf",img2)
cv2.waitKey(1)
fDisplayCallBack = DISPLAYCALLBACK(_fDisplayCallBack)
|