what I need is an Emgu.Cv.Mat
. Due to I have an Bitmap
I want to pass his information to this Mat instance.
Here is my 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());
I keep getting an
System.AccessViolationException
If I read either mat1.Bitmap
property or mat2.Bitmap
property (all other properties looking fine). What is wrong with my code?
Any suggestions how I can pass the "graphic information" to an Mat
using EmguCv
?
One again: using new Mat(@"C:\Users\my\Desktop\file1.PNG")
is not possible due to the bitmap is not stored on the hard drive.
Image<Bgr, Byte> image = new Image<Bgr, Byte>(fileBmp);
Mat mat1 = image.Mat;