My call in c++:
long g_nPort;
cv::Mat g_BGRImage;
void CALLBACK DecCBFun(long nPort, char* pBuf, long nSize, FRAME_INFO* pFrameInfo, long nUser, long nReserved2)
{
if(pFrameInfo->nType == T_YV12)
{
if(g_BGRImage.empty())
{
g_BGRImage.create(pFrameInfo->nHeight, pFrameInfo->nWidth, CV_8UC3);
}
cv::Mat YUVImage(pFrameInfo->nHeight + pFrameInfo->nHeight/2, pFrameInfo->nWidth, CV_8UC1, (unsigned char*)pBuf);
cvtColor(YUVImage, g_BGRImage, cv::COLOR_YUV2BGR_YV12);
imshow("RGBImage", g_BGRImage);
cv::waitKey(15);
YUVImage.~Mat();
}
}
I want to use pyOpencv to achieve the same function, what should I do?
The parameter pBuf is the data stream returned by yv12;
My python call:
DECODECALLBACK = CFUNCTYPE(None,c_long,c_char_p,c_long,POINTER(FRAME_INFO),c_long,c_long)
@DECODECALLBACK
def g_decode_callback (nPort:c_long, pBuf:c_char_p, nSize:c_long, pFrameInfo:POINTER(FRAME_INFO), nUser:c_long, nReserved2:c_long):
frameInfo = pFrameInfo.contents
#YU12
if frameInfo.nType == T_YV12:
srcImg = np.zeros((frameInfo.nHeight,frameInfo.nWidth,3),dtype=np.uint8)
# print(srcImg)
return 0