DecCBFun回调函数中使用如下代码函数,则可以快速返回np类型的BGR类型。进行opencv的处理。
def YV12ToBGR(pBuf,nSize,nHeigh,nWidth)
#pBuf,nSize,nHeigh,nWidth对于回调函数中的形参
YV12 = np.frombuffer(pBuf[0:nSize],dtype=np.uint8).reshape(int(nHeigh + nHeigh / 2),nWidth)
BGR = cv2.cvtColor(YV12, cv2.COLOR_YUV2BGR_YV12)
return BGR