向OpenCV添加我自己的函数 [英] Adding my own function to OpenCV

查看:172
本文介绍了向OpenCV添加我自己的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加一个新的方法来计算连接的组件到OpenCV 2.4.4在我自己的项目中使用。我已经有来自此问题的函数代码(感谢 jason ),我浏览了补丁,我找到了代码和标题。



我做的是添加一个新的在 C:\opencv\modules\imgproc\src 中的文件 connectedcomponents.cpp 这个新函数的代码。接下来,我去了 C:\opencv\modules\imgproc\include\opencv2\imgproc ,我添加了适当的导出标题到 imgproc.hpp 。最后,我使用Visual Studio 2010在OpenCV源代码中重建了 opencv_imgproc 项目。一切正常,并生成 opencv_imgproc244.dll opencv_imgproc244.lib opencv_imgproc244.exp



现在,我将这些文件(除了.exp,我不能找到它应该去哪里)复制到我现有的OpenCV目录并替换旧的文件。当我现在尝试构建我自己的项目,一切仍然构建良好,但我无法从这里访问新的方法。我包括 #include< opencv2 / imgproc / imgproc.hpp> ,从这里我可以访问文件中的所有其他方法,除了我想要的新。



事实上,一切都编译,但方法没有暴露导致我认为有一些其他文件,我应该改变,但是,由于缺乏



额外的信息:
我使用Visual Studio 2010,OpenCV 2.4.4和构建的OpenCV与CMake 2.8.10.2
我知道有一些库,如 cvBlobsLib 计算连接组件,我已经成功地在我的项目中使用这些。但是,我想要一个更快和更新的解决方案(cvBlobsLib仍然使用旧的IplImage)。

解决方案

今天早上用一双新鲜的眼睛,我立刻发现了我的错误。

\\ imgproc\include\opencv2\imgproc\imgproc.hpp ,



但我应该做的也将其添加到



C:\opencv\build\include\opencv2\imgproc\imgproc .hpp



,因为这是使用OpenCV的任何项目包含的文件。一切都按计划现在。


I need to add a new method that computes connected components to OpenCV 2.4.4 to use in one of my own projects. I already have the code for the function from this question (Thanks to jason), I navigated my way to the patch where I found both the code and the header.

What I did was to add a new file connectedcomponents.cpp in C:\opencv\modules\imgproc\src, in which I placed the code for this new function. Next, I went to C:\opencv\modules\imgproc\include\opencv2\imgproc and I added the appropriate export header to imgproc.hpp. Finally, I rebuilt the opencv_imgproc project in the OpenCV source code using Visual Studio 2010. Everything builds fine, and generates the opencv_imgproc244.dll, opencv_imgproc244.lib, and opencv_imgproc244.exp files for me.

Now, I copy these files (except for the .exp, where I can't find where it should go?) into my existing OpenCV directory and replace the old files. When I now try to build my own project, everything still builds fine, but I cannot access the new method from here. I include #include <opencv2/imgproc/imgproc.hpp>, and from here I can access all the other methods in the file, except for the new one that I want.

The fact that everything compiles but that the method is not exposed leads me to think there is some other file that I should have changed as well, however, due to lack of experience I do not know where or what this file could be.

Extra information: I am using Visual Studio 2010, OpenCV 2.4.4 and built OpenCV with CMake 2.8.10.2 I am aware that there are libaries such as cvBlobsLib that compute connected components, and I have successfully used these in my project. However, I want a faster and more recent solution (cvBlobsLib still uses the old IplImage).

解决方案

So after looking at the problem with a fresh pair of eyes this morning, I immediately spotted my mistake. What I originally did was to add the new function's header code in

C:\opencv\modules\imgproc\include\opencv2\imgproc\imgproc.hpp,

but what I should've done is to also add it to

C:\opencv\build\include\opencv2\imgproc\imgproc.hpp,

because this is the file that is included by any project that uses OpenCV. Everything works as planned now.

这篇关于向OpenCV添加我自己的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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