我想创建一个OpenCV的包装在C#中使用它。我使用这个链接作为参考的 drthitirat.wordpress/2013/06/06/use-opencv-c-codes-in-a-vc-project-solution-的创造 - 一个管理-CLR-包装/ 到目前为止,我已经创建了一个包含我的图像处理代码,一个C ++控制台应用程序。此外,我创建了一个C ++ / CLI类库中,我裹OpenCV的代码,但是当我尝试构建它,我得到了很多关于在C ++代码中使用OpenCV函数解析的外部错误的,我不知道如何解决它...任何想法如何解决这一问题?有没有在C#中使用C ++ OpenCV的代码更简单的,更简单的方法?我不想用Emgu或任何其他的包装,我的图像处理代码必须在C ++中。
I want to create an OpenCV wrapper to use it in C#. I am using this link as a reference drthitirat.wordpress/2013/06/06/use-opencv-c-codes-in-a-vc-project-solution-of-creating-a-managed-clr-wrapper/ So far I have created a C++ console application that contains my image processing code. Also I created a C++/CLI class library in which I wrapped the OpenCV code, but when i try to build it I get a lot of unresolved externals errors about OpenCV functions used in the C++ code and I don't know how to fix it... Any idea how to fix the problem? Is there a simpler, easier way of using C++ OpenCV code in C#? I don't want to use Emgu or any other wrapper, my image processing code has to be in C++.
推荐答案使用我如何解决了OpenCV的问题的Visual Studio 2012:
How I solved the problem with opencv using visual studio 2012:
备注答:我可以保证这个解决方案工作。我喜欢用模式检测和CAMSHIFT与OpenCV的2.4.2功能。
Remark A: I can assure that this solution worked. I used features like pattern detection and camshift with opencv 2.4.2.
备注乙:的另一个话题是究竟如何编组应。在简单数据类型的情况下,没有使用C ++ / CLI数据类型如UInt32的等等。毫无疑问,但问题是,如果你想通过更复杂的对象,如简历::垫不具有类型C ++ / CLI直接等同。在这种情况下,我对C ++ / CLI方提出这样的类的简化版本。
Remark B: Another topic is how exactly marshalling should be made. In case of simple data types, there is no doubt in using c++/cli data types like UInt32 etc. But the question is if you want to pass more sophisticated objects like cv::Mat which do not have types direct equivalent in c++/cli. In that case, I made simplified version of such classes on c++/cli side.
备注C:不要乱架构在不同的项目。如果您在使用例如。86,在所有项目后续
Remark C: Don't mess architecture in different projects. If you are using e.g. x86, be consequent in all projects.
备注D:实际上,在C#中使用C ++代码的问题有两种解决方案:我所描述的和直接呼叫到C ++托管代码在C#中使用动态的即时编组托管代码。主要有两大缺点:对即时编组需要时间和你真的不知道究竟是如何做到这一点的复杂数据类型(即,一切还有什么比int或字符串不同)之间。所以C ++ / CLI它确实是一个很好的选择,因为你可以混合托管和非托管代码。
Remark D: Practically, the problem using c++ code in c# has two solutions: the one I described and the direct calling to c++ unmanaged code from c# managed code using dynamic on-the-fly marshalling. There are two major disadvantages: on-the-fly marshalling takes time and you do not really know how exactly do this between complex data types (namely, everything what is different than int or string). So c++/cli it is really a good option because you are able to mix managed and unmanaged code.
备注E:这个解决方案是通用的,它不仅在OpenCV的计数。我成功地使用本作C ++ / CLI包装旋转阶段(机动设备),它只有C ++驱动程序和使用,在C#代码驱动程序。
Remark E: This solution is general, it does not count only in opencv. I successfully used this making c++/cli wrappers to rotation stages (motor devices) which only have c++ drivers and used that drivers in c# code.
关于备注C:使用的Dependency Walker像安装depends( HTTP: //www.dependencywalker/ ),看看哪些依赖是不相符的。
Regarding Remark C: Use a dependency walker like Depends (www.dependencywalker/) to see which dependencies are not consistent.
更多推荐
创建C ++ / CLI OpenCV的包装在C#中使用
发布评论