1 | initial version |
Just for the sake of completion I'm adding this answer.
#include "opencv2/opencv.hpp"
int main(int, char**)
{
cv::Size szSize(600, 600);
uchar *b_Buffer = new uchar[szSize.width * szSize.height * 2];
cv::Mat mSrc(szSize,CV_8UC2, b_Buffer);
string binFile("dump1.yuv");
ifstream File_VideoFile;
File_VideoFile.open(binFile, ios::in | ios::binary);
if (!File_VideoFile.is_open())
{
std::cerr << "[ERROR] cannot open the YUV Input File " << binFile << endl;
std::cerr << std::endl;
assert(0);
}
File_VideoFile.read((char*)b_Buffer, sizeof(uchar)*szSize.width*szSize.height*2);
File_VideoFile.close();
cv::Mat mSrc_BGR(szSize, CV_8UC3);
cvtColor(mSrc, mSrc_BGR, COLOR_YUV2BGR_YUYV);
imshow("Image BGR", mSrc_BGR);
waitKey(0);
delete[] b_Buffer;
return 0;
}