close
Emgu CV版本: libemgucv-windows-universal-cuda-3.0.0.2158
Visual Studio: 2010
加入參考, 瀏覽目錄 C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin
加入3個參考
Emgu.CV Emgu.CV.UI Emgu.Util
編譯出現錯誤表示找不到對應的DLL
1.加入系統變數 Emgu30
C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin
2.加入系統變數 Emgu_OpenCV
C:\Emgu\emgucv-windows-universal-cuda 3.0.0.2158\bin\x64
3. 將上述兩個定義Emgu30和Emgu_OpenCV加入Path變數
%Emgu30%;%Emgu_OpenCV%;
加入namespace
1 using System.Threading; 2 using Emgu.CV; 3 using Emgu.CV.Structure; 4 using Emgu.CV.CvEnum;
人機介面如下
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>
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>
彩色會自動轉灰階
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<Bgr, byte>(640, 480, new Bgr(0, 255, 255)) to PictureBox
Image<Gray, byte>(640, 480, new Gray(i)) to PictureBox
灰階0->255
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
範例程式
參考資料
全站熱搜
留言列表