使用emgucv的一个例外 [英] an exception in using emgucv

查看:93
本文介绍了使用emgucv的一个例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试在C#中使用emgucv。当使用以下代码时,我得到了异常'Emgu.CV.CvInvoke'的类型初始化程序引发了异常。请帮助我。我是这个领域的新人,如果有人给我更多的信息,我会非常感激。

Hello,I'm trying to use emgucv in C#.when using the following code,I got the exception "The type initializer for 'Emgu.CV.CvInvoke' threw an exception."please help me.as I'm new in this field,If any one gives me some more information,I would be so thankful.

using Emgu.CV.Structure;
using Emgu.CV;




IntPtr ima = Emgu.CV.CvInvoke.cvCreateImage(s, Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_16S, 10);

推荐答案

EMGU [ ^ ] < br $>


在该页面上,您将找到api文档和教程的链接。
EMGU [^]

On that page, you'll find a link to the api documentation AND a tutorial.


您好,



这是一个非常常见的问题,直到输出文件夹中没有正确的dll。 EMGU是opencv的包装器,这意味着你需要EMGU dll用于c#代码(已编写处理图像)和opencv中的dll。现在因为Opencv实际上是c ++,所以在c#中不能正常引用它们。



要查看底部错误弹出时丢失的文件是< b>操作:如果选择查看详细信息并使用左侧的小箭头展开 System.TypeInitializedException InnerException 会显示哪个dll。





方法1



现在最简单的方法是进入EMGU提取文件夹的 bin 文件夹并复制所有.dll文件,除了那些以EMGU并将它们粘贴到您的c#项目的 bin \Debug bin \ Release 文件夹中。



现在这会让你的发布变得更难,但是在Visual Studio中使项目变得更少了





方法2



更复杂但首选的是opencv_core220.dll和opencv_imgproc220.dll。这是加载和显示图像所需的两个最小项目。



右键单击解决方案资源管理器中的项目,然后选择添加>>现有项目... 或菜单项项目>添加现有项目



找到这两个文件并将它们添加到你的项目中。



现在s在解决方案资源管理器中选择它们并转到那里的属性。您需要将复制到输出目录选项更改为始终复制



这将复制每个dll编译项目的时间是发布或调试编译。





注意



两个建议的dll不会执行大多数更复杂的算法。您将收到无法加载cvextern.dll的错误,在这种情况下,您将不得不添加其他opencv dll的大部分。你将需要以下所有:



cudart64_32_16.dll

cufft64_32_16.dll

ZedGraph.dll


除非您使用CUDA,否则您将需要前两个ZedGraph用于绘制c#中的图形并且通常会自动复制。





如果您遇到困难,此处还有其他说明:

http://www.emgu.com/wiki/index.php/Download_And_Installation [ ^ ]



希望得到这个帮助,



保重

Chris
Hi,

This is a very common problem it is down to the correct dll's not being present in the output folder. EMGU is a wrapper for opencv which means you need the EMGU dll for the c# code (that has been written to deal with the images) and the dll from opencv. Now as Opencv is in fact c++ they can't be referenced as normally in c#.

To see what files are missing when the error pops up at the bottom are Actions: if you select View Details and expand System.TypeInitializedException using the small arrow to the left. The InnerException will show you which dll.


METHOD 1

Now the easy way is to go into "bin folder of the EMGU extraction folder and copy all of the .dll files except for those starting with EMGU and paste them into your bin\Debug or bin\Release folder of your c# project.

Now this make your release harder however makes the project less clutered in Visual Studio


METHOD 2

More complicated but preferred start with opencv_core220.dll and opencv_imgproc220.dll. These are the two minimal items you will require to load and display an image.

Right click on your project in solution explorer and select Add >> Existing Item... or menu item Project>Add Existing Item.

Find the two files and add them to your project.

Now select them within the solution explorer and go to there properties. You need to change the Copy to Output Directory option to Copy Always.

This will copy the dll every time you compile your project be it a release or debug compilation.


NOTE

The two suggested dll's will not do a majority of the more complex algorithms. You will get an error of Unable to load cvextern.dll in this case you will have to add a majority of the other opencv dll's. You will need all but:

cudart64_32_16.dll
cufft64_32_16.dll
ZedGraph.dll

Unless you are using CUDA then you will need the first two ZedGraph is used to plot graphs in c# and usually copied automatically anyway.


There are additional instructions here if you get stuck:
http://www.emgu.com/wiki/index.php/Download_And_Installation[^]

Hope this Help,

Take Care
Chris


我遇到了同样的问题。我发现该程序来自这里运行得很好,但是当我编写相同的程序并从最新版本下载opencv_XXXX242.dll文件时,它无法正常工作。然后我删除最新的一个,并添加程序的文件opencv_XXXX231.dll。它运行得很好。
I meet the same question. I find that the program from here runs very well, but when I write the same program and download opencv_XXXX242.dll files from the latest version, it can not work. Then I delete the latest one, and add the program's file,opencv_XXXX231.dll. It run very well.


这篇关于使用emgucv的一个例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆