'I', 'Y', 'U', 'V' exception
Hello, I am recording video using IYUV codec. It is present in my system, because i can see it when using -1 for FOURCC
But first time i want to record frame i have an exception
This is happening only at first frame and only when i run it in Visual Studio (2015). If i press "Continue" everything is going well. After this recording is going without any problems. If i run application outside of Visual Studio nothing visible is happening.
I don`t think, what it is normal behavior. Can you help me please, what i am doing wrong and how to fix it.
I am using binaries, compiled myself in VS2015 from opencv-3.1.0 source. Maybe i need to configure "cmake" or VS project in special way?
source code
unsigned char* frame;//rgb raw data
int width = 800;
int height= 400;
Size frameSize(width, height);
VideoWriter recorder(name.toStdString(), CV_FOURCC('I', 'Y', 'U', 'V'), 20, frameSize, true);
Mat _frame(frameSize, CV_8UC3);
_frame.data = frame;
_recorder.write(_frame); <-line of exception
_recorder.release();
UPDATE
The same is happening during playback, using VideoCapture
That is probably because the first frame is grabbed somehow and is not correct yet. Simply said, most software solves this by skipping the first few frames then start to record.
@StevenPuttemans Frame is correct. So, you advice is "ignore it"?
I'm agree StevenPuttemans. After this please read your prev post http://answers.opencv.org/question/10...
_frame.data = frame;
Mat _frame(frameSize,CV_8UC3,(void*)frame); //build a Mat over user allocated data
Finally use Mat over user allocated data with care if producer process can change the memory while any OpenCV process is changing too or it's doing any stuff
@pklab The reason i started this question, you was not able to help me in my previous one.It is simplified version. Only one question.But i see you doing the same. I am asking about shape, you answering about color. :) I have exception on first frame because of "this is NOT safe@"? And i do not agree with StevenPuttemans. I was expected to have answer "ignore it" from JavaScript programmer, but not from c++. Sorry.
@Mikl I did not say you need to ignore it. But it is a fact that hardware producers tend to place in the manual that the first 1-3 frames are actually initialisation frames, and can thus contain rubbish. That is why people tend to throw away the first few frames in a robust setup ...
@StevenPuttemans You mean throw away because of content, but not wrong data format? It this case you are right. Sorry for misunderstanding. It can be garbage on a screen on first frames. Not really worries me now. I need to start recording at least something first.