Commit b204e73d authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

propagated some more fixes from 2.3 branch to the trunk

parent dacd2654
......@@ -645,7 +645,7 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including ``std::sort()`` .
.. _MatrixExpressions:
Matrix Expressions
------------------
......
......@@ -3,16 +3,17 @@ Clustering
.. highlight:: cpp
.. index:: kmeans
.. _kmeans:
kmeans
------
Finds centers of clusters and groups input samples around the clusters.
.. ocv:function:: double kmeans( InputArray samples, int clusterCount, InputOutputArray labels, TermCriteria criteria, int attempts, int flags, OutputArray centers=noArray() )
.. ocv:pyfunction:: cv2.kmeans(data, K, criteria, attempts, flags[, bestLabels[, centers]]) -> retval, bestLabels, centers
.. ocv:function:: double kmeans( InputArray samples, int clusterCount, InputOutputArray labels, TermCriteria termcrit, int attempts, int flags, OutputArray centers=noArray() )
.. ocv:cfunction:: int cvKMeans2(const CvArr* samples, int nclusters, CvArr* labels, CvTermCriteria criteria, int attempts=1, CvRNG* rng=0, int flags=0, CvArr* centers=0, double* compactness=0)
Finds centers of clusters and groups input samples around the clusters.
.. ocv:pyoldfunction:: cv.KMeans2(samples, nclusters, labels, criteria)-> None
:param samples: Floating-point matrix of input samples, one row per sample.
......@@ -20,7 +21,7 @@ kmeans
:param labels: Input/output integer array that stores the cluster indices for every sample.
:param termcrit: Flag to specify the maximum number of iterations and/or the desired accuracy. The accuracy is specified as ``termcrit.epsilon``. As soon as each of the cluster centers moves by less than ``termcrit.epsilon`` on some iteration, the algorithm stops.
:param criteria: The algorithm termination criteria, that is, the maximum number of iterations and/or the desired accuracy. The accuracy is specified as ``criteria.epsilon``. As soon as each of the cluster centers moves by less than ``criteria.epsilon`` on some iteration, the algorithm stops.
:param attempts: Flag to specify the number of times the algorithm is executed using different initial labelings. The algorithm returns the labels that yield the best compactness (see the last function parameter).
......@@ -28,7 +29,7 @@ kmeans
* **KMEANS_RANDOM_CENTERS** Select random initial centers in each attempt.
* **KMEANS_PP_CENTERS** Use ``kmeans++`` center initialization by Arthur and Vassilvitskii.
* **KMEANS_PP_CENTERS** Use ``kmeans++`` center initialization by Arthur and Vassilvitskii [Arthur2007].
* **KMEANS_USE_INITIAL_LABELS** During the first (and possibly the only) attempt, use the user-supplied labels instead of computing them from the initial centers. For the second and further attempts, use the random or semi-random centers. Use one of ``KMEANS_*_CENTERS`` flag to specify the exact method.
......@@ -53,16 +54,14 @@ Basically, you can use only the core of the function, set the number of
attempts to 1, initialize labels each time using a custom algorithm, pass them with the
( ``flags`` = ``KMEANS_USE_INITIAL_LABELS`` ) flag, and then choose the best (most-compact) clustering.
.. index:: partition
partition
-------------
Splits an element set into equivalency classes.
.. ocv:function:: template<typename _Tp, class _EqPredicate> int
.. ocv:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
Splits an element set into equivalency classes.
:param vec: Set of elements stored as a vector.
:param labels: Output vector of labels. It contains as many elements as ``vec``. Each label ``labels[i]`` is a 0-based cluster index of ``vec[i]`` .
......@@ -77,3 +76,4 @@ http://en.wikipedia.org/wiki/Disjoint-set_data_structure
. The function
returns the number of equivalency classes.
.. [Arthur2007] Arthur and S. Vassilvitskii “k-means++: the advantages of careful seeding”, Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, 2007
......@@ -6,9 +6,12 @@ core. The Core Functionality
:maxdepth: 2
basic_structures
old_basic_structures
dynamic_structures
operations_on_arrays
drawing_functions
xml_yaml_persistence
old_xml_yaml_persistence
clustering
utility_and_system_functions_and_macros
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -162,5 +162,3 @@ FileNodeIterator
.. ocv:class:: FileNodeIterator
The class ``FileNodeIterator`` is used to iterate through sequences and mappings. A standard STL notation, with ``node.begin()``, ``node.end()`` denoting the beginning and the end of a sequence, stored in ``node``. See the data reading sample in the beginning of the section.
......@@ -2075,6 +2075,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
if( kind1 == kind2 && src1.dims <= 2 && src2.dims <= 2 && src1.size() == src2.size() && src1.type() == src2.type() )
{
CV_Assert(src1.channels() == 1);
_dst.create(src1.size(), CV_8UC1);
Mat dst = _dst.getMat();
Size sz = getContinuousSize(src1, src2, dst, src1.channels());
......
......@@ -148,7 +148,7 @@ static void updateContinuityFlag(Mat& m)
break;
}
int64 t = (int64)(m.step[0]/CV_ELEM_SIZE(m.flags))*m.size[0];
int64 t = (int64)m.step[0]*m.size[0];
if( j <= i && t == (int)t )
m.flags |= Mat::CONTINUOUS_FLAG;
else
......
......@@ -9,7 +9,7 @@ represented as vectors in a multidimensional space. All objects that implement t
descriptor extractors inherit the
:ocv:class:`DescriptorExtractor` interface.
.. index:: DescriptorExtractor
DescriptorExtractor
-------------------
......@@ -47,13 +47,13 @@ distances between descriptors. Therefore, a collection of
descriptors is represented as
:ocv:class:`Mat` , where each row is a keypoint descriptor.
.. index:: DescriptorExtractor::compute
DescriptorExtractor::compute
--------------------------------
.. ocv:function:: void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const
Computes the descriptors for a set of keypoints detected in an image (first variant) or image set (second variant).
Computes the descriptors for a set of keypoints detected in an image (first variant) or image set (second variant).
.. ocv:function:: void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const
:param image: Image.
......@@ -71,33 +71,33 @@ DescriptorExtractor::compute
:param descriptors: Descriptor collection. ``descriptors[i]`` are descriptors computed for a ``keypoints[i]`` set.
.. index:: DescriptorExtractor::read
DescriptorExtractor::read
-----------------------------
.. ocv:function:: void DescriptorExtractor::read( const FileNode& fn )
Reads the object of a descriptor extractor from a file node.
Reads the object of a descriptor extractor from a file node.
.. ocv:function:: void DescriptorExtractor::read( const FileNode& fn )
:param fn: File node from which the detector is read.
.. index:: DescriptorExtractor::write
DescriptorExtractor::write
------------------------------
.. ocv:function:: void DescriptorExtractor::write( FileStorage& fs ) const
Writes the object of a descriptor extractor to a file storage.
Writes the object of a descriptor extractor to a file storage.
.. ocv:function:: void DescriptorExtractor::write( FileStorage& fs ) const
:param fs: File storage where the detector is written.
.. index:: DescriptorExtractor::create
DescriptorExtractor::create
-------------------------------
.. ocv:function:: Ptr<DescriptorExtractor> DescriptorExtractor::create( const string& descriptorExtractorType )
Creates a descriptor extractor by name.
Creates a descriptor extractor by name.
.. ocv:function:: Ptr<DescriptorExtractor> DescriptorExtractor::create( const string& descriptorExtractorType )
:param descriptorExtractorType: Descriptor extractor type.
......@@ -112,9 +112,7 @@ A combined format is also supported: descriptor extractor adapter name ( ``"Oppo
:ocv:class:`OpponentColorDescriptorExtractor` ) + descriptor extractor name (see above),
for example: ``"OpponentSIFT"`` .
.. index:: SiftDescriptorExtractor
.. _SiftDescriptorExtractor:
SiftDescriptorExtractor
-----------------------
......@@ -144,9 +142,7 @@ Wrapping class for computing descriptors by using the
}
.. index:: SurfDescriptorExtractor
.. _SurfDescriptorExtractor:
SurfDescriptorExtractor
-----------------------
......@@ -170,9 +166,7 @@ Wrapping class for computing descriptors by using the
}
.. index:: OrbDescriptorExtractor
.. _OrbDescriptorExtractor:
OrbDescriptorExtractor
---------------------------
......@@ -196,7 +190,7 @@ Wrapping class for computing descriptors by using the
}
.. index:: CalonderDescriptorExtractor
CalonderDescriptorExtractor
---------------------------
......@@ -220,10 +214,6 @@ Wrapping class for computing descriptors by using the
}
.. index:: OpponentColorDescriptorExtractor
.. _OpponentColorDescriptorExtractor:
OpponentColorDescriptorExtractor
--------------------------------
.. ocv:class:: OpponentColorDescriptorExtractor
......@@ -248,9 +238,6 @@ them into a single color descriptor. ::
};
.. index:: BriefDescriptorExtractor
.. _BriefDescriptorExtractor:
BriefDescriptorExtractor
------------------------
......
......@@ -9,10 +9,6 @@ that are represented as vectors in a multidimensional space. All objects that im
descriptor matchers inherit the
:ocv:class:`DescriptorMatcher` interface.
.. index:: DMatch
.. _DMatch:
DMatch
------
.. ocv:class:: DMatch
......@@ -42,10 +38,6 @@ train descriptor index, train image index, and distance between descriptors. ::
};
.. index:: DescriptorMatcher
.. _DescriptorMatcher:
DescriptorMatcher
-----------------
.. ocv:class:: DescriptorMatcher
......@@ -104,66 +96,67 @@ with an image set. ::
};
.. index:: DescriptorMatcher::add
DescriptorMatcher::add
--------------------------
.. ocv:function:: void add( const vector<Mat>& descriptors )
Adds descriptors to train a descriptor collection. If the collection ``trainDescCollectionis`` is not empty, the new descriptors are added to existing train descriptors.
Adds descriptors to train a descriptor collection. If the collection ``trainDescCollectionis`` is not empty, the new descriptors are added to existing train descriptors.
.. ocv:function:: void DescriptorMatcher::add( const vector<Mat>& descriptors )
:param descriptors: Descriptors to add. Each ``descriptors[i]`` is a set of descriptors from the same train image.
.. index:: DescriptorMatcher::getTrainDescriptors
DescriptorMatcher::getTrainDescriptors
------------------------------------------
.. ocv:function:: const vector<Mat>& getTrainDescriptors() const
Returns a constant link to the train descriptor collection ``trainDescCollection`` .
.. ocv:function:: const vector<Mat>& DescriptorMatcher::getTrainDescriptors() const
Returns a constant link to the train descriptor collection ``trainDescCollection`` .
.. index:: DescriptorMatcher::clear
DescriptorMatcher::clear
----------------------------
Clears the train descriptor collection.
.. ocv:function:: void DescriptorMatcher::clear()
Clears the train descriptor collection.
.. index:: DescriptorMatcher::empty
DescriptorMatcher::empty
----------------------------
Returns true if there are no train descriptors in the collection.
.. ocv:function:: bool DescriptorMatcher::empty() const
Returns true if there are no train descriptors in the collection.
.. index:: DescriptorMatcher::isMaskSupported
DescriptorMatcher::isMaskSupported
--------------------------------------
Returns true if the descriptor matcher supports masking permissible matches.
.. ocv:function:: bool DescriptorMatcher::isMaskSupported()
Returns true if the descriptor matcher supports masking permissible matches.
.. index:: DescriptorMatcher::train
DescriptorMatcher::train
----------------------------
Trains a descriptor matcher
.. ocv:function:: void DescriptorMatcher::train()
Trains a descriptor matcher (for example, the flann index). In all methods to match, the method ``train()`` is run every time before matching. Some descriptor matchers (for example, ``BruteForceMatcher``) have an empty implementation of this method. Other matchers really train their inner structures (for example, ``FlannBasedMatcher`` trains ``flann::Index`` ).
Trains a descriptor matcher (for example, the flann index). In all methods to match, the method ``train()`` is run every time before matching. Some descriptor matchers (for example, ``BruteForceMatcher``) have an empty implementation of this method. Other matchers really train their inner structures (for example, ``FlannBasedMatcher`` trains ``flann::Index`` ).
.. index:: DescriptorMatcher::match
DescriptorMatcher::match
----------------------------
Finds the best match for each descriptor from a query set.
.. ocv:function:: void DescriptorMatcher::match( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<DMatch>& matches, const Mat& mask=Mat() ) const
.. ocv:function:: void DescriptorMatcher::match( const Mat& queryDescriptors, vector<DMatch>& matches, const vector<Mat>& masks=vector<Mat>() )
Finds the best match for each descriptor from a query set.
:param queryDescriptors: Query set of descriptors.
:param trainDescriptors: Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
......@@ -176,16 +169,16 @@ DescriptorMatcher::match
In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by ``DescriptorMatcher::add`` is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, ``queryDescriptors[i]`` can be matched with ``trainDescriptors[j]`` only if ``mask.at<uchar>(i,j)`` is non-zero.
.. index:: DescriptorMatcher::knnMatch
DescriptorMatcher::knnMatch
-------------------------------
Finds the k best matches for each descriptor from a query set.
.. ocv:function:: void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<vector<DMatch> >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const
.. ocv:function:: void DescriptorMatcher::knnMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k, const vector<Mat>& masks=vector<Mat>(), bool compactResult=false )
Finds the k best matches for each descriptor from a query set.
:param queryDescriptors: Query set of descriptors.
:param trainDescriptors: Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
......@@ -202,16 +195,16 @@ DescriptorMatcher::knnMatch
These extended variants of :ocv:func:`DescriptorMatcher::match` methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See :ocv:func:`DescriptorMatcher::match` for the details about query and train descriptors.
.. index:: DescriptorMatcher::radiusMatch
DescriptorMatcher::radiusMatch
----------------------------------
For each query descriptor, finds the training descriptors not farther than the specified distance.
.. ocv:function:: void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, vector<vector<DMatch> >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const
.. ocv:function:: void DescriptorMatcher::radiusMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance, const vector<Mat>& masks=vector<Mat>(), bool compactResult=false )
For each query descriptor, finds the training descriptors not farther than the specified distance.
:param queryDescriptors: Query set of descriptors.
:param trainDescriptors: Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
......@@ -228,23 +221,23 @@ DescriptorMatcher::radiusMatch
For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than ``maxDistance``. Found matches are returned in the distance increasing order.
.. index:: DescriptorMatcher::clone
DescriptorMatcher::clone
----------------------------
.. ocv:function:: Ptr<DescriptorMatcher> DescriptorMatcher::clone( bool emptyTrainData ) const
Clones the matcher.
Clones the matcher.
.. ocv:function:: Ptr<DescriptorMatcher> DescriptorMatcher::clone( bool emptyTrainData ) const
:param emptyTrainData: If ``emptyTrainData`` is false, the method creates a deep copy of the object, that is, copies both parameters and train data. If ``emptyTrainData`` is true, the method creates an object copy with the current parameters but with empty train data.
.. index:: DescriptorMatcher::create
DescriptorMatcher::create
-----------------------------
.. ocv:function:: Ptr<DescriptorMatcher> DescriptorMatcher::create( const string& descriptorMatcherType )
Creates a descriptor matcher of a given type with the default parameters (using default constructor).
Creates a descriptor matcher of a given type with the default parameters (using default constructor).
.. ocv:function:: Ptr<DescriptorMatcher> DescriptorMatcher::create( const string& descriptorMatcherType )
:param descriptorMatcherType: Descriptor matcher type. Now the following matcher types are supported:
......@@ -259,9 +252,9 @@ DescriptorMatcher::create
*
``FlannBased``
.. index:: BruteForceMatcher
.. _BruteForceMatcher:
BruteForceMatcher
-----------------
......@@ -345,9 +338,9 @@ For efficiency, ``BruteForceMatcher`` is used as a template parameterized with t
};
.. index:: FlannBasedMatcher
.. _FlannBasedMatcher:
FlannBasedMatcher
-----------------
......
Drawing Function of Keypoints and Matches
=========================================
.. index:: drawMatches
drawMatches
---------------
Draws the found matches of keypoints from two images.
.. ocv:function:: void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<DMatch>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<char>& matchesMask=vector<char>(), int flags=DrawMatchesFlags::DEFAULT )
.. ocv:function:: void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<vector<DMatch> >& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<vector<char>>& matchesMask= vector<vector<char> >(), int flags=DrawMatchesFlags::DEFAULT )
Draws the found matches of keypoints from two images.
:param img1: First source image.
......@@ -59,13 +59,13 @@ This function draws matches of keypoints from two images in the output image. Ma
..
.. index:: drawKeypoints
drawKeypoints
-----------------
.. ocv:function:: void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, Mat& outImg, const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT )
Draws keypoints.
Draws keypoints.
.. ocv:function:: void drawKeypoints( const Mat& image, const vector<KeyPoint>& keypoints, Mat& outImg, const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT )
:param image: Source image.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment