【发布时间】:2020-05-09 19:12:05
【问题描述】:
我在 Visual Studio 2019 和 emgucv 3.3.0.2824 中使用。 在这个版本的 emgucv 中,我找不到光流算法。我知道在 emgucv 2.4.9.1847 版本中有opticalflow.hs 函数。但在我的版本中,我没有成功使用光流算法。在我的代码中,我将视频分割成帧并将每一帧转换为灰度。现在我想将这些帧用于光流算法。这样我的输出将是一个灰度视频,而我正在移动的对象将被标记为红色或绿色方块。
提前感谢任何可以提供帮助的人。
这是代码(在私有 async void ReadAllFrames() func 中):
private async void ReadAllFrames()
{
Mat m = new Mat();
//read all the frames
while (isReadingFrames == true && FrameNo < TotalFrame)
{
FrameNo += Convert.ToInt16(numericUpDown1.Value);
capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames, FrameNo);
capture.Read(m);//read the frame that we choose in the upper line
pictureBox2.Image = m.Bitmap;
Bitmap img = null;
if (FrameNo < TotalFrame)
{
img = new Bitmap(pictureBox2.Image);
}
if (FrameNo < TotalFrame)
{
imgInput = new Image<Bgr, byte>(m.Bitmap);
Image<Gray, byte> imgOutput =
new Image<Gray, byte>(m.Bitmap.Width, m.Bitmap.Height, new Gray(0));
imgOutput = imgInput.Convert<Gray, byte>();
pictureBox3.Image = imgOutput.Bitmap;
await Task.Delay(1000 / Convert.ToInt16(Fps));
label1.Text = FrameNo.ToString() + "/" + TotalFrame.ToString();
}
}
}
【问题讨论】:
标签: c# emgucv opticalflow