非常非常基礎的說明
簡單講述如何在 Visual studio上 如何使用 EMGU
目前分為兩個步驟:
1. 下載 EMGU
2. 在Visual studio使用
下載 EMGU
EMGU的官網如下:
http://www.emgu.com/wiki/index.php/Main_Page
點選 Download Open Source Release 就可以下載 EMGU的 DLL檔案

接著點選想要的版本

下載後解壓縮內的 bin內有數個 dll 檔案

在Visual studio使用
在 VS 中選擇 C# 的 windows forms

將 EMGU加入參考 (範例中是使用 x64作為說明 )

加入參考的項目有:
Emgu.CV.UI 、Emgu.CV.UI.GL.dll 與 Emgu.CV.World.dll

在工具中選擇 選擇工具箱項目

接著 按下 預覽 並選擇 Emgu.CV.UI

點選

簡單畫一個 繪圖
在工具箱選擇 imageBox

在介面上畫入 imageBox 按鈕 與 textbox
然後程式碼如下
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.CvEnum;
using Emgu.CV;
using Emgu.CV.Structure;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
OpenFileDialog filename = new OpenFileDialog();
if (filename.ShowDialog() == DialogResult.OK)
{
textBox1.Text = filename.FileName;
}
}
private void TextBox1_TextChanged(object sender, EventArgs e)
{
Image<Bgr, byte> LoadImage = new Image<Bgr, byte>(textBox1.Text);
imageBox1.Image = LoadImage;
}
}
}

建置程式碼
然後將 剛剛 EMGU解壓縮的資料夾中
EMGU\Emgu.CV.Example\WebDynamicImage\Bin\x64 內的 cvextern.dll 放置到 執行檔旁邊


最後將軟體打開 按下按鈕選擇圖片 測試是否成功
