@@ -16,7 +16,7 @@ Today it is common to have a digital video recording system at your disposal. Th
The source code
===============
As a test case where to show off these using OpenCV I've created a small program that reads in two video files and performs a similarity check between them. This is something you could use to check just how well a new video compressing algorithms works. Let there be a reference (original) video like :download:`this small Megamind clip <../../../../samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/video/Megamind.avi>` and :download:`a compressed version of it <../../../../samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/video/Megamind_bugy.avi>`. You may also find the source code and these video file in the :file:`samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/` folder of the OpenCV source library.
As a test case where to show off these using OpenCV I've created a small program that reads in two video files and performs a similarity check between them. This is something you could use to check just how well a new video compressing algorithms works. Let there be a reference (original) video like :download:`this small Megamind clip <../../../../samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind.avi>` and :download:`a compressed version of it <../../../../samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind_bugy.avi>`. You may also find the source code and these video file in the :file:`samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/` folder of the OpenCV source library.
Retrieve the current parameters values in a *Retina::RetinaParameters* structure
...
...
@@ -325,7 +325,7 @@ Retina::RetinaParameters
.. ocv:struct:: Retina::RetinaParameters
This structure merges all the parameters that can be adjusted threw the **Retina::setup()**, **Retina::setupOPLandIPLParvoChannel** and **Retina::setupIPLMagnoChannel** setup methods
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
@@ -210,9 +210,9 @@ The sample below demonstrates how to use RotatedRect:
.. seealso::
:ocv:cfunc:`CamShift`,
:ocv:func:`fitEllipse`,
:ocv:func:`minAreaRect`,
:ocv:func:`CamShift` ,
:ocv:func:`fitEllipse`,
:ocv:func:`minAreaRect`,
:ocv:struct:`CvBox2D`
TermCriteria
...
...
@@ -1303,7 +1303,7 @@ because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::cre
Mat::addref
---------------
-----------
Increments the reference counter.
.. ocv:function:: void Mat::addref()
...
...
@@ -1313,7 +1313,7 @@ The method increments the reference counter associated with the matrix data. If
Mat::release
----------------
------------
Decrements the reference counter and deallocates the matrix if needed.
.. ocv:function:: void Mat::release()
...
...
@@ -1324,7 +1324,7 @@ The method decrements the reference counter associated with the matrix data. Whe
This method can be called manually to force the matrix data deallocation. But since this method is automatically called in the destructor, or by any other method that changes the data pointer, it is usually not needed. The reference counter decrement and check for 0 is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
Mat::resize
---------------
-----------
Changes the number of matrix rows.
.. ocv:function:: void Mat::resize( size_t sz )
...
...
@@ -1337,7 +1337,7 @@ The methods change the number of matrix rows. If the matrix is reallocated, the
Mat::reserve
---------------
------------
Reserves space for the certain number of rows.
.. ocv:function:: void Mat::reserve( size_t sz )
...
...
@@ -1370,7 +1370,7 @@ The method removes one or more rows from the bottom of the matrix.
////////////// some internally used methods ///////////////
...
// pointer to the sparse matrix header
Hdr* hdr;
};
The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Such a sparse array can store elements of any type that
:ocv:class:`Mat` can store. *Sparse* means that only non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its stored elements can actually become 0. It is up to you to detect such elements and delete them using ``SparseMat::erase`` ). The non-zero elements are stored in a hash table that grows when it is filled so that the search time is O(1) in average (regardless of whether element is there or not). Elements can be accessed using the following methods:
...
...
@@ -2231,6 +2035,204 @@ The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Su
..
SparseMat::SparseMat
--------------------
Various SparseMat constructors.
.. ocv:function:: SparseMat::SparseMat()
.. ocv:function:: SparseMat::SparseMat(int dims, const int* _sizes, int _type)
.. ocv:function:: SparseMat::SparseMat(const SparseMat& m)
.. ocv:function:: SparseMat::SparseMat(const Mat& m, bool try1d=false)
.. ocv:function:: SparseMat::SparseMat(const CvSparseMat* m)
:param m: Source matrix for copy constructor. If m is dense matrix (ocv:class:`Mat`) then it will be converted to sparse representation.
:param dims: Array dimensionality.
:param _sizes: Sparce matrix size on all dementions.
:param _type: Sparse matrix data type.
:param try1d: if try1d is true and matrix is a single-column matrix (Nx1), then the sparse matrix will be 1-dimensional.
SparseMat::~SparseMat
---------------------
SparseMat object destructor.
.. ocv:function:: SparseMat::~SparseMat()
SparseMat::operator =
---------------------
Provides sparse matrix assignment operators.
.. ocv:function:: SparseMat& SparseMat::operator=(const SparseMat& m)
.. ocv:function:: SparseMat& SparseMat::operator=(const Mat& m)
The last variant is equivalent to the corresponding constructor with try1d=false.
The method returns a sparse matrix element type. This is an identifier compatible with the ``CvMat`` type system, like ``CV_16SC3`` or 16-bit signed 3-channel array, and so on.
SparseMat::depth
----------------
Returns the depth of a sparse matrix element.
.. ocv:function:: int SparseMat::depth() const
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed 3-channel array, the method returns ``CV_16S``
@@ -166,6 +166,12 @@ field of the set is the total number of nodes both occupied and free. When an oc
``CvSet`` is used to represent graphs (:ocv:struct:`CvGraph`), sparse multi-dimensional arrays (:ocv:struct:`CvSparseMat`), and planar subdivisions (:ocv:struct:`CvSubdiv2D`).
CvSetElem
---------
.. ocv:struct:: CvSetElem
The structure is represent single element of :ocv:struct:`CvSet`. It consists of two fields: element data pointer and flags.
CvGraph
-------
...
...
@@ -174,6 +180,24 @@ CvGraph
The structure ``CvGraph`` is a base for graphs used in OpenCV 1.x. It inherits from
:ocv:struct:`CvSet`, that is, it is considered as a set of vertices. Besides, it contains another set as a member, a set of graph edges. Graphs in OpenCV are represented using adjacency lists format.
CvGraphVtx
----------
.. ocv:struct:: CvGraphVtx
The structure represents single vertex in :ocv:struct:`CvGraph`. It consists of two filds: pointer to first edge and flags.
CvGraphEdge
-----------
.. ocv:struct:: CvGraphEdge
The structure represents edge in :ocv:struct:`CvGraph`. Each edge consists of:
- Two pointers to the starting and ending vertices (vtx[0] and vtx[1] respectively);
- Two pointers to next edges for the starting and ending vertices, where
next[0] points to the next edge in the vtx[0] adjacency list and
next[1] points to the next edge in the vtx[1] adjacency list;
* **SVD::NO_UV** indicates that only a vector of singular values ``w`` is to be processed, while ``u`` and ``vt`` will be set to empty matrices.
* **SVD::FULL_UV** when the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction; if, however, ``FULL_UV`` flag is specified, ``u`` and ``vt``will be full-size square orthogonal matrices.
* **SVD::FULL_UV** when the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction; if, however, ``FULL_UV`` flag is specified, ``u`` and ``vt`` will be full-size square orthogonal matrices.
The first constructor initializes an empty ``SVD`` structure. The second constructor initializes an empty ``SVD`` structure and then calls
.. ocv:function:: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features=400, int max_features=500, int max_iters=5 )
...
...
@@ -484,7 +483,7 @@ Example: ::
AdjusterAdapter::good
-------------------------
---------------------
Returns false if the detector parameters cannot be adjusted any more.
@@ -10,11 +10,11 @@ Clusters features using hierarchical k-means algorithm.
.. ocv:function:: template<typename Distance> int flann::hierarchicalClustering(const Mat& features, Mat& centers, const cvflann::KMeansIndexParams& params, Distance d = Distance())
:param features: The points to be clustered. The matrix must have elements of type ``Distance::ElementType``.
:param centers: The centers of the clusters obtained. The matrix must have type ``Distance::ResultType``. The number of rows in this matrix represents the number of clusters desired, however, because of the way the cut in the hierarchical tree is chosen, the number of clusters computed will be the highest number of the form ``(branching-1)*k+1`` that's lower than the number of clusters desired, where ``branching`` is the tree's branching factor (see description of the KMeansIndexParams).
:param centers: The centers of the clusters obtained. The matrix must have type ``Distance::ResultType``. The number of rows in this matrix represents the number of clusters desired, however, because of the way the cut in the hierarchical tree is chosen, the number of clusters computed will be the highest number of the form ``(branching-1)*k+1`` that's lower than the number of clusters desired, where ``branching`` is the tree's branching factor (see description of the KMeansIndexParams).
:param params: Parameters used in the construction of the hierarchical k-means tree.
:param d: Distance to be used for clustering.
The method clusters the given feature vectors by constructing a hierarchical k-means tree and choosing a cut in the tree that minimizes the cluster's variance. It returns the number of clusters found.
@@ -6,6 +6,7 @@ Fast Approximate Nearest Neighbor Search
This section documents OpenCV's interface to the FLANN library. FLANN (Fast Library for Approximate Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. More information about FLANN can be found in [Muja2009]_ .
.. [Muja2009] Marius Muja, David G. Lowe. Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration, 2009
flann::Index\_
-----------------
...
...
@@ -20,40 +21,40 @@ flann::Index_<T>::Index\_
Constructs a nearest neighbor search index for a given dataset.
:param features: Matrix of containing the features(points) to index. The size of the matrix is ``num_features x feature_dimensionality`` and the data type of the elements in the matrix must coincide with the type of the index.
:param features: Matrix of containing the features(points) to index. The size of the matrix is ``num_features x feature_dimensionality`` and the data type of the elements in the matrix must coincide with the type of the index.
:param params: Structure containing the index parameters. The type of index that will be constructed depends on the type of this parameter. See the description.
The method constructs a fast search structure from a set of features using the specified algorithm with specified parameters, as defined by ``params``. ``params`` is a reference to one of the following class ``IndexParams`` descendants:
*
**LinearIndexParams** When passing an object of this type, the index will perform a linear, brute-force search. ::
struct LinearIndexParams : public IndexParams
{
};
..
*
**KDTreeIndexParams** When passing an object of this type the index constructed will consist of a set of randomized kd-trees which will be searched in parallel. ::
struct KDTreeIndexParams : public IndexParams
{
KDTreeIndexParams( int trees = 4 );
};
..
* **trees** The number of parallel kd-trees to use. Good values are in the range [1..16]
* **trees** The number of parallel kd-trees to use. Good values are in the range [1..16]
*
**KMeansIndexParams** When passing an object of this type the index constructed will be a hierarchical k-means tree. ::
struct KMeansIndexParams : public IndexParams
{
KMeansIndexParams(
...
...
@@ -62,20 +63,20 @@ The method constructs a fast search structure from a set of features using the s
* **branching** The branching factor to use for the hierarchical k-means tree
* **branching** The branching factor to use for the hierarchical k-means tree
* **iterations** The maximum number of iterations to use in the k-means clustering stage when building the k-means tree. A value of -1 used here means that the k-means clustering should be iterated until convergence
* **centers_init** The algorithm to use for selecting the initial centers when performing a k-means clustering step. The possible values are ``CENTERS_RANDOM`` (picks the initial cluster centers randomly), ``CENTERS_GONZALES`` (picks the initial centers using Gonzales' algorithm) and ``CENTERS_KMEANSPP`` (picks the initial centers using the algorithm suggested in arthur_kmeanspp_2007 )
* **cb_index** This parameter (cluster boundary index) influences the way exploration is performed in the hierarchical kmeans tree. When ``cb_index`` is zero the next kmeans domain to be explored is chosen to be the one with the closest center. A value greater then zero also takes into account the size of the domain.
*
**CompositeIndexParams** When using a parameters object of this type the index created combines the randomized kd-trees and the hierarchical k-means tree. ::
struct CompositeIndexParams : public IndexParams
{
CompositeIndexParams(
...
...
@@ -88,7 +89,7 @@ The method constructs a fast search structure from a set of features using the s
*
**LshIndexParams** When using a parameters object of this type the index created uses multi-probe LSH (by ``Multi-Probe LSH: Efficient Indexing for High-Dimensional Similarity Search`` by Qin Lv, William Josephson, Zhe Wang, Moses Charikar, Kai Li., Proceedings of the 33rd International Conference on Very Large Data Bases (VLDB). Vienna, Austria. September 2007) ::
struct LshIndexParams : public IndexParams
{
LshIndexParams(
...
...
@@ -96,9 +97,9 @@ The method constructs a fast search structure from a set of features using the s
unsigned int key_size,
unsigned int multi_probe_level );
};
..
* **table_number** the number of hash tables to use (between 10 and 30 usually).
...
...
@@ -109,7 +110,7 @@ The method constructs a fast search structure from a set of features using the s
*
**AutotunedIndexParams** When passing an object of this type the index created is automatically tuned to offer the best performance, by choosing the optimal index type (randomized kd-trees, hierarchical kmeans, linear) and parameters for the dataset provided. ::
struct AutotunedIndexParams : public IndexParams
{
AutotunedIndexParams(
...
...
@@ -118,80 +119,80 @@ The method constructs a fast search structure from a set of features using the s
float memory_weight = 0,
float sample_fraction = 0.1 );
};
..
* **target_precision** Is a number between 0 and 1 specifying the percentage of the approximate nearest-neighbor searches that return the exact nearest-neighbor. Using a higher value for this parameter gives more accurate results, but the search takes longer. The optimum value usually depends on the application.
* **build_weight** Specifies the importance of the index build time raported to the nearest-neighbor search time. In some applications it's acceptable for the index build step to take a long time if the subsequent searches in the index can be performed very fast. In other applications it's required that the index be build as fast as possible even if that leads to slightly longer search times.
* **memory_weight** Is used to specify the tradeoff between time (index build time and search time) and memory used by the index. A value less than 1 gives more importance to the time spent and a value greater than 1 gives more importance to the memory usage.
* **memory_weight** Is used to specify the tradeoff between time (index build time and search time) and memory used by the index. A value less than 1 gives more importance to the time spent and a value greater than 1 gives more importance to the memory usage.
* **sample_fraction** Is a number between 0 and 1 indicating what fraction of the dataset to use in the automatic parameter configuration algorithm. Running the algorithm on the full dataset gives the most accurate results, but for very large datasets can take longer than desired. In such case using just a fraction of the data helps speeding up this algorithm while still giving good approximations of the optimum parameters.
*
**SavedIndexParams** This object type is used for loading a previously saved index from the disk. ::
struct SavedIndexParams : public IndexParams
{
SavedIndexParams( std::string filename );
};
..
* **filename** The filename in which the index was saved.
* **filename** The filename in which the index was saved.
flann::Index_<T>::knnSearch
----------------------------
Performs a K-nearest neighbor search for a given query point using the index.
:param indices: Vector that will contain the indices of the K-nearest neighbors found. It must have at least knn size.
:param dists: Vector that will contain the distances to the K-nearest neighbors found. It must have at least knn size.
:param knn: Number of nearest neighbors to search for.
:param query: The query point
:param indices: Vector that will contain the indices of the K-nearest neighbors found. It must have at least knn size.
:param dists: Vector that will contain the distances to the K-nearest neighbors found. It must have at least knn size.
:param knn: Number of nearest neighbors to search for.
:param params:
Search parameters ::
struct SearchParams {
SearchParams(int checks = 32);
};
..
* **checks** The number of times the tree(s) in the index should be recursively traversed. A higher value for this parameter would give better search precision, but also take more time. If automatic configuration was used when the index was created, the number of checks required to achieve the specified precision was also computed, in which case this parameter is ignored.
* **checks** The number of times the tree(s) in the index should be recursively traversed. A higher value for this parameter would give better search precision, but also take more time. If automatic configuration was used when the index was created, the number of checks required to achieve the specified precision was also computed, in which case this parameter is ignored.
flann::Index_<T>::radiusSearch
--------------------------------------
Performs a radius nearest neighbor search for a given query point.
:param indices: Vector that will contain the indices of the points found within the search radius in decreasing order of the distance to the query point. If the number of neighbors in the search radius is bigger than the size of this vector, the ones that don't fit in the vector are ignored.
:param dists: Vector that will contain the distances to the points found within the search radius
:param radius: The search radius
:param params: Search parameters
:param query: The query point
:param indices: Vector that will contain the indices of the points found within the search radius in decreasing order of the distance to the query point. If the number of neighbors in the search radius is bigger than the size of this vector, the ones that don't fit in the vector are ignored.
:param dists: Vector that will contain the distances to the points found within the search radius
:param fps: Framerate of the created video stream.
:param params: Encoder parameters. See :ocv:class:`gpu::VideoWriter_GPU::EncoderParams` .
:param params: Encoder parameters. See :ocv:struct:`gpu::VideoWriter_GPU::EncoderParams` .
:param format: Surface format of input frames ( ``SF_UYVY`` , ``SF_YUY2`` , ``SF_YV12`` , ``SF_NV12`` , ``SF_IYUV`` , ``SF_BGR`` or ``SF_GRAY``). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
The weak tree classifier, a component of the boosted tree classifier :ocv:class:`CvBoost`, is a derivative of :ocv:class:`CvDTree`. Normally, there is no need to use the weak classifiers directly. However, they can be accessed as elements of the sequence :ocv:member:`CvBoost::weak`, retrieved by :ocv:func:`CvBoost::get_weak_predictors`.
The weak tree classifier, a component of the boosted tree classifier :ocv:class:`CvBoost`, is a derivative of :ocv:class:`CvDTree`. Normally, there is no need to use the weak classifiers directly. However, they can be accessed as elements of the sequence ``CvBoost::weak``, retrieved by :ocv:func:`CvBoost::get_weak_predictors`.
.. note:: In case of LogitBoost and Gentle AdaBoost, each weak predictor is a regression tree, rather than a classification tree. Even in case of Discrete AdaBoost and Real AdaBoost, the ``CvBoostTree::predict`` return value (:ocv:member:`CvDTreeNode::value`) is not an output class label. A negative value "votes" for class #0, a positive value - for class #1. The votes are weighted. The weight of each individual tree may be increased or decreased using the method ``CvBoostTree::scale``.
...
...
@@ -233,4 +233,3 @@ CvBoost::get_data
Returns used train data of the boosted tree classifier.
@@ -148,7 +148,7 @@ Brute-force descriptor matcher. For each descriptor in the first set, this match
The class ``BruteForceMatcher_OCL_base`` has an interface similar to the class :ocv:class:`DescriptorMatcher`. It has two groups of ``match`` methods: for matching descriptors of one image with another image or with an image set. Also, all functions have an alternative to save results either to the GPU memory or to the CPU memory. ``BruteForceMatcher_OCL_base`` supports only the ``L1<float>``, ``L2<float>``, and ``Hamming`` distance types.
@@ -56,7 +56,7 @@ Class providing memory buffers for :ocv:func:`ocl::matchTemplate` function, plus
You can use field `user_block_size` to set specific block size for :ocv:func:`ocl::matchTemplate` function. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed.
ocl::matchTemplate
----------------------
------------------
Computes a proximity map for a raster template and an image where the template is searched for.