-
-
Notifications
You must be signed in to change notification settings - Fork 55.9k
How_to_contribute
We suppose that you've seen the contribute page, and now, as an enthusiastic coder, want to contribute some code. For that purpose OpenCV project now has a mirror on the GitHub, to simplify everybody's life! All the bug fixes, new functionality, new tutorials etc. should be submitted via the GitHub's mechanism of pull requests.
If you are not familiar with the mechanism - do not worry, it's very simple. Keep reading.
-
Make sure you agree to contribute your code under OpenCV (Apache 2.0) license.
-
If you are submitting a new algorithm implementation, do a quick search over internet to see whether the algorithm is patented or not. Note: All new algorithms should go into opencv_contrib repository by default.
-
If you are going to fix a bug, check that it still exists. This can be done by building the latest 4.x/5.x branch or the latest master branch, and make sure that the error is still reproducible there. We do not fix bugs that only affect deprecated versions like OpenCV 2.x/3.x for example. Note: Please note that issues found in older versions may already be resolved in the latest version.
-
Make sure that nobody beat you into fixing or reporting the issue by doing a search on the Github OpenCV issues page, and making sure that there isn't someone working on it. In the latter case you might provide support or suggestion in the issue or in the linked pull request.
-
If you have a question about the software, then this is NOT the right place. You should open up a question at the OpenCV Q&A forum. In order to post a decent question from the start, feel free to read the official forum guidelines.
Before you open up anything on the OpenCV GitHub page, be sure that you are at the right place with your problem.
- Install Git.
- Register at GitHub. Create your fork of OpenCV repository https://github.com/opencv/opencv (see https://help.github.com/articles/fork-a-repo for details).
- Choose a task for yourself. It could be a bugfix or some new code.
- Choose a base branch for your work. More details about branches and policies are here: Branches
- Clone your fork to your computer. You can install the default pre-commit hook by renaming
opencv/.git/hooks/pre-commit.sample
toopencv/.git/hooks/pre-commit
- this will prevent you from committing whitespace errors. - Create a new branch (with a meaningful name) from the base branch you chose.
- Modify/add the code following our Coding_Style_Guide.
- Run testsuite locally:
- get the required sample data by cloning https://github.com/opencv/opencv_extra (choose corresponding branch)
export OPENCV_TEST_DATA_PATH=<path_to_opencv_extra>/testdata
- execute each test binary from the build directory, e.g.
./bin/opencv_test_core
- When you are done, push your branch to your GitHub fork; then create a pull request from your branch to the base branch (see https://help.github.com/articles/using-pull-requests for details).
Following these guidelines will increase the likelihood of your pull request being accepted:
- Before pushing your PR to the repository, make sure that it builds perfectly fine on your local system.
- Add enough information, like a meaningful title, the reason why you made the commit and a link to the issue page if you opened one for this PR.
- Scope your PR to one issue. Before submitting, make sure the diff contains no unrelated changes. If you want to cover more than one issue, submit your changes for each as separate pull requests.
- If you have added new functionality, you should update/create the relevant documentation, as well as add tests for it to the testsuite.
- Try not to include "oops" commits - ones that just fix an error in the previous commit. If you have those, then before submitting squash those fixes directly into the commits where they belong.
- Make sure to choose the right base branch and to follow the Coding_Style_Guide for your code.
- Make sure to add tests for new functionality or test that reproduces fixed bug with related test data. Please do not add extra images or videos, if some of existing media files are suitable.
- Make sure to add performance tests, if you propose optimization or the patch could affect performance of major functionality. See HowToWritePerfTests page to implement good tests and HowToUsePerfTests page to run performance tests properly.
- Your pull request will be automatically tested by OpenCV's Github Action (testing status can be checked here: https://github.com/opencv/opencv/actions) and OpenCV's buildbot (http://pullrequest.opencv.org). If any builders have failed, you should fix the issue. If you want to rerun builders, for Github Action, there is a button in the upper right corner of the status page and for buildbot, you just push changes to your branch on GitHub. No need to close pull request and open a new one!
- Once all the builders are "green", one of OpenCV developers will review your code. Reviewer could ask you to modify your pull request. Please provide timely response for reviewers (within weeks, not months), otherwise your submission could be postponed or even rejected.
- As soon as the reviewer is fine with the pull request and BuildBot likes your code, the special approval comment 👍 or is put, which signals OpenCV maintainers that they can merge your pull request.
- The last, but not least. Make sure you got credits. We try to memorize all the contributions and list major ones in the ChangeLog and release announcements, but we may forget to do that, unintentionally. Please, do not hesitate to remind us, and we will update opencv.org and the ChangeLog accordingly.
Please read this, read the "Choose a base branch..." section.
You can use git cherry-pick
command to move individual commits between branches. Here is the overall algorithm: you backup your current branch, re-create a new branch properly (from either 2.4, 3.4 or master), cherry-pick necessary commits from backup branch onto re-create branch, change base branch of your pull request (via GitHub), finally push changes to your GitHub repository (with --force/-f
option).
Just resolve the issues, commit changes, and push them to the same branch you used to create a pull request.
Next time we suggest you to do the following. Install the default pre-commit hook by renaming opencv/.git/hooks/pre-commit.sample
to opencv/.git/hooks/pre-commit
- this will prevent you from committing whitespace errors.
cd opencv
mv .git/hooks/pre-commit.sample .git/hooks/pre-commit
Also, you can check for whitespace errors before the commit using this command:
git diff --check
Please refer Writing documentation for OpenCV tutorial.
© Copyright 2024, OpenCV team
- Home
- Deep Learning in OpenCV
- Running OpenCV on Various Platforms
- OpenCV 5
- OpenCV 4
- OpenCV 3
- Development process
- OpenCV GSoC
- Archive