Error recording video in Emgu Cv

I am trying to record a video captured from a webcam using Emgu CV, but I am getting an exception.

_capture = new Capture(0);
_capture.QueryFrame();
captureOutput = new VideoWriter(@"output.avi",
                                (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.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 get "Attempt to divide by zero." an exception when I execute the line captureOutput.WriteFrame (frame).

+3
source share
1 answer

Cite from Comment:

The problem was choosing the right codec for recording. I changed part of line 3 below:

_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC) s -1.

This provided me with a dialog box listing the available codecs on my machine. I chose the "Uncompressed" codec, and the video was correctly generated.

+1
source

Source: https://habr.com/ru/post/1754930/


All Articles