How to contribute

Version 34 (Daniil Osokin, 2014-07-14 06:01 pm) → Version 35/52 (Daniil Osokin, 2014-07-14 06:01 pm)

{{>toc}}

h1. How to contribute

We suppose that you've seen the http://opencv.org/contribute.html 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.

h2. "Fork & Pull Request model" for code contribution

h3. *Short instruction*

# Install [[Git]].
# Register at GitHub. Create your fork of OpenCV repository https://github.com/Itseez/opencv (see https://help.github.com/articles/fork-a-repo for details).
# Choose a task for youself. It could be a "bugfix":http://www.code.opencv.org/projects/opencv/issues?query_id=5, or some new code.
# Choose a base branch for your work. You have two options:
## *2.4* - the branch that will be used for future minor releases in the 2.4.x line. Choose it when fixing a bug that's reproducible in this branch, or when making performance optimizations relevant to it. 2.4 has been feature-frozen; as such, new functionality will _not_ be accepted.
## *master* - the branch that will be used for the next major release of OpenCV (tentatively, 3.0). Choose it when adding new functionality, or for bugfixes/optimizations that don't apply to 2.4.
# Create a new branch (with a meaningful name) from the base branch you chose.
# Modify/add the code following our [[Coding Style Guide]].
# 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).

h3. *Links to "step-by-step" guide for popular systems and clients*

* [[How to contribute#Windows-7-and-TortoiseGit|Windows 7 and TortoiseGit]]

h2. Making a good pull request

Following these guidelines will increase the likelihood of your pull request being accepted:

# 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":http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits those fixes directly into the commits where they belong.
# Make sure to choose the right base branch and to follow the [[Style Guide]] for your code.

h2. Testing and merging of pull requests

# Your pull request will be automatically tested by OpenCV's buildbot (testing status can be checked here: http://pullrequest.opencv.org). If any builders are failed, you should fix the issue. As you fix the code and push changes to your branch at github, buildbot reruns automatically. _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 you submission could be postponed or even rejected.

h3. Here is the flow-chart of the process:

!https://docs.google.com/drawings/pub?id=1_m7oVQ4CvoMxZn63N1_TyhhazmLLWY5uLEGUyPCERLo&w=960&h=720!

h2. Happy End

# As soon as the reviewer is fine with the pull request and BuildBot likes your code, the special comment ":+1:" or ":shipit:" 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.

h1. "Step-by-step" guide for popular systems and clients

h2. {{anchor|Windows 7 and TortoiseGit}}Windows 7 and TortoiseGit

*System configuration:*

* Windows 7 x64 bit operating system.
* Git 1.8.1 & TortoiseGit 1.8.4.

*Prerequisites:*

# Register at GitHub.
# Download & install "Git":http://code.google.com/p/msysgit/downloads/list.
# Download & install "TortoiseGit":http://code.google.com/p/tortoisegit/wiki/Download.

Firstly, *configure your GitHub page* to fork the original OpenCV repository:

# Go to GitHub.
# Open the "Itseez OpenCV page":https://github.com/Itseez/opencv.
# Press the fork icon on the right hand top side of the page:

!press_fork_button.png!

Create a folder on your system to *sync up the OpenCV source code* from your fork:

* Create a folder named 'opencv_source' in your systems root path (or your own selection).
* Right click on the folder, selecting the Git Clone option:

!git_clone.png!

* Fill in the proper information into the configuration panel. Replace "StevenPuttemans" username with your GitHub username and remove the extra opencv folder that is added to the directory structure:

!clone_existing_repository!

* Press OK and let the folder sync up, until full synchronization has passed:

!synchronization_with_Itseez_git.png!

*Create a new branch on your Git repository*, to apply changes. Do not forget to create a new branch for every single update you want to do! _These branches are local, but will be pushed to github after editing the source code._

* Right click on folder.
* Select TortoiseGit > Create Branch:

!create_branch.png!

Select the correct options, choose a correct name for your branch, base it on the *master branch* for complete *new functionality*, or for *minor fix*, base it on *2.4 branch*:

!choose_base_branch.png!

* Hit the OK button and let it configure your repository. Changes might not change immediatly on the GitHub page, because it sync's in a lapsed time interval. Don't worry about that.

!switched_to_branch.png!

*Select the file you want to adapt* (in our case I will illustrate adding an extra comment to a source code file), *adapt the the file accordingly* and *commit it to your GitHub repository*.

* In your configured GitHub folder on your machine, adapt the file you want.
* In our case, we open up the file *C:\opencv_source\apps\traincascade\traincascade.cpp*.
* Add your lines of code to the source code:

!modify_opencv_source.png!

* Save the file so that your adaptations are stored onto the system.
* Your folder will indicate that a change has been made, by placing an exclamation mark:

!opencv_source_folder_has_changed_files.png!

* Commit your adapted file to GitHub by selecting the commit->bugfix_1 option:

!commit_changes.png!
* The first time, the system will ask you to input your username and email, giving the following warning. Press *Yes*, fill in credentials and press *OK*:

!set_username_alert.png!

!set_username_and_email.png!

* A commit window of TortoiseGit will appear, showing you the files that were adapted. It requires you to give a complete but brief description of your adaptation, then allows you to push the file. Select only the files you want to commit to the repository!

!commit_window.png!

* At the next window, explicitly tell the software to push the adaptations!

!select_push_changes.png!