gpt4 book ai didi

c# - Emgu CV无法播放视频

转载 作者:太空宇宙 更新时间:2023-11-03 21:53:25 26 4
gpt4 key购买 nike

我无法使用 Emgu CV 播放视频

显示错误

Unable to create capture from 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 文件并将其属性设置为始终复制。

enter image description here

并且认为您可以只使用 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();
}
}
}

关于c# - Emgu CV无法播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29058980/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com