Ask Your Question

Best/efficient development workflow?

asked 2020-10-11 06:06:29 -0500

Aitik Gupta gravatar image

I've recently started open-source, contributing to OpenCV. I searched through the questions, never really found a good exhaustive development workflow. (Might be a rookie search)
My current workflow:

  1. Sync up everything with upstream, create a new branch.
  2. Run cmake-gui, configure and generate. [BUILD_opencv_world checked]
  3. Install OpenCV globally (via sudo make install -j12) <- This takes a huge, huge amount of time.
  4. Make changes in files. (actual contribution)
  5. Repeat 3)
  6. Create a directory in a separate location, use CMakeLists.txt to find OpenCV package, bind libs to arbitrary test.cpp
  7. Compile, check if changes were correct. Repeat 4) and 5) until the changes make sense.
  8. Push and create a PR.

The step 3) is very time consuming, if I were to shift from master to 3.4 or vice versa, or if I were to quickly check out another working branch. Is there any workaround to this? (Might be a rookie overview of the problem, any help would be much appreciated!)

edit retag flag offensive close merge delete


Install OpenCV globally (via sudo make install -j12)

This is not recommended to install globally. Instead, use CMAKE_INSTALL_PREFIX to point to something like opencv-build/install and use OpenCV_DIR environment variable to let CMake find OpenCV.

Eduardo gravatar imageEduardo ( 2020-10-11 09:58:27 -0500 )edit

This is a good point, I'll make sure of this from next time.

Aitik Gupta gravatar imageAitik Gupta ( 2020-10-11 10:58:02 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-10-11 07:40:07 -0500

berak gravatar image

updated 2020-10-11 08:00:43 -0500

2 ideas here:

1: divide & conquer

if it's just a single small function, extract it from the library code into your test.cpp, hack it into submission there and only then put it back into the library code, if you're lucky, you only need a single pass of 3. then.

2: build only what you need for your change

don't rebuild the whole world ;)

in fact, disable the world module, and use a whitelist of only the nessecary modules, like

cmake -DBUILD_LIST=core,imgproc,imgcodecs

(a list of comma-seperated module names sans the "opencv_" prefix, builds in a few miutes here, like this ...)

this will also disable python/java bindings


  • they'll probably ask you to add a unit test for your changes, so getting somewhat familiar with google's test framework might be a good idea.
  • the github wiki has some nice info, e.g. here and here
  • gl, and no fear, devs there are very noob friendly / encouraging ;)
  • usually, there's a step 9. -- ppl will request changes, add those, squash commits (the fun part, vi.. !!) git rebase -i HEAD~2 and force-push again ;)
  • scan current issues/pr's e.g. like this: , it will give you a good feel for how discussions there go, who's working on what and other ppl's workflows.
edit flag offensive delete link more


note : you can do all precess with your browser after you forked opencv on github also see

sturkmen gravatar imagesturkmen ( 2020-10-11 08:41:27 -0500 )edit

no fear to create a PR OpenCV's build system will compile and you see if there is a can change the code (add new commits)

sturkmen gravatar imagesturkmen ( 2020-10-11 08:49:27 -0500 )edit

Thanks for all the pointers! This is precisely what I needed @berak :)

Aitik Gupta gravatar imageAitik Gupta ( 2020-10-11 11:00:03 -0500 )edit

@sturkmen I'm not sure I get you, this is what I understood: I can create multiple commits on the PR, OpenCV's build system will compile with every new commit in the PR. If this is what you mean, I understand. But if not, could you elaborate just a bit more? Thanks :)

Aitik Gupta gravatar imageAitik Gupta ( 2020-10-11 11:04:39 -0500 )edit

You can create multiple commits on the PR, OpenCV's build system will compile with every new commit in the PR. this is what i mean :)

sturkmen gravatar imagesturkmen ( 2020-10-11 11:07:07 -0500 )edit

did you pushed your local changes to your fork ? what is your github account ?

sturkmen gravatar imagesturkmen ( 2020-10-11 11:11:05 -0500 )edit

Yeah I understand @sturkmen, I already have a merged PR in OpenCV - Problem was that it took long development times for a single issue (which I understand can be made much faster, thanks to this thread).
Anyway here's my github account:

Aitik Gupta gravatar imageAitik Gupta ( 2020-10-11 15:16:20 -0500 )edit

there is a problem on with python3 you can test creating a PR with your browser if you solve the issue

sturkmen gravatar imagesturkmen ( 2020-10-11 15:29:38 -0500 )edit

Question Tools

1 follower


Asked: 2020-10-11 05:54:07 -0500

Seen: 148 times

Last updated: Oct 11 '20