There is a problem with your code as far as I can see, that is process frame is attached to the application.idle
event.
So when ever the application is idle this function is called and a frame is grabbed from the video source.
Now if we consider your ProcessFrame
Function ,it just reinitializes the VideoWriter
and writes a frame(current frame) in the video and that is why you only get a single frame in the output video.
So ideally your ProcessFrame
should look something like this
public void ProcessFrame(object sender, EventArgs e)
{
frame = _capture.QueryFrame();
imageBox1.Image = frame;
VideoW.WriteFrame(frame);
}
and the initialization of the VideoW
variable ie, this underlying code.
VideoW = new VideoWriter(@"temp.avi",
CvInvoke.CV_FOURCC('M', 'P', '4', '2'),
(Convert.ToInt32(upDownFPS.Value)),
frame.Width,
frame.Height,
true);
It should be placed outside ideally in the constructor
or where you have initilized other variables(_capture
variables etc.)
check this tutorial for more about reading and writing video files in Emgucv.
Hoping this helps.