2016-10-29 3 views
0

was ich brauche ist ein Emgu.Cv.Mat. Da ich eine Bitmap habe, möchte ich seine Informationen an diese Mat-Instanz weitergeben.System.AccessViolationException während Konstrukt Mat mit EmguCV

Hier ist mein Code:

//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()); 

Ich halte einen

System.AccessViolationException

bekommen Wenn ich entweder mat1.Bitmap Eigentum oder mat2.Bitmap Eigentum (alle anderen Eigenschaften suchen fein) lesen. error Was ist falsch an meinem Code?

Irgendwelche Vorschläge, wie ich die "grafischen Informationen" an Mat mit EmguCv weiterleiten kann?

Noch einmal: Verwendung new Mat(@"C:\Users\my\Desktop\file1.PNG") ist nicht möglich, weil die Bitmap nicht auf der Festplatte gespeichert ist.

Antwort

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

auch überprüfen, um sicherzustellen Sie für x64 kompilieren, wenn Sie EmguCV 3.1

verwenden
Verwandte Themen