close

Emgu CV版本: libemgucv-windows-universal-cuda-3.0.0.2158

Visual Studio: 2010

image

加入參考, 瀏覽目錄 C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin

image

加入3個參考

Emgu.CV   Emgu.CV.UI      Emgu.Util

編譯出現錯誤表示找不到對應的DLL

image

image

1.加入系統變數 Emgu30

C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin

image

2.加入系統變數 Emgu_OpenCV

C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin\x64

image

3. 將上述兩個定義Emgu30和Emgu_OpenCV加入Path變數

%Emgu30%;%Emgu_OpenCV%;

image

加入namespace

1 using System.Threading; 2 using Emgu.CV; 3 using Emgu.CV.Structure; 4 using Emgu.CV.CvEnum;

人機介面如下

image

Mat

1 using (OpenFileDialog ofd = new OpenFileDialog()) 2 { 3 if (ofd.ShowDialog() == DialogResult.OK) 4 { 5 Mat inputImage = CvInvoke.Imread(ofd.FileName, LoadImageType.Unchanged); 6 CvInvoke.Imshow("IntPtr", inputImage); 7 } 8 }

Image<Bgr, Byte>

image

1 using (OpenFileDialog ofd = new OpenFileDialog()) 2 { 3 if (ofd.ShowDialog() == DialogResult.OK) 4 { 5 Image<Bgr, Byte> inputImage = new Image<Bgr, byte>(ofd.FileName); 6 CvInvoke.Imshow("Image<Bgr, Byte>", inputImage); 7 } 8 }

Image<Gray, byte>

image

彩色會自動轉灰階

1 using (OpenFileDialog ofd = new OpenFileDialog()) 2 { 3 if (ofd.ShowDialog() == DialogResult.OK) 4 { 5 Image<Gray, Byte> inputImage = new Image<Gray, byte>(ofd.FileName); 6 CvInvoke.Imshow("Image<Gray, Byte>", inputImage); 7 } 8 }

PictureBox to Image<Bgr, Byte>

image


Image<Bgr, byte>(640, 480, new Bgr(0, 255, 255)) to PictureBox

image

Image<Gray, byte>(640, 480, new Gray(i)) to PictureBox

image

灰階0->255

image

1 for (int i = 0; i < 256; i++) 2 { 3 Image<Gray, Byte> inputImage = new Image<Gray, byte>(640, 480, new Gray(i)); 4 pictureBox1.Image = inputImage.ToBitmap(); 5 this.Text = i.ToString(); 6 Application.DoEvents(); 7 Thread.Sleep(10); 8 }

Bitmap to PictureBox

image

範例程式

EmguVS2010LoadImage

參考資料

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(1) 人氣()