2012-02-04 55 views
5

我已經寫了簡單的程序使用EmguCV在C#在VS 2010中打開圖像,並顯示圖像,但我得到以下異常:爲「Emgu.CV.CvInvoke」的類型初始值引發了異常

的'Emgu.CV.CvInvoke'的類型初始值設定項引發異常。

在行Image<Bgr, Byte> myimg = new Image<Bgr, Byte>(openfile.FileName);

這裏是我的代碼..

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using Emgu.CV; 
using Emgu.Util; 
using Emgu.CV.Structure; 

namespace imgdisplay2 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void imageBox1_Click(object sender, EventArgs e) 
     { 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      OpenFileDialog openfile = new OpenFileDialog(); 
      if (openfile.ShowDialog() == DialogResult.OK) 
      { 
       // imageBox1 =new Emgu.CV.UI.ImageBox() ; 
       Image<Bgr, Byte> myimg = new Image<Bgr, Byte>(openfile.FileName); 
       pictureBox1.Image = myimg.ToBitmap(); 
       //imageBox1.Image =myimg ; 
      } 
     } 

     private void pictureBox1_Click(object sender, EventArgs e) 
     { 
     } 
    } 
} 
+0

關於例外的任何細節? – Bort 2012-02-04 17:00:45

+1

發佈InnerException,這是重要的。 – 2012-02-04 22:18:13

回答

1

下面是我可以如何解決問題的方法: 將安裝了Emgu的「bin」文件夾下的x86(或64位OS上的x64)文件夾地址複製。我的是:C:\ Emgu \ emgucv-windows-universal-gpu 2.4.9.1847 \ bin \ x86

然後粘貼這個地址: 控制面板>系統>高級系統設置>環境變量>在系統變量中點擊「路徑」,然後點擊編輯>在該字符串的末尾添加分號,並在分號後面粘貼剛剛複製到剪貼板的地址>單擊確定。

相關問題