I am trying to record a video captured from a webcam using Emgu CV but I a, getting an exception.
_capture = new Capture(0);
_capture.QueryFrame();
captureOutput = new VideoWriter(@"output.avi",
(int)_capture.GetCaptureProperty(Emgu.CV.CvEnu开发者_StackOverflowm.CAP_PROP.CV_CAP_PROP_FOURCC),
(int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS),
(int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH),
(int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT),
true);
Image<Bgr, Byte> frame = _capture.QueryFrame();
captureOutput.WriteFrame(frame);
I am getting an "Attempted to divide by zero." exception when I am executing captureOutput.WriteFrame(frame) line.
Cite from Comment:
The issue was with the selecting the proper codec to record. I changed part of line 3 below:
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC)
with -1.
This provided me with a dialog box with the list of codec available on my machine. I selected "Uncompressed" codec and the video was properly generated.
精彩评论