【问题标题】:System.AccessViolationException while construct Mat using EmguCV使用 EmguCV 构造 Mat 时出现 System.AccessViolationException
【发布时间】: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


    【解决方案1】:
    Image<Bgr, Byte> image = new Image<Bgr, Byte>(fileBmp);
    Mat mat1 = image.Mat;
    

    【讨论】:

      【解决方案2】:

      如果您使用 EmguCV 3.1,还要检查以确保您正在为 x64 编译

      【讨论】:

        猜你喜欢
        • 2018-06-21
        • 2011-01-22
        • 2018-05-26
        • 1970-01-01
        • 2012-09-10
        • 2020-05-14
        • 1970-01-01
        • 2015-08-24
        • 2021-09-11
        相关资源
        最近更新 更多