I'm learning OpenCV, in C++ but Something got wrong..
I want to imshow yuv file, but I got an error on my code.
code :
Mat img = imread("myimage.yuv"); imshow("img", img);
Does anyone know what's wrong with my code and how can I fix it?
I'm learning OpenCV, in C++ but Something got wrong..
I want to imshow yuv file, but I got an error on my code.
code :
Mat img = imread("myimage.yuv"); imshow("img", img);
Does anyone know what's wrong with my code and how can I fix it?
You need to open the file first :
FILE *YUV_FILE = fopen( "YourPAth\\YourFileName.yuv", "rb" );
create a pointer :
char *databuffer = new char[ frameWidth*frameHeight*ChannelCount];
Then read data using fread
to the pointer databuffer
Now you'll be able to create an opencv Mat
using :
cv::Mat OpencvImage(Size(frameWidth, frameHeight), CV_8UC3, databuffer, Mat::AUTO_STEP);