我需要的是Emgu.Cv.Mat
。由於我有一個Bitmap
我想將他的信息傳遞給這個Mat實例。當使用EmguCV構造Mat時System.AccessViolationException異常
這裏是我的代碼:
//the real file is not stored on the harddrive. this is for demonstration only.
Bitmap fileBmp = new Bitmap(@"C:\Users\my\Desktop\file1.PNG");
。
//generating an Image from it works pretty fine as well. Even displaying it works great.
Image<Bgr, Byte> image = new Image<Bgr, Byte>(fileBmp);
。
//But I'm not able to generate a Mat with it. Not using the Bitmap
Mat mat1 = new Mat(new int[] { fileBmp.Width, fileBmp.Height }, DepthType.Cv8S, fileBmp.GetHbitmap());
//... and not using the Image
Mat mat2 = new Mat(new int[] { fileBmp.Width, fileBmp.Height }, DepthType.Cv8S, image.Bitmap.GetHbitmap());
我不斷收到
System.AccessViolationException
如果我讀要麼mat1.Bitmap
財產或財產mat2.Bitmap
(所有其他屬性看起來很不錯)。 我的代碼有什麼問題?
任何建議如何使用EmguCv
將「圖形信息」傳遞給Mat
?
再一次:使用new Mat(@"C:\Users\my\Desktop\file1.PNG")
是不可能的,因爲位圖沒有存儲在硬盤上。