casper casper - 22 days ago 4x
C++ Question

Adding my own function to 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

, in which I placed the code for this new function. Next, I went to
and I added the appropriate export header to
. Finally, I rebuilt the
project in the OpenCV source code using Visual Studio 2010. Everything builds fine, and generates the
, and
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
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


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


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