Vb.net SystemAccessViolation将Drawing.Bitmap转换为Emgu.CV.Image

Vb.net SystemAccessViolation将Drawing.Bitmap转换为Emgu.CV.Image,vb.net,emgucv,Vb.net,Emgucv,我需要将Drawing.Bitmap(“\u MyBitmap”)转换为EmguCV.Image 为此,我使用以下代码: Dim nCVImage As New Emgu.CV.Image(Of Bgr, Byte)("c:\users\myuser\desktop\1.png") MsgBox("Width: " & nCVImage.Width)'this work fine!! :-) 'Now (after th

我需要将Drawing.Bitmap(“\u MyBitmap”)转换为EmguCV.Image

为此,我使用以下代码:

    Dim nCVImage As New Emgu.CV.Image(Of Bgr, Byte)("c:\users\myuser\desktop\1.png")

    MsgBox("Width: " & nCVImage.Width)'this work fine!! :-)

    'Now (after the messagebox), the error is shown.        

    Stop'this is just some Stop statement for me to see to which point VB.NET executes the code when OpenCV throws the message. Stop is not hit. This means that the error must have occured in the very first line already.


    Dim m As Mat = nCVImage.Mat

    Dim imagez0 As Image(Of Gray, Byte) = m.ToImage(Of Gray, Byte)
    Dim imagez1 As Image(Of Bgr, Byte) = m.ToImage(Of Bgr, Byte)
    Dim imagez2 As Image(Of Gray, Byte) = imagez0.Canny(150, 60)
但是,第一行已经引发异常“imageSize溢出”

_我的位图非常好。我可以在图片盒里展示。它的大小是1200 x 1000像素

有人看到我的错误了吗

谢谢大家!

找到了一个解决方案:

缺少“cvextern.dll”

我所做的就是下载

并按照建议进行安装

(不知道我是怎么到那里的)

我编译了以下文件:

C:\Emgu\emgucv windesktop 4.4.0.4099\Solution\Windows.Desktop\Emgu.CV.Example.sln

然后我将\x86\cvextern.dll复制到我的\Debug\x86文件夹中

此外,我还将我的项目升级到了framework 4.7.2,并使用了Nuget的Emug.CV v4.4.0.4099

不知道为什么它不会自动将cvextern.dll放入我的应用程序目录。
完全令人不安

IIRC中有一个重载,它接受一个包含数据字节的锯齿状数组,还有一个重载接受(宽度、高度、跨距、扫描0)。要使用后者,请参阅注释:(简而言之,从代码>图像获取IMADATA。Loopss,它包含您需要的属性。考虑到步幅,因为您正在创建特定类型的位图,所以可能需要转换)@ Jimi,我的方法有什么不对?我不记得超编代码> EGUG.CV.IMAGE()。接受源
System.Drawing.Bitmap
对象的构造函数。不过,您可以指定文件位置。@Jimi您的意思是这样吗?将nCVImage设置为新的Emgu.CV.Image(Bgr,Byte)(“c:\users\myuser\desktop\1.png”),我这样问是因为它会抛出相同的错误。@Jimi实际上,这很奇怪。我在帖子中增加了一些观察。我很确定错误发生在第一行,但我不知道为什么或者哪个,因为图像似乎加载得很好。