我正在 Windows 7 32 位操作系统上处理 Emgu cv,并且发生 System.TypeInitializationException 错误,我尝试了所有解决方案;当我运行 Emgu 附带的示例时,没关系,但是当我创建自己的项目时,会发生错误。
这是我的代码;
using System;
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.Structure;
using Emgu.Util;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Capture cap;
private bool capinpro;
public Form1()
{
InitializeComponent();
}
private void processframe(object o, EventArgs e)
{
Image<Bgr, byte> img = cap.QueryFrame();
imageBox1.Image = img;
}
private void button1_Click(object sender, EventArgs e)
{
if(cap!=null)
{
try
{
if (capinpro)
{
Application.Idle += processframe;
//i have also tried cap.start();
}
else
{
Application.Idle -= processframe;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
cap= new Capure();
}
}
}
}