|
每个通道的数据应该是按行顺序存储的吧,我引用的应该没错吧
BVCU_Result CMLibBVCU::afterDecode(BVCU_HDialog hDialog, SAVCodec_Context* pCodec, SAV_Frame* pFrame)
{
//YUV转BGR,openCV默认BGR
unsigned char Y, U, V;
Mat frame(1080, 1920, CV_8UC3);
for (int i = 0; i < 1080; i++)
for (int j = 0; j < 1920; j++)
{
Y= *((*pFrame).ppData[0] + 1920 * i + j);
U= *((*pFrame).ppData[1] + 960 * (i / 2) + (j / 2));
V= *((*pFrame).ppData[2] + 960 * (i / 2) + (j / 2));
frame.at<Vec3b>(i, j)[0] = unsigned char(1.164 * Y + 2.017 * U - 276.8);
frame.at<Vec3b>(i, j)[1] = unsigned char(1.164 * Y - 0.392 * U - 0.823 * V + 135.6);
frame.at<Vec3b>(i, j)[2] = unsigned char(1.164 * Y + 1.596 * V - 222.9);
}
imshow("camera", frame);
waitKey(0);
return BVCU_RESULT_S_OK;
} |
|