it is used for finding color histograms where two features are Hue & Saturation values of every
pixel.
-There is a [python sample in the official
-samples](https://github.com/Itseez/opencv/blob/master/samples/python2/color_histogram.py) already
+There is a python sample (samples/python/color_histogram.py) already
for finding color histograms. We will try to understand how to create such a color histogram, and it
will be useful in understanding further topics like Histogram Back-Projection.
### Method 3 : OpenCV sample style !!
-There is a [sample code for color-histogram in OpenCV-Python2
-samples](https://github.com/Itseez/opencv/blob/master/samples/python2/color_histogram.py). If you
-run the code, you can see the histogram shows the corresponding color also. Or simply it outputs a
-color coded histogram. Its result is very good (although you need to add extra bunch of lines).
+There is a sample code for color-histogram in OpenCV-Python2 samples
+(samples/python/color_histogram.py).
+If you run the code, you can see the histogram shows the corresponding color also.
+Or simply it outputs a color coded histogram.
+Its result is very good (although you need to add extra bunch of lines).
In that code, the author created a color map in HSV. Then converted it into BGR. The resulting
histogram image is multiplied with this color map. He also uses some preprocessing steps to remove
Well, here you adjust the values of histograms along with its bin values to look like x,y
coordinates so that you can draw it using cv2.line() or cv2.polyline() function to generate same
-image as above. This is already available with OpenCV-Python2 official samples. [Check the
-Code](https://github.com/Itseez/opencv/raw/master/samples/python2/hist.py)
+image as above. This is already available with OpenCV-Python2 official samples. Check the
+code at samples/python/hist.py.
Application of Mask
-------------------
Our goal is to build an application which can read the handwritten digits. For this we need some
train_data and test_data. OpenCV comes with an image digits.png (in the folder
-opencv/samples/python2/data/) which has 5000 handwritten digits (500 for each digit). Each digit is
+opencv/samples/data/) which has 5000 handwritten digits (500 for each digit). Each digit is
a 20x20 image. So our first step is to split this image into 5000 different digits. For each digit,
we flatten it into a single row with 400 pixels. That is our feature set, ie intensity values of all
pixels. It is the simplest feature set we can create. We use first 250 samples of each digit as
Exercises
---------
--# OpenCV comes with an interactive sample on inpainting, samples/python2/inpaint.py, try it.
+-# OpenCV comes with an interactive sample on inpainting, samples/python/inpaint.py, try it.
2. A few months ago, I watched a video on [Content-Aware
Fill](http://www.youtube.com/watch?v=ZtoUiplKa2A), an advanced inpainting technique used in
Adobe Photoshop. On further search, I was able to find that same technique is already there in
actually for a robust tracking, corner points should be detected in particular intervals. OpenCV
samples comes up with such a sample which finds the feature points at every 5 frames. It also run a
backward-check of the optical flow points got to select only good ones. Check
-samples/python2/lk_track.py).
+samples/python/lk_track.py).
See the results we got:
![image](images/opticalfb.jpg)
OpenCV comes with a more advanced sample on dense optical flow, please see
-samples/python2/opt_flow.py.
+samples/python/opt_flow.py.
Additional Resources
--------------------
Exercises
---------
--# Check the code in samples/python2/lk_track.py. Try to understand the code.
-2. Check the code in samples/python2/opt_flow.py. Try to understand the code.
+-# Check the code in samples/python/lk_track.py. Try to understand the code.
+2. Check the code in samples/python/opt_flow.py. Try to understand the code.
- A calibration example on stereo matching can be found at
opencv_source_code/samples/cpp/stereo_match.cpp
- (Python) A camera calibration sample can be found at
- opencv_source_code/samples/python2/calibrate.py
+ opencv_source_code/samples/python/calibrate.py
@{
@defgroup calib3d_fisheye Fisheye camera model
@note
- An example of how to use solvePnP for planar augmented reality can be found at
- opencv_source_code/samples/python2/plane_ar.py
+ opencv_source_code/samples/python/plane_ar.py
- If you are using Python:
- Numpy array slices won't work as input because solvePnP requires contiguous
arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
@note
- (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found
- at opencv_source_code/samples/python2/stereo_match.py
+ at opencv_source_code/samples/python/stereo_match.py
*/
class CV_EXPORTS_W StereoSGBM : public StereoMatcher
{
- An example using the discrete fourier transform can be found at
opencv_source_code/samples/cpp/dft.cpp
- (Python) An example using the dft functionality to perform Wiener deconvolution can be found
- at opencv_source/samples/python2/deconvolution.py
+ at opencv_source/samples/python/deconvolution.py
- (Python) An example rearranging the quadrants of a Fourier image can be found at
- opencv_source/samples/python2/dft.py
+ opencv_source/samples/python/dft.py
@param src input array that could be real or complex.
@param dst output array whose size and type depends on the flags .
@param flags transformation flags, representing a combination of the cv::DftFlags
@note
- (Python) An example on K-means clustering can be found at
- opencv_source_code/samples/python2/kmeans.py
+ opencv_source_code/samples/python/kmeans.py
@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
Examples of this array can be:
- Mat points(count, 2, CV_32F);
- A CUDA example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/gpu/hog.cpp
- (Python) An example applying the HOG descriptor for people detection can be found at
- opencv_source_code/samples/python2/peopledetect.py
+ opencv_source_code/samples/python/peopledetect.py
*/
class CV_EXPORTS HOG : public Algorithm
{
- A complete Bag-Of-Words sample can be found at
opencv_source_code/samples/cpp/bagofwords_classification.cpp
- (Python) An example using the features2D framework to perform object categorization can be
- found at opencv_source_code/samples/python2/find_obj.py
+ found at opencv_source_code/samples/python/find_obj.py
@}
*/
than grey image method ( 3~4 times ); the chi_table.h file is taken directly from paper's source
code which is distributed under GPL.
-- (Python) A complete example showing the use of the %MSER detector can be found at samples/python2/mser.py
+- (Python) A complete example showing the use of the %MSER detector can be found at samples/python/mser.py
*/
class CV_EXPORTS_W MSER : public Feature2D
{
@note
- (Python) A face detection example using cascade classifiers can be found at
- opencv_source_code/samples/python2/facedetect.py
+ opencv_source_code/samples/python/facedetect.py
*/
CV_WRAP void detectMultiScale( InputArray image,
CV_OUT std::vector<Rect>& objects,
- An example using the inpainting technique can be found at
opencv_source_code/samples/cpp/inpaint.cpp
- (Python) An example using the inpainting technique can be found at
- opencv_source_code/samples/python2/inpaint.py
+ opencv_source_code/samples/python/inpaint.py
*/
CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask,
OutputArray dst, double inpaintRadius, int flags );
@note
- (Python) A sample explaining the camshift tracking algorithm can be found at
- opencv_source_code/samples/python2/camshift.py
+ opencv_source_code/samples/python/camshift.py
*/
CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
TermCriteria criteria );
- An example using the Lucas-Kanade optical flow algorithm can be found at
opencv_source_code/samples/cpp/lkdemo.cpp
- (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
- opencv_source_code/samples/python2/lk_track.py
+ opencv_source_code/samples/python/lk_track.py
- (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
- opencv_source_code/samples/python2/lk_homography.py
+ opencv_source_code/samples/python/lk_homography.py
*/
CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg,
InputArray prevPts, InputOutputArray nextPts,
- An example using the optical flow algorithm described by Gunnar Farneback can be found at
opencv_source_code/samples/cpp/fback.cpp
- (Python) An example using the optical flow algorithm described by Gunnar Farneback can be
- found at opencv_source_code/samples/python2/opt_flow.py
+ found at opencv_source_code/samples/python/opt_flow.py
*/
CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow,
double pyr_scale, int levels, int winsize,
- Another basic video processing sample can be found at
opencv_source_code/samples/cpp/video_dmtx.cpp
- (Python) A basic sample on using the VideoCapture interface can be found at
- opencv_source_code/samples/python2/video.py
+ opencv_source_code/samples/python/video.py
- (Python) Another basic video processing sample can be found at
- opencv_source_code/samples/python2/video_dmtx.py
+ opencv_source_code/samples/python/video_dmtx.py
- (Python) A multi threaded video processing sample can be found at
- opencv_source_code/samples/python2/video_threaded.py
+ opencv_source_code/samples/python/video_threaded.py
*/
class CV_EXPORTS_W VideoCapture
{
endif()
if(INSTALL_PYTHON_EXAMPLES)
- add_subdirectory(python2)
+ add_subdirectory(python)
endif()
#
if(INSTALL_PYTHON_EXAMPLES)
file(GLOB install_list *.py )
install(FILES ${install_list}
- DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/python2
+ DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/python
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
endif()