加入參考:

C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\Emgu.CV.dll

A wrapper for the OpenCV library (opencv_core, opencv_calib3d, opencv_contrib, opencv_features2d, opencv_highgui, opencv_imgproc, opencv_objdetect and opencv_video)

image

image

接著仿照上步驟也加入Emgu.Util.dll

image

加入以下三個namespace

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;

image

加入System.Drawing

image

image

namespace HelloWorld
{
     class Program
     {
         static void Main(string[] args)
         {
             String win1 = "Emgu Window"; //The name of the window
             CvInvoke.cvNamedWindow(win1); //Create the window using the specific name

            Image<Bgr, Byte> img = new Image<Bgr, byte>(400, 200, new Bgr(0, 255, 255)); //Create an image of 400x200 of Yellow color
             MCvFont f = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0); //Create the font

            img.Draw("Hello, world", ref f, new System.Drawing.Point(10, 80), new Bgr(0, 255, 0)); //Draw "Hello, world." on the image using the specific font

            // 畫個圓
             System.Drawing.PointF center = new System.Drawing.PointF(300,70);
             CircleF cir = new CircleF(center, 25);
             img.Draw(cir, new Bgr(255, 0, 0), 2);
 
             CvInvoke.cvShowImage(win1, img); //Show the image
             CvInvoke.cvWaitKey(0);  //Wait for the key pressing event
             CvInvoke.cvDestroyWindow(win1); //Destory the window

        }
     }
}

image

Emgu.CV.CvInvoke' 的型別初始設定式發生例外狀況

定義Emgu變數名稱

image

定義EmguOpenCV變數名稱

image

將Emgu和EmguOpenCV加入系統變數Path之中

image


image

在Visual Studio 2008環境下, 選擇x86或x64會發生未處理意外錯誤訊息

image

但是如果直接點選執行檔案執行卻是正常的耶 !!!

image

如果要在Visual Studio 2008環境下, 避免跳出上述錯誤訊息, 建議使用預設AnyCPU就可以!

很奇怪的現象@@

image

sample code

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

    天天向上

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