Here's how mine was added.
- Create a new folder in opencv_contrib/modules with the name of your new module.
- Add a file CmakeLists.txt
- To CMakeLists.txt make the first line: set(the_description "Descripton here")
- To CMakeLists.txt make the second line: set(OPENCV_MODULE_IS_PART_OF_WORLD OFF) or ON, if you want it included in Opencv_contrib_world
- The third line is: ocv_define_module(name dependencies WRAP python) name is the name of your module, and dependencies is the name of all the modules that must be compiled before your module is. ex: opencv_core opencv_imgproc opencv_calib3d....
- In the folder of your module, add folders include and src.
- Copy the existing .hpp and .cpp files from an existing module (I used saliency) and replace all the parts that actually do something with your own code.
Now, when you run cmake again, it should find your module and include it. The appropriate files are generated and everything works.