Ask Your Question

Add your own module in opencv

asked 2017-02-05 13:54:12 -0500

LBerger gravatar image

Hi there,

You have your applications and you want to add your own module in opencv without a pull request how do you manage it?

  1. modify all make files
  2. add your own module in your repo opencv_contrib
  3. ...


n. add variables in Opencv cmakelist : OPENCV_MYOWN_MODULES_PATH

Ideas are welcome

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-02-05 14:59:26 -0500

Tetragramm gravatar image

Here's how mine was added.

  1. Create a new folder in opencv_contrib/modules with the name of your new module.
  2. Add a file CmakeLists.txt
  3. To CMakeLists.txt make the first line: set(the_description "Descripton here")
  4. 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
  5. 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....
  6. In the folder of your module, add folders include and src.
  7. 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.

edit flag offensive delete link more


Thanks for your answer.

Using your answer when you have two computers and you want to share your code using git you have to use a new branch if you want to make a regular PR about a small bug elsewhere opencv_contrib ?

LBerger gravatar imageLBerger ( 2017-02-05 15:18:35 -0500 )edit

You can put this in a branch, and just switch back to the main to make PRs. Then switch back to your branch.

Tetragramm gravatar imageTetragramm ( 2017-02-05 18:49:37 -0500 )edit

My memory is a problem ... I forget to switch branch...

LBerger gravatar imageLBerger ( 2017-02-06 02:08:30 -0500 )edit

You could check just that one folder as a different repository? Then when you check into and out of the contrib repository, it's not included.

Tetragramm gravatar imageTetragramm ( 2017-02-06 18:12:29 -0500 )edit

Question Tools

1 follower


Asked: 2017-02-05 13:54:12 -0500

Seen: 715 times

Last updated: Feb 05 '17