【发布时间】:2015-11-27 17:00:26
【问题描述】:
我正在尝试从 WPF 中的视频中抓取所有帧并使用 emguCV 3.0。
但是 Retrive(frame, 0) 总是返回具有空位图的帧?
我猜这个问题出现在 Capture(string filename) 但我不知道为什么会这样。
谁能给我解释一下并给我一些解决方案? 谢谢。
这是我的代码
Capture _capture;
private void btnCut_Click(object sender, RoutedEventArgs e)
{
_capture = new Capture(@"H:\VisualC\HK5\LT Win\ForTesting\TestCutVideo\bin\Debug\Hay.mp4");
_capture.Start();
//bool isReading = true;
while (/*isReading*/_capture.Grab())
{
Mat frame = new Mat();
_capture.Retrieve(frame, 0);
if (frame != null)
{
imageArray.Add(frame);
}
}
//to Cut list of frames from video.
int start = 1, end = 10;
start = start * (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
end = end * (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
VideoWriter vw = new VideoWriter("test.mp4", 15, new System.Drawing.Size(400, 400), true);
for (int i = start; i <= end; i++)
{
vw.Write(imageArray[i]);
}
}
【问题讨论】: