& # 39; Emgu.CV.Invoke& # 39;抛出异常
本文关键字:抛出异常 Invoke CV Emgu | 更新日期: 2023-09-27 18:05:33
我是一个相对较新的EmguCV,但我做了很多研究,阅读了一些教程,并通过这个网站寻找答案。所有其他有类似问题的人都被告知将未管理的dll添加到输出文件夹中。我已经这样做了,我仍然得到这个错误'Emgu.CV。Invoke抛出了一个异常。
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using AForge;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.VFW;
using System.Drawing.Imaging;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class SandBox : Form
{
private bool DeviceExist = false;
public VideoCaptureDevice FinalVideoSource;
public FilterInfoCollection VideoCaptureDevices;
private Capture capture;
private VideoWriter captureOutput;
private void FinalVideoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgseventArgs)
{
Bitmap image = (Bitmap)eventArgs.Frame.Clone();
image.RotateFlip(RotateFlipType.Rotate180FlipY);
pictureBox1.Image = image;
}
public SandBox()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = " ";
FPS.Text = " ";
try
{
VideoCaptureDevices = new FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
DeviceExist = true;
foreach (AForge.Video.DirectShow.FilterInfo VideoCaptureDevice in VideoCaptureDevices)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
}
comboBox1.SelectedIndex = 0;
}
catch (ApplicationException)
{
DeviceExist = false;
comboBox1.Items.Add("No device on your system");
}
}
private void Start_Click(object sender, EventArgs e)
{
FinalVideoSource = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
FinalVideoSource.NewFrame += new NewFrameEventHandler(FinalVideoSource_NewFrame);
FinalVideoSource.Start();
label1.Text = "Device running...";
Start.Enabled = false;
Stop.Enabled = true;
timer1.Enabled = true;
capture = new Capture();
captureOutput = new VideoWriter("test.avi", 30, 1280, 720, true);
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
captureOutput.WriteFrame(ImageFrame);
}
}
在capture = new Capture();
行抛出错误。我不知道这个项目出了什么问题。澄清一下,我只是使用EmguCV来录制视频,而不是在屏幕上显示。
Emgu.CV的类型初始化项。CvInvoke抛出了一个异常,这意味着EMGU。CV文件不被代码检测。这是由于系统依赖性。您需要进入visual studio中的配置管理器窗口,选择所需的平台,然后根据您的平台复制相应的DLL文件(x64的64位DLL文件和x86的32位DLL文件可以从emgu网站下载)。现在将其复制,不会出现类似emgu.cv.invoke的错误http://www.emgu.com/wiki/index.php/Setting_up_EMGU_C_Sharp