2016-10-29 19 views
0

私が必要とするものは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()); 

私はmat1.Bitmapプロパティまたはmat2.Bitmap財産(ファイン探して他のすべてのプロパティ)のいずれかを読めば

System.AccessViolationException

を得続けます。 error私のコードで何が問題になっていますか?

EmguCvを使用してMatに「グラフィック情報」を渡す方法を教えてください。

もう一度:ビットマップがハードドライブに格納されていないため、new Mat(@"C:\Users\my\Desktop\file1.PNG")を使用することはできません。

答えて

2
Image<Bgr, Byte> image = new Image<Bgr, Byte>(fileBmp); 
Mat mat1 = image.Mat; 
0

また、あなたがEmguCV 3.1

を使用している場合は、x64の用にコンパイルされていることを確認するチェック
関連する問題