[英]Emgu CV can't play video
我无法使用Emgu CV播放视频
显示错误
无法从184.avi创建捕获
这是代码:
public partial class Form1 : Form
{
//Set the name of pop-up window
String winname = "First Window";
Timer My_Time = new Timer();
int FPS=30;
Capture _capture;
public Form1()
{
InitializeComponent();
//Frame Rate
My_Timer.Interval = 1000 / FPS;
My_Timer.Tick += new EventHandler(My_Timer_Tick);
My_Timer.Start();
_capture = new Capture("184.avi"); // Error this line
}
private void My_Timer_Tick(object sender, EventArgs e)
{
imageBox.Image = _capture.QueryFrame().ToBitmap();
}
我使用Windows 8 x64并安装emgucv-windows-universal-cuda 2.4.10.1940
它在bin中没有opencv_ffmpeg.dll
。 因此,我安装了opencv-2.4.11并从OpenCV bin复制所有dll,以粘贴到我的项目中的Debug中。 我也将184.avi粘贴到Debug。 但是当我运行它时会显示这样的错误。 如何使用Emgu CV播放视频?
您的代码工作正常。 我认为问题在于您尚未将视频文件导入Visual Studio。 因此,请尝试将视频文件导入Visual Studio,并将属性设置为始终复制。 您可以在下面看到我已导入A.avi文件并将其属性设置为始终复制。
并认为您可以只使用imageBox.Image = _capture.QueryFrame();
而不是imageBox.Image = _capture.QueryFrame().ToBitmap();
因为您不需要使用ImageBox转换为位图。
我使用的代码与您的相同。
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using Emgu.CV.Features2D;
using Emgu.CV.Util;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{//Set the name of pop-up window
String winname = "First Window";
Timer My_Time = new Timer();
int FPS = 30;
Capture _capture;
public Form1()
{
InitializeComponent();
//Frame Rate
My_Time.Interval = 1000 / FPS;
My_Time.Tick += new EventHandler(My_Timer_Tick);
My_Time.Start();
_capture = new Capture("A.avi"); // Error this line
}
private void My_Timer_Tick(object sender, EventArgs e)
{
imageBox.Image = _capture.QueryFrame();
}
}
}
您可以提供完整路径,而不仅仅是文件名。
您没有将视频文件与程序exe放在同一文件夹中。 如果将视频文件放置在程序exe的旁边,则它也应该起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.