Repository: opencv
Issue: Documentation for reduce() function does not match its CV2 implementation in python
Labels: feature,category: documentation,category: features2d

For Python programmers who have OpenCV v3.xxx installed (aka the cv2 library in Python-world), the only OpenCV online documentation available for the **reduce()** function shows incorrect info that makes the function impossible to use.  When searching for usage info for this function (eg, search: "python open cv reduce()" or something similar), we get only the v2.4 doc pages.  So those with OpenCV 3.xxx installed will see only the v2.4 pages (there are no v3.xxx doc pages available for Python programmers importing cv2)  Those users will be unable to use the **reduce()** function because they will not know that the OpenCV v2.4 doc pages describe older/deprecated constants (**_CV_REDUCE_SUM_**, et al), which were renamed in openCV 3.0 (they are now called **_REDUCE_SUM_**, et al).

##### System information (version)
- OpenCV => my system has v3.1.0
- Operating System / Platform => Windows 10 (and prior)
- Compiler => Python 3.6 (Anaconda3)

##### Detailed description
Documentation for the **reduce()** function has differing doc pages for OpenCV version 2 (2.1 through latest 2.4.13.2) versus the newer OpenCV 3 (versions 3.0.0 to latest 3.2.0-dev).  By itself this is not a problem (other than maybe?? backward compatibility issues).

However, when compounded with the fact that web-search for usage info for the **reduce()** function show results **_only for the v2.4 OpenCV modules_** (ie. no info for v3.xxx modules appear if we search with "Python" or "cv2" as a keyword), thus Python users of OpenCV 3.xxx looking for this info will currently get the incorrect info.  They will soon see the **reduce()** function does not work according to how it's described in the official OpenCV doc pages.  They have no way of knowing that there are totally different doc pages for v3.xxx containing different info, including the renamed REDUCE_SUM (and related) constants.

The difference between the 2.xx and 3.xx doc pages that causes the problem is that there are 4 constants required to use function **reduce()**, and these constants were renamed between OpenCV 2 and 3:  "**_CV_REDUCE_xxx_**" (CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, and CV_REDUCE_MIN) became "**_REDUCE_xxx_**" (REDUCE_SUM, et al) in OpenCV 3.xxx.

This problem occurs mainly because doc pages with "Python" always brings up the 2.4 version of the online OpenCV documentation -- which shows the deprecated constants.  However, 3.xxx binaries/sources and definitions don't conform to that 2.4xx documentation.

Possible Solution:
a) update the v3.xx documentation to also show Python headers (so they appear in search results), **and**
b) update the v2.4.x documentation to include a note that the four CV_REDUCE_xxx constants were renamed in OpenCV 3, to be REDUCE_xxx.  (I didn't check this but it's possible the constants for 2.4 were also renamed in v2.4 binaries, which means the v2.4 doc pages are also in error and so must be updated to also show the renamed constants)

I believe the Python doc pages and bindings are automagically generated from the official C++ version.  So the problem may be caused by the Python bindings no longer being correct (for OpenCV v3.xxx files, for the **reduce()** function or its constants definitions).

##### Steps to reproduce

- This link shows the problem (for v2.4.13.2):  [http://docs.opencv.org/2.4.13.2/modules/core/doc/operations_on_arrays.html?highlight=cv_reduce_avg#cv2.reduce](url)
_This first URL shows the Python header (highlighted) for the **reduce()** function.  In the paragraph, it describes 4 constants (which are required) to call this function.  This is the only official documentation available to Python programmers on the web (on [docs.OpenCV.org](url) )._

- Another link (for v2.4 doc page):  [http://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html?highlight=cv_reduce_avg#cv2.reduce](url)

- The correct documentation exists only for v3 and up, however Python programmers cannot see/find those links. This page show the (now renamed) constants that Python programmers don't know about:  [http://docs.opencv.org/3.1.0/d2/de8/group__core__array.html#ga4b78072a303f29d9031d56e5638da78e](url)

- Here's the v3.1.0 constants definition for **cv::ReduceTypes**:  [http://docs.opencv.org/3.1.0/d0/de1/group__core.html#ga14cdedf2933367eb9395ec16798af994](url)