【发布时间】:2016-10-29 15:16:47
【问题描述】:
我需要的是Emgu.Cv.Mat。由于我有一个Bitmap,我想将他的信息传递给这个 Mat 实例。
这是我的代码:
//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")。
【问题讨论】:
标签: c# emgucv access-violation