在 Emgu Cv 中写入视频时出错
我正在尝试使用 Emgu CV 录制从网络摄像头捕获的视频,但出现异常。
_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);
我收到“尝试除以零”。当我执行 captureOutput.WriteFrame(frame) 行时出现异常。
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.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 am getting an "Attempted to divide by zero." exception when I am executing captureOutput.WriteFrame(frame) line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用评论:
问题在于选择正确的编解码器进行录制。我将下面第 3 行的部分内容更改
为 -1:
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC)
。这为我提供了一个对话框,其中包含我的计算机上可用的编解码器列表。我选择了“未压缩”编解码器,视频已正确生成。
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.