1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

put short descriptions right after the titles

This commit is contained in:
Vadim Pisarevsky
2011-06-24 16:27:57 +00:00
parent d758cca902
commit 0e3af357d3
36 changed files with 1033 additions and 1401 deletions
+1 -1
View File
@@ -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
------------------
+4 -11
View File
@@ -3,17 +3,12 @@ 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 termcrit, int attempts, int flags, OutputArray centers=noArray() )
Finds centers of clusters and groups input samples around the clusters.
:param samples: Floating-point matrix of input samples, one row per sample.
:param clusterCount: Number of clusters to split the set by.
@@ -53,15 +48,13 @@ 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.
.. ocv:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
:param vec: Set of elements stored as a vector.
+34 -45
View File
@@ -26,13 +26,11 @@ If a drawn figure is partially or completely outside the image, the drawing func
.. note:: The functions do not support alpha-transparency when the target image is 4-channel. In this case, the ``color[3]`` is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.
.. index:: circle
circle
----------
.. ocv:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a circle.
Draws a circle.
.. ocv:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
:param img: Image where the circle is drawn.
@@ -50,18 +48,16 @@ circle
The function ``circle`` draws a simple or filled circle with a given center and radius.
.. index:: clipLine
clipLine
------------
Clips the line against the image rectangle.
.. ocv:function:: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
.. ocv:function:: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
Clips the line against the image rectangle.
:param imgSize: Image size. The image rectangle is ``Rect(0, 0, imgSize.width, imgSize.height)`` .
:param imgSize: Image rectangle.?? why do you list the same para twice??
:param pt1: First line point.
@@ -71,16 +67,14 @@ clipLine
The functions ``clipLine`` calculate a part of the line segment that is entirely within the specified rectangle.
They return ``false`` if the line segment is completely outside the rectangle. Otherwise, they return ``true`` .
.. index:: ellipse
ellipse
-----------
Draws a simple or thick elliptic arc or fills an ellipse sector.
.. ocv:function:: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
.. ocv:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
Draws a simple or thick elliptic arc or fills an ellipse sector.
:param img: Image.
:param center: Center of the ellipse.
@@ -113,13 +107,11 @@ A piecewise-linear curve is used to approximate the elliptic arc boundary. If yo
.. image:: pics/ellipse.png
.. index:: ellipse2Poly
ellipse2Poly
----------------
.. ocv:function:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
Approximates an elliptic arc with a polyline.
Approximates an elliptic arc with a polyline.
.. ocv:function:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
:param center: Center of the arc.
@@ -138,13 +130,13 @@ ellipse2Poly
The function ``ellipse2Poly`` computes the vertices of a polyline that approximates the specified elliptic arc. It is used by
:ocv:func:`ellipse` .
.. index:: fillConvexPoly
fillConvexPoly
------------------
.. ocv:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
Fills a convex polygon.
Fills a convex polygon.
.. ocv:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
:param img: Image.
@@ -162,13 +154,13 @@ The function ``fillConvexPoly`` draws a filled convex polygon.
This function is much faster than the function ``fillPoly`` . It can fill not only convex polygons but any monotonic polygon without self-intersections,
that is, a polygon whose contour intersects every horizontal line (scan line) twice at the most (though, its top-most and/or the bottom edge could be horizontal).
.. index:: fillPoly
fillPoly
------------
.. ocv:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
Fills the area bounded by one or more polygons.
Fills the area bounded by one or more polygons.
.. ocv:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
:param img: Image.
@@ -187,22 +179,22 @@ fillPoly
The function ``fillPoly`` fills an area bounded by several polygonal contours. The function can fill complex areas, for example,
areas with holes, contours with self-intersections (some of thier parts), and so forth.
.. index:: getTextSize
getTextSize
---------------
.. ocv:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
Calculates the width and height of a text string.
Calculates the width and height of a text string.
.. ocv:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
:param text: Input text string.
:param fontFace: Font to use. See the :ocv:func:`putText` for details.
:param fontScale: Font scale. See the :ocv:func:`putText` for details.
:param thickness: Thickness of lines used to render the text. See :ocv:func:`putText` for details.
:param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
The function ``getTextSize`` calculates and returns the size of a box that contains the specified text.
@@ -238,13 +230,13 @@ That is, the following code renders some text, the tight box surrounding it, and
putText(img, text, textOrg, fontFace, fontScale,
Scalar::all(255), thickness, 8);
.. index:: line
line
--------
.. ocv:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a line segment connecting two points.
Draws a line segment connecting two points.
.. ocv:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
:param img: Image.
@@ -269,13 +261,10 @@ line
The function ``line`` draws the line segment between ``pt1`` and ``pt2`` points in the image. The line is clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings.
Antialiased lines are drawn using Gaussian filtering. To specify the line color, you may use the macro ``CV_RGB(r, g, b)`` .
.. index:: LineIterator
.. _LineIterator:
LineIterator
------------
.. c:type:: LineIterator
.. ocv:class:: LineIterator
Class for iterating pixels on a raster line. ::
@@ -315,16 +304,16 @@ The number of pixels along the line is stored in ``LineIterator::count`` . ::
for(int i = 0; i < it.count; i++, ++it)
buf[i] = *(const Vec3b)*it;
.. index:: rectangle
rectangle
-------------
Draws a simple, thick, or filled up-right rectangle.
.. ocv:function:: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
.. ocv:function:: void rectangle(Mat& img, Rect r, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a simple, thick, or filled up-right rectangle.
:param img: Image.
:param pt1: Vertex of the rectangle.
@@ -343,13 +332,13 @@ rectangle
The function ``rectangle`` draws a rectangle outline or a filled rectangle whose two opposite corners are ``pt1`` and ``pt2``, or ``r.tl()`` and ``r.br()-Point(1,1)``.
.. index:: polylines
polylines
-------------
.. ocv:function:: void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )
Draws several polygonal curves.
Draws several polygonal curves.
.. ocv:function:: void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )
:param img: Image.
@@ -371,13 +360,13 @@ polylines
The function ``polylines`` draws one or more polygonal curves.
.. index:: putText
putText
-----------
.. ocv:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
Draws a text string.
Draws a text string.
.. ocv:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
:param img: Image.
File diff suppressed because it is too large Load Diff
@@ -3,13 +3,11 @@ Utility and System Functions and Macros
.. highlight:: cpp
.. index:: alignPtr
alignPtr
------------
.. ocv:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
Aligns a pointer to the specified number of bytes.
Aligns a pointer to the specified number of bytes.
.. ocv:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
:param ptr: Aligned pointer.
@@ -21,13 +19,13 @@ The function returns the aligned pointer of the same type as the input pointer:
\texttt{(\_Tp*)(((size\_t)ptr + n-1) \& -n)}
.. index:: alignSize
alignSize
-------------
.. ocv:function:: size_t alignSize(size_t sz, int n)
Aligns a buffer size to the specified number of bytes.
Aligns a buffer size to the specified number of bytes.
.. ocv:function:: size_t alignSize(size_t sz, int n)
:param sz: Buffer size to align.
@@ -39,25 +37,25 @@ The function returns the minimum number that is greater or equal to ``sz`` and i
\texttt{(sz + n-1) \& -n}
.. index:: allocate
allocate
------------
.. ocv:function:: template<typename _Tp> _Tp* allocate(size_t n)
Allocates an array of elements.
Allocates an array of elements.
.. ocv:function:: template<typename _Tp> _Tp* allocate(size_t n)
:param n: Number of elements to allocate.
The generic function ``allocate`` allocates a buffer for the specified number of elements. For each element, the default constructor is called.
.. index:: deallocate
deallocate
--------------
.. ocv:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
Deallocates an array of elements.
Deallocates an array of elements.
.. ocv:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
:param ptr: Pointer to the deallocated buffer.
@@ -67,35 +65,23 @@ The generic function ``deallocate`` deallocates the buffer allocated with
:ocv:func:`allocate` . The number of elements must match the number passed to
:ocv:func:`allocate` .
.. index:: CV_Assert
CV_Assert
---------
Checks a condition at runtime and throws exception if it fails
.. ocv:function:: CV_Assert(expr)
Checks a condition at runtime. ::
The macros ``CV_Assert`` (and ``CV_DbgAssert``) evaluate the specified expression. If it is 0, the macros raise an error (see :ocv:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations while ``CV_DbgAssert`` is only retained in the Debug configuration.
#define CV_Assert( expr ) ...
#define CV_DbgAssert(expr) ...
..
:param expr: Expression to check.
The macros ``CV_Assert`` and ``CV_DbgAssert`` evaluate the specified expression. If it is 0, the macros raise an error (see
:ocv:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations while ``CV_DbgAssert`` is only retained in the Debug configuration.
.. index:: error
error
---------
Signals an error and raises an exception.
.. ocv:function:: void error( const Exception& exc )
.. ocv:function:: #define CV_Error( code, msg ) <...>
.. ocv:function:: #define CV_Error_( code, args ) <...>
Signals an error and raises an exception.
:param exc: Exception to throw.
:param code: Error code. Normally, it is a negative value. The list of pre-defined error codes can be found in ``cxerror.h`` .
@@ -104,7 +90,12 @@ error
:param args: ``printf`` -like formatted error message in parentheses.
The function and the helper macros ``CV_Error`` and ``CV_Error_`` call the error handler. Currently, the error handler prints the error code ( ``exc.code`` ), the context ( ``exc.file``,``exc.line`` ), and the error message ``exc.err`` to the standard error stream ``stderr`` . In the Debug configuration, it then provokes memory access violation, so that the execution stack and all the parameters can be analyzed by the debugger. In the Release configuration, the exception ``exc`` is thrown.
The function and the helper macros ``CV_Error`` and ``CV_Error_``: ::
#define CV_Error( code, msg ) error(...)
#define CV_Error_( code, args ) error(...)
call the error handler. Currently, the error handler prints the error code ( ``exc.code`` ), the context ( ``exc.file``,``exc.line`` ), and the error message ``exc.err`` to the standard error stream ``stderr`` . In the Debug configuration, it then provokes memory access violation, so that the execution stack and all the parameters can be analyzed by the debugger. In the Release configuration, the exception ``exc`` is thrown.
The macro ``CV_Error_`` can be used to construct an error message on-fly to include some dynamic information, for example: ::
@@ -113,8 +104,6 @@ The macro ``CV_Error_`` can be used to construct an error message on-fly to incl
("the matrix element (
i, j, mtx.at<float>(i,j)))
.. index:: Exception
Exception
---------
@@ -147,25 +136,25 @@ Exception class passed to an error. ::
The class ``Exception`` encapsulates all or almost all necessary information about the error happened in the program. The exception is usually constructed and thrown implicitly via ``CV_Error`` and ``CV_Error_`` macros. See
:ocv:func:`error` .
.. index:: fastMalloc
fastMalloc
--------------
.. ocv:function:: void* fastMalloc(size_t size)
Allocates an aligned memory buffer.
Allocates an aligned memory buffer.
.. ocv:function:: void* fastMalloc(size_t size)
:param size: Allocated buffer size.
The function allocates the buffer of the specified size and returns it. When the buffer size is 16 bytes or more, the returned buffer is aligned to 16 bytes.
.. index:: fastFree
fastFree
------------
.. ocv:function:: void fastFree(void* ptr)
Deallocates a memory buffer.
Deallocates a memory buffer.
.. ocv:function:: void fastFree(void* ptr)
:param ptr: Pointer to the allocated buffer.
@@ -173,26 +162,26 @@ The function deallocates the buffer allocated with
:ocv:func:`fastMalloc` .
If NULL pointer is passed, the function does nothing.
.. index:: format
format
----------
.. ocv:function:: string format( const char* fmt, ... )
Returns a text string formatted using the ``printf`` -like expression.
Returns a text string formatted using the ``printf`` -like expression.
.. ocv:function:: string format( const char* fmt, ... )
:param fmt: ``printf`` -compatible formatting specifiers.
The function acts like ``sprintf`` but forms and returns an STL string. It can be used to form an error message in the
:ocv:func:`Exception` constructor.
.. index:: getNumThreads
getNumThreads
-----------------
.. ocv:function:: int getNumThreads()
Returns the number of threads used by OpenCV.
Returns the number of threads used by OpenCV.
.. ocv:function:: int getNumThreads()
The function returns the number of threads that is used by OpenCV.
@@ -200,13 +189,13 @@ The function returns the number of threads that is used by OpenCV.
:ocv:func:`setNumThreads`,
:ocv:func:`getThreadNum`
.. index:: getThreadNum
getThreadNum
----------------
.. ocv:function:: int getThreadNum()
Returns the index of the currently executed thread.
Returns the index of the currently executed thread.
.. ocv:function:: int getThreadNum()
The function returns a 0-based index of the currently executed thread. The function is only valid inside a parallel OpenMP region. When OpenCV is built without OpenMP support, the function always returns 0.
@@ -214,25 +203,25 @@ The function returns a 0-based index of the currently executed thread. The funct
:ocv:func:`setNumThreads`,
:ocv:func:`getNumThreads` .
.. index:: getTickCount
getTickCount
----------------
.. ocv:function:: int64 getTickCount()
Returns the number of ticks.
Returns the number of ticks.
.. ocv:function:: int64 getTickCount()
The function returns the number of ticks after the certain event (for example, when the machine was turned on).
It can be used to initialize
:ocv:func:`RNG` or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
.. index:: getTickFrequency
getTickFrequency
--------------------
.. ocv:function:: double getTickFrequency()
Returns the number of ticks per second.
Returns the number of ticks per second.
.. ocv:function:: double getTickFrequency()
The function returns the number of ticks per second.
That is, the following code computes the execution time in seconds: ::
@@ -241,23 +230,23 @@ That is, the following code computes the execution time in seconds: ::
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency();
.. index:: getCPUTickCount
getCPUTickCount
----------------
.. ocv:function:: int64 getCPUTickCount()
Returns the number of CPU ticks.
Returns the number of CPU ticks.
.. ocv:function:: int64 getCPUTickCount()
The function returns the current number of CPU ticks on some architectures (such as x86, x64, PowerPC). On other platforms the function is equivalent to ``getTickCount``. It can also be used for very accurate time measurements, as well as for RNG initialization. Note that in case of multi-CPU systems a thread, from which ``getCPUTickCount`` is called, can be suspended and resumed at another CPU with its own counter. So, theoretically (and practically) the subsequent calls to the function do not necessary return the monotonously increasing values. Also, since a modern CPU varies the CPU frequency depending on the load, the number of CPU clocks spent in some code cannot be directly converted to time units. Therefore, ``getTickCount`` is generally a preferable solution for measuring execution time.
.. index:: setNumThreads
setNumThreads
-----------------
.. ocv:function:: void setNumThreads(int nthreads)
Sets the number of threads used by OpenCV.
Sets the number of threads used by OpenCV.
.. ocv:function:: void setNumThreads(int nthreads)
:param nthreads: Number of threads used by OpenCV.
@@ -267,13 +256,13 @@ The function sets the number of threads used by OpenCV in parallel OpenMP region
:ocv:func:`getNumThreads`,
:ocv:func:`getThreadNum`
.. index:: setUseOptimized
setUseOptimized
-----------------
.. ocv:function:: void setUseOptimized(bool onoff)
Enables or disables the optimized code.
Enables or disables the optimized code.
.. ocv:function:: void setUseOptimized(bool onoff)
:param onoff: The boolean flag specifying whether the optimized code should be used (``onoff=true``) or not (``onoff=false``).
@@ -281,12 +270,10 @@ The function can be used to dynamically turn on and off optimized code (code tha
By default, the optimized code is enabled unless you disable it in CMake. The current status can be retrieved using ``useOptimized``.
.. index:: useOptimized
useOptimized
-----------------
Returns the status of optimized code usage.
.. ocv:function:: bool useOptimized()
Returns the status of optimized code usage.
The function returns ``true`` if the optimized code is enabled. Otherwise, it returns ``false``.
@@ -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
-----------------
@@ -93,9 +93,9 @@ Abstract base class for 2D image feature detectors. ::
FeatureDetector::detect
---------------------------
.. ocv:function:: void FeatureDetector::detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const
Detects keypoints in an image (first variant) or image set (second variant).
Detects keypoints in an image (first variant) or image set (second variant).
.. ocv:function:: void FeatureDetector::detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const
:param image: Image.
@@ -113,25 +113,25 @@ FeatureDetector::detect
FeatureDetector::read
-------------------------
.. ocv:function:: void FeatureDetector::read( const FileNode& fn )
Reads a feature detector object from a file node.
Reads a feature detector object from a file node.
.. ocv:function:: void FeatureDetector::read( const FileNode& fn )
:param fn: File node from which the detector is read.
FeatureDetector::write
--------------------------
.. ocv:function:: void FeatureDetector::write( FileStorage& fs ) const
Writes a feature detector object to a file storage.
Writes a feature detector object to a file storage.
.. ocv:function:: void FeatureDetector::write( FileStorage& fs ) const
:param fs: File storage where the detector is written.
FeatureDetector::create
---------------------------
.. ocv:function:: Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
Creates a feature detector by its name.
Creates a feature detector by its name.
.. ocv:function:: Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
:param detectorType: Feature detector type.
@@ -457,12 +457,11 @@ Example of creating ``DynamicAdaptedFeatureDetector`` : ::
new FastAdjuster(20,true)));
DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector
----------------------------------------------------------------
.. ocv:function:: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features, int max_features, int max_iters )
The constructor
Constructs the class.
.. ocv:function:: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features, int max_features, int max_iters )
:param adjuster: :ocv:class:`AdjusterAdapter` that detects features and adjusts parameters.
@@ -497,9 +496,9 @@ See
AdjusterAdapter::tooFew
---------------------------
.. ocv:function:: void AdjusterAdapter::tooFew(int min, int n_detected)
Adjusts the detector parameters to detect more features.
Adjusts the detector parameters to detect more features.
.. ocv:function:: void AdjusterAdapter::tooFew(int min, int n_detected)
:param min: Minimum desired number of features.
@@ -514,9 +513,9 @@ Example: ::
AdjusterAdapter::tooMany
----------------------------
.. ocv:function:: void AdjusterAdapter::tooMany(int max, int n_detected)
Adjusts the detector parameters to detect less features.
Adjusts the detector parameters to detect less features.
.. ocv:function:: void AdjusterAdapter::tooMany(int max, int n_detected)
:param max: Maximum desired number of features.
@@ -532,9 +531,9 @@ Example: ::
AdjusterAdapter::good
-------------------------
.. ocv:function:: bool AdjusterAdapter::good() const
Returns false if the detector parameters cannot be adjusted any more.
Returns false if the detector parameters cannot be adjusted any more.
.. ocv:function:: bool AdjusterAdapter::good() const
Example: ::
@@ -545,6 +544,8 @@ Example: ::
AdjusterAdapter::create
-------------------------
Creates an adjuster adapter by name
.. ocv:function:: Ptr<AdjusterAdapter> AdjusterAdapter::create( const string& detectorType )
Creates an adjuster adapter by name ``detectorType``. The detector name is the same as in :ocv:func:`FeatureDetector::create`, but now supports ``"FAST"``, ``"STAR"``, and ``"SURF"`` only.
@@ -11,7 +11,7 @@ Every descriptor with the
:ocv:class:`VectorDescriptorMatcher` ).
There are descriptors such as the One-way descriptor and Ferns that have the ``GenericDescriptorMatcher`` interface implemented but do not support ``DescriptorExtractor``.
.. index:: GenericDescriptorMatcher
GenericDescriptorMatcher
------------------------
@@ -79,68 +79,69 @@ Abstract interface for extracting and matching a keypoint descriptor. There are
};
.. index:: GenericDescriptorMatcher::add
GenericDescriptorMatcher::add
---------------------------------
.. ocv:function:: void GenericDescriptorMatcher::add( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints )
Adds images and their keypoints to the training collection stored in the class instance.
Adds images and their keypoints to the training collection stored in the class instance.
.. ocv:function:: void GenericDescriptorMatcher::add( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints )
:param images: Image collection.
:param keypoints: Point collection. It is assumed that ``keypoints[i]`` are keypoints detected in the image ``images[i]`` .
.. index:: GenericDescriptorMatcher::getTrainImages
GenericDescriptorMatcher::getTrainImages
--------------------------------------------
Returns a train image collection.
.. ocv:function:: const vector<Mat>& GenericDescriptorMatcher::getTrainImages() const
Returns a train image collection.
.. index:: GenericDescriptorMatcher::getTrainKeypoints
GenericDescriptorMatcher::getTrainKeypoints
-----------------------------------------------
Returns a train keypoints collection.
.. ocv:function:: const vector<vector<KeyPoint> >& GenericDescriptorMatcher::getTrainKeypoints() const
Returns a train keypoints collection.
.. index:: GenericDescriptorMatcher::clear
GenericDescriptorMatcher::clear
-----------------------------------
Clears a train collection (images and keypoints).
.. ocv:function:: void GenericDescriptorMatcher::clear()
Clears a train collection (images and keypoints).
.. index:: GenericDescriptorMatcher::train
GenericDescriptorMatcher::train
-----------------------------------
Trains descriptor matcher
.. ocv:function:: void GenericDescriptorMatcher::train()
Trains an object, for example, a tree-based structure, to extract descriptors or to optimize descriptors matching.
Prepares descriptor matcher, for example, creates a tree-based structure, to extract descriptors or to optimize descriptors matching.
.. index:: GenericDescriptorMatcher::isMaskSupported
GenericDescriptorMatcher::isMaskSupported
---------------------------------------------
Returns ``true`` if a generic descriptor matcher supports masking permissible matches.
.. ocv:function:: void GenericDescriptorMatcher::isMaskSupported()
Returns ``true`` if a generic descriptor matcher supports masking permissible matches.
.. index:: GenericDescriptorMatcher::classify
GenericDescriptorMatcher::classify
--------------------------------------
Classifies keypoints from a query set.
.. ocv:function:: void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, const Mat& trainImage, vector<KeyPoint>& trainKeypoints ) const
.. ocv:function:: void GenericDescriptorMatcher::classify( const Mat& queryImage, vector<KeyPoint>& queryKeypoints )
Classifies keypoints from a query set.
:param queryImage: Query image.
:param queryKeypoints: Keypoints from a query image.
@@ -159,15 +160,15 @@ The methods do the following:
#.
Set the ``class_id`` field of each keypoint from the query set to ``class_id`` of the corresponding keypoint from the training set.
.. index:: GenericDescriptorMatcher::match
GenericDescriptorMatcher::match
-----------------------------------
.. ocv:function:: void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, const Mat& trainImage, vector<KeyPoint>& trainKeypoints, vector<DMatch>& matches, const Mat& mask=Mat() ) const
Finds the best match in the training set for each keypoint from the query set.
.. ocv:function:: void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, vector<DMatch>& matches, const vector<Mat>& masks=vector<Mat>() )
.. ocv:function:: void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, const Mat& trainImage, vector<KeyPoint>& trainKeypoints, vector<DMatch>& matches, const Mat& mask=Mat() ) const
Finds the best match in the training set for each keypoint from the query set.
.. ocv:function:: void GenericDescriptorMatcher::match( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, vector<DMatch>& matches, const vector<Mat>& masks=vector<Mat>() )
:param queryImage: Query image.
@@ -185,61 +186,57 @@ GenericDescriptorMatcher::match
The methods find the best match for each query keypoint. In the first variant of the method, a train image and its keypoints are the input arguments. In the second variant, query keypoints are matched to the internally stored training collection that can be built using the ``GenericDescriptorMatcher::add`` method. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, ``queryKeypoints[i]`` can be matched with ``trainKeypoints[j]`` only if ``mask.at<uchar>(i,j)`` is non-zero.
.. index:: GenericDescriptorMatcher::knnMatch
GenericDescriptorMatcher::knnMatch
--------------------------------------
Finds the ``k`` best matches for each query keypoint.
.. ocv:function:: void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, const Mat& trainImage, vector<KeyPoint>& trainKeypoints, vector<vector<DMatch> >& matches, int k, const Mat& mask=Mat(), bool compactResult=false ) const
.. ocv:function:: void GenericDescriptorMatcher::knnMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, vector<vector<DMatch> >& matches, int k, const vector<Mat>& masks=vector<Mat>(), bool compactResult=false )
Finds the ``k`` best matches for each query keypoint.
The methods are extended variants of ``GenericDescriptorMatch::match``. The parameters are similar, and the the semantics is similar to ``DescriptorMatcher::knnMatch``. But this class does not require explicitly computed keypoint descriptors.
.. index:: GenericDescriptorMatcher::radiusMatch
GenericDescriptorMatcher::radiusMatch
-----------------------------------------
For each query keypoint, finds the training keypoints not farther than the specified distance.
.. ocv:function:: void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, const Mat& trainImage, vector<KeyPoint>& trainKeypoints, vector<vector<DMatch> >& matches, float maxDistance, const Mat& mask=Mat(), bool compactResult=false ) const
.. ocv:function:: void GenericDescriptorMatcher::radiusMatch( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, vector<vector<DMatch> >& matches, float maxDistance, const vector<Mat>& masks=vector<Mat>(), bool compactResult=false )
For each query keypoint, finds the training keypoints not farther than the specified distance.
The methods are similar to ``DescriptorMatcher::radius``. But this class does not require explicitly computed keypoint descriptors.
.. index:: GenericDescriptorMatcher::read
GenericDescriptorMatcher::read
----------------------------------
Reads a matcher object from a file node.
.. ocv:function:: void GenericDescriptorMatcher::read( const FileNode& fn )
Reads a matcher object from a file node.
.. index:: GenericDescriptorMatcher::write
GenericDescriptorMatcher::write
-----------------------------------
Writes a match object to a file storage.
.. ocv:function:: void GenericDescriptorMatcher::write( FileStorage& fs ) const
Writes a match object to a file storage.
.. index:: GenericDescriptorMatcher::clone
GenericDescriptorMatcher::clone
-----------------------------------
.. ocv:function:: Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::clone( bool emptyTrainData ) const
Clones the matcher.
Clones the matcher.
.. ocv:function:: Ptr<GenericDescriptorMatcher> GenericDescriptorMatcher::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:: OneWayDescriptorMatcher
.. _OneWayDescriptorMatcher:
OneWayDescriptorMatcher
-----------------------
@@ -298,7 +295,7 @@ Wrapping class for computing, matching, and classifying descriptors using the
};
.. index:: FernDescriptorMatcher
FernDescriptorMatcher
---------------------
@@ -355,9 +352,7 @@ Wrapping class for computing, matching, and classifying descriptors using the
};
.. index:: VectorDescriptorMatcher
.. _VectorDescriptorMatcher:
VectorDescriptorMatcher
-----------------------
@@ -1,16 +1,16 @@
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.
@@ -3,13 +3,13 @@ Feature Detection and Description
.. highlight:: cpp
.. index:: FAST
FAST
--------
.. ocv:function:: void FAST( const Mat& image, vector<KeyPoint>& keypoints, int threshold, bool nonmaxSupression=true )
Detects corners using the FAST algorithm
Detects corners using the FAST algorithm by E. Rosten (*Machine Learning for High-speed Corner Detection*, 2006).
.. ocv:function:: void FAST( const Mat& image, vector<KeyPoint>& keypoints, int threshold, bool nonmaxSupression=true )
:param image: Image where keypoints (corners) are detected.
@@ -19,9 +19,8 @@ FAST
:param nonmaxSupression: If it is true, non-maximum supression is applied to detected corners (keypoints).
.. index:: MSER
Detects corners using the FAST algorithm by E. Rosten (*Machine Learning for High-speed Corner Detection*, 2006).
.. _MSER:
MSER
----
@@ -48,9 +47,6 @@ Maximally stable extremal region extractor. ::
The class encapsulates all the parameters of the MSER extraction algorithm (see
http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions). Also see http://opencv.willowgarage.com/wiki/documentation/cpp/features2d/MSER for usefull comments and parameters description.
.. index:: StarDetector
.. _StarDetector:
StarDetector
------------
@@ -87,7 +83,7 @@ Class implementing the ``Star`` keypoint detector. ::
The class implements a modified version of the ``CenSurE`` keypoint detector described in
[Agrawal08].
.. index:: SIFT
SIFT
----
@@ -175,7 +171,7 @@ Class for extracting keypoints and computing descriptors using the Scale Invaria
};
.. index:: SURF
SURF
----
@@ -213,7 +209,7 @@ There is a fast multi-scale Hessian keypoint detector that can be used to find k
The algorithm can be used for object tracking and localization, image stitching, and so on. See the ``find_obj.cpp`` demo in the OpenCV samples directory.
.. index:: ORB
ORB
----
@@ -269,7 +265,7 @@ Class for extracting ORB features and descriptors from an image. ::
The class implements ORB.
.. index:: RandomizedTree
RandomizedTree
@@ -344,13 +340,13 @@ Class containing a base structure for ``RTreeClassifier``. ::
void estimateQuantPercForPosteriors(float perc[2]);
};
.. index:: RandomizedTree::train
RandomizedTree::train
-------------------------
.. ocv:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
Trains a randomized tree using an input set of keypoints.
Trains a randomized tree using an input set of keypoints.
.. ocv:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
.. ocv:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
@@ -368,37 +364,37 @@ RandomizedTree::train
:param num_quant_bits: Number of bits used for quantization.
.. index:: RandomizedTree::read
RandomizedTree::read
------------------------
Reads a pre-saved randomized tree from a file or stream.
.. ocv:function:: read(const char* file_name, int num_quant_bits)
.. ocv:function:: read(std::istream &is, int num_quant_bits)
Reads a pre-saved randomized tree from a file or stream.
:param file_name: Name of the file that contains randomized tree data.
:param is: Input stream associated with the file that contains randomized tree data.
:param num_quant_bits: Number of bits used for quantization.
.. index:: RandomizedTree::write
RandomizedTree::write
-------------------------
Writes the current randomized tree to a file or stream.
.. ocv:function:: void write(const char* file_name) const
Writes the current randomized tree to a file or stream.
.. ocv:function:: void write(std::ostream \&os) const
.. ocv:function:: void write(std::ostream &os) const
:param file_name: Name of the file where randomized tree data is stored.
:param is: Output stream associated with the file where randomized tree data is stored.
.. index:: RandomizedTree::applyQuantization
RandomizedTree::applyQuantization
-------------------------------------
@@ -408,9 +404,6 @@ RandomizedTree::applyQuantization
:param num_quant_bits: Number of bits used for quantization.
.. index:: RTreeNode
.. _RTreeNode:
RTreeNode
---------
@@ -436,9 +429,7 @@ Class containing a base structure for ``RandomizedTree``. ::
}
};
.. index:: RTreeClassifier
.. _RTreeClassifier:
RTreeClassifier
---------------
@@ -508,13 +499,13 @@ Class containing ``RTreeClassifier``. It represents the Calonder descriptor orig
bool keep_floats_;
};
.. index:: RTreeClassifier::train
RTreeClassifier::train
--------------------------
.. ocv:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
Trains a randomized tree classifier using an input set of keypoints.
Trains a randomized tree classifier using an input set of keypoints.
.. ocv:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
.. ocv:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
@@ -536,41 +527,41 @@ RTreeClassifier::train
:param print_status: Current status of training printed on the console.
.. index:: RTreeClassifier::getSignature
RTreeClassifier::getSignature
---------------------------------
.. ocv:function:: void getSignature(IplImage *patch, uchar *sig)
Returns a signature for an image patch.
Returns a signature for an image patch.
.. ocv:function:: void getSignature(IplImage *patch, uchar *sig)
.. ocv:function:: void getSignature(IplImage *patch, float *sig)
:param patch: Image patch to calculate the signature for.
:param sig: Output signature (array dimension is ``reduced_num_dim)`` .
.. index:: RTreeClassifier::getSparseSignature
RTreeClassifier::getSparseSignature
---------------------------------------
Returns a sparse signature for an image patch
.. ocv:function:: void getSparseSignature(IplImage *patch, float *sig, float thresh)
Returns a signature for an image patch similarly to ``getSignature`` but uses a threshold for removing all signature elements below the threshold so that the signature is compressed.
:param patch: Image patch to calculate the signature for.
:param sig: Output signature (array dimension is ``reduced_num_dim)`` .
:param thresh: Threshold used for compressing the signature.
.. index:: RTreeClassifier::countNonZeroElements
Returns a signature for an image patch similarly to ``getSignature`` but uses a threshold for removing all signature elements below the threshold so that the signature is compressed.
RTreeClassifier::countNonZeroElements
-----------------------------------------
.. ocv:function:: static int countNonZeroElements(float *vec, int n, double tol=1e-10)
Returns the number of non-zero elements in an input array.
Returns the number of non-zero elements in an input array.
.. ocv:function:: static int countNonZeroElements(float *vec, int n, double tol=1e-10)
:param vec: Input vector containing float elements.
@@ -578,13 +569,13 @@ RTreeClassifier::countNonZeroElements
:param tol: Threshold used for counting elements. All elements less than ``tol`` are considered as zero elements.
.. index:: RTreeClassifier::read
RTreeClassifier::read
-------------------------
.. ocv:function:: read(const char* file_name)
Reads a pre-saved ``RTreeClassifier`` from a file or stream.
Reads a pre-saved ``RTreeClassifier`` from a file or stream.
.. ocv:function:: read(const char* file_name)
.. ocv:function:: read(std::istream& is)
@@ -592,13 +583,13 @@ RTreeClassifier::read
:param is: Input stream associated with the file that contains randomized tree data.
.. index:: RTreeClassifier::write
RTreeClassifier::write
--------------------------
.. ocv:function:: void write(const char* file_name) const
Writes the current ``RTreeClassifier`` to a file or stream.
Writes the current ``RTreeClassifier`` to a file or stream.
.. ocv:function:: void write(const char* file_name) const
.. ocv:function:: void write(std::ostream &os) const
@@ -606,13 +597,13 @@ RTreeClassifier::write
:param os: Output stream associated with the file where randomized tree data is stored.
.. index:: RTreeClassifier::setQuantization
RTreeClassifier::setQuantization
------------------------------------
.. ocv:function:: void setQuantization(int num_quant_bits)
Applies quantization to the current randomized tree.
Applies quantization to the current randomized tree.
.. ocv:function:: void setQuantization(int num_quant_bits)
:param num_quant_bits: Number of bits used for quantization.
@@ -34,42 +34,41 @@ Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. ::
BOWTrainer::add
-------------------
.. ocv:function:: void BOWTrainer::add( const Mat& descriptors )
Adds descriptors to a training set.
Adds descriptors to a training set. The training set is clustered using ``clustermethod`` to construct the vocabulary.
.. ocv:function:: void BOWTrainer::add( const Mat& descriptors )
:param descriptors: Descriptors to add to a training set. Each row of the ``descriptors`` matrix is a descriptor.
The training set is clustered using ``clustermethod`` to construct the vocabulary.
BOWTrainer::getDescriptors
------------------------------
Returns a training set of descriptors.
.. ocv:function:: const vector<Mat>& BOWTrainer::getDescriptors() const
Returns a training set of descriptors.
.. index:: BOWTrainer::descripotorsCount
BOWTrainer::descripotorsCount
---------------------------------
Returns the count of all descriptors stored in the training set.
.. ocv:function:: const vector<Mat>& BOWTrainer::descripotorsCount() const
Returns the count of all descriptors stored in the training set.
.. index:: BOWTrainer::cluster
BOWTrainer::cluster
-----------------------
.. ocv:function:: Mat BOWTrainer::cluster() const
Clusters train descriptors.
Clusters train descriptors. The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first variant of the method, train descriptors stored in the object are clustered. In the second variant, input descriptors are clustered.
.. ocv:function:: Mat BOWTrainer::cluster() const
.. ocv:function:: Mat BOWTrainer::cluster( const Mat& descriptors ) const
:param descriptors: Descriptors to cluster. Each row of the ``descriptors`` matrix is a descriptor. Descriptors are not added to the inner train descriptor set.
.. index:: BOWKMeansTrainer
.. _BOWKMeansTrainer:
The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first variant of the method, train descriptors stored in the object are clustered. In the second variant, input descriptors are clustered.
BOWKMeansTrainer
----------------
@@ -94,7 +93,9 @@ BOWKMeansTrainer
};
BOWKMeansTrainer::BOWKMeansTrainer
----------------
----------------------------------
The constructor.
.. ocv:function:: BOWKMeansTrainer::BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(), int attempts=3, int flags=KMEANS_PP_CENTERS );
See :ocv:func:`kmeans` function parameters.
@@ -132,43 +133,43 @@ The class declaration is the following: ::
};
.. index:: BOWImgDescriptorExtractor::BOWImgDescriptorExtractor
BOWImgDescriptorExtractor::BOWImgDescriptorExtractor
--------------------------------------------------------
.. ocv:function:: BOWImgDescriptorExtractor::BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor, const Ptr<DescriptorMatcher>& dmatcher )
The constructor.
Constructs a class.
.. ocv:function:: BOWImgDescriptorExtractor::BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor, const Ptr<DescriptorMatcher>& dmatcher )
:param dextractor: Descriptor extractor that is used to compute descriptors for an input image and its keypoints.
:param dmatcher: Descriptor matcher that is used to find the nearest word of the trained vocabulary for each keypoint descriptor of the image.
.. index:: BOWImgDescriptorExtractor::setVocabulary
BOWImgDescriptorExtractor::setVocabulary
--------------------------------------------
.. ocv:function:: void BOWImgDescriptorExtractor::setVocabulary( const Mat& vocabulary )
Sets a visual vocabulary.
Sets a visual vocabulary.
.. ocv:function:: void BOWImgDescriptorExtractor::setVocabulary( const Mat& vocabulary )
:param vocabulary: Vocabulary (can be trained using the inheritor of :ocv:class:`BOWTrainer` ). Each row of the vocabulary is a visual word (cluster center).
.. index:: BOWImgDescriptorExtractor::getVocabulary
BOWImgDescriptorExtractor::getVocabulary
--------------------------------------------
Returns the set vocabulary.
.. ocv:function:: const Mat& BOWImgDescriptorExtractor::getVocabulary() const
Returns the set vocabulary.
.. index:: BOWImgDescriptorExtractor::compute
BOWImgDescriptorExtractor::compute
--------------------------------------
.. ocv:function:: void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor, vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 )
Computes an image descriptor using the set visual vocabulary.
Computes an image descriptor using the set visual vocabulary.
.. ocv:function:: void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor, vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 )
:param image: Image, for which the descriptor is computed.
@@ -180,19 +181,19 @@ BOWImgDescriptorExtractor::compute
:param descriptors: Descriptors of the image keypoints that are returned if they are non-zero.
.. index:: BOWImgDescriptorExtractor::descriptorSize
BOWImgDescriptorExtractor::descriptorSize
---------------------------------------------
Returns an image discriptor size if the vocabulary is set. Otherwise, it returns 0.
.. ocv:function:: int BOWImgDescriptorExtractor::descriptorSize() const
Returns an image discriptor size if the vocabulary is set. Otherwise, it returns 0.
.. index:: BOWImgDescriptorExtractor::descriptorType
BOWImgDescriptorExtractor::descriptorType
---------------------------------------------
Returns an image descriptor type.
.. ocv:function:: int BOWImgDescriptorExtractor::descriptorType() const
Returns an image descriptor type.
+14 -36
View File
@@ -56,15 +56,12 @@ The following code is an example used to generate the figure. ::
return 0;
}
.. index:: setWindowProperty
.. _setWindowProperty:
setWindowProperty
---------------------
.. ocv:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
Changes parameters of a window dynamically.
Changes parameters of a window dynamically.
.. ocv:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
:param name: Name of the window.
@@ -92,13 +89,11 @@ setWindowProperty
The function ``setWindowProperty`` enables changing properties of a window.
.. index:: getWindowProperty
getWindowProperty
---------------------
.. ocv:function:: void getWindowProperty(const string& name, int prop_id)
Provides parameters of a window.
Provides parameters of a window.
.. ocv:function:: void getWindowProperty(const string& name, int prop_id)
:param name: Name of the window.
@@ -116,15 +111,11 @@ See
The function ``getWindowProperty`` returns properties of a window.
.. index:: fontQt
.. _fontQt:
fontQt
----------
.. ocv:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0)
Creates the font to draw a text on an image.
Creates the font to draw a text on an image.
.. ocv:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0)
:param nameFont: Name of the font. The name should match the name of a system font (such as *Times*). If the font is not found, a default one is used.
@@ -163,13 +154,12 @@ A basic usage of this function is the following: ::
CvFont font = fontQt(''Times'');
addText( img1, ``Hello World !'', Point(50,50), font);
.. index:: addText
addText
-----------
.. ocv:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
Creates the font to draw a text on an image.
Creates the font to draw a text on an image.
.. ocv:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
:param img: 8-bit 3-channel image where the text should be drawn.
@@ -204,13 +194,12 @@ displayOverlay
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time *delay*. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.
.. index:: displayStatusBar
displayStatusBar
--------------------
.. ocv:function:: void displayStatusBar(const string& name, const string& text, int delay)
Displays a text on the window statusbar during the specified period of time.
Displays a text on the window statusbar during the specified period of time.
.. ocv:function:: void displayStatusBar(const string& name, const string& text, int delay)
:param name: Name of the window.
@@ -222,15 +211,12 @@ The function ``displayOverlay`` displays useful information/tips on top of the w
*delay*
. This information is displayed on the window statubar (the window must be created with the ``CV_GUI_EXPANDED`` flags).
.. index:: createOpenGLCallback
createOpenGLCallback
------------------------
Creates a callback function called to draw OpenGL on top the the image display by ``windowname``.
.. ocv:function:: void createOpenGLCallback( const string& window_name, OpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1)
Creates a callback function called to draw OpenGL on top the the image display by ``windowname``.
:param window_name: Name of the window.
:param callbackOpenGL: Pointer to the function to be called every frame. This function should be prototyped as ``void Foo(*void);`` .
@@ -274,43 +260,35 @@ The function ``createOpenGLCallback`` can be used to draw 3D data on the window.
}
}
.. index:: saveWindowParameters
saveWindowParameters
------------------------
Saves parameters of the specified window.
.. ocv:function:: void saveWindowParameters(const string& name)
Saves parameters of the window ``windowname`` .
:param name: Name of the window.
The function ``saveWindowParameters`` saves size, location, flags, trackbars value, zoom and panning location of the window
``window_name`` .
.. index:: loadWindowParameters
loadWindowParameters
------------------------
Loads parameters of the specified window.
.. ocv:function:: void loadWindowParameters(const string& name)
Loads parameters of the window ``windowname`` .
:param name: Name of the window.
The function ``loadWindowParameters`` loads size, location, flags, trackbars value, zoom and panning location of the window
``window_name`` .
.. index:: createButton
createButton
----------------
Attaches a button to the control panel.
.. ocv:function:: createButton( const string& button_name CV_DEFAULT(NULL),ButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL), int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0))
Attaches a button to the control panel.
:param button_name: Name of the button.
:param on_change: Pointer to the function to be called every time the button changes its state. This function should be prototyped as ``void Foo(int state,*void);`` . *state* is the current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
@@ -3,15 +3,11 @@ Reading and Writing Images and Video
.. highlight:: cpp
.. index:: imdecode
.. _imdecode:
imdecode
------------
.. ocv:function:: Mat imdecode( InputArray buf, int flags )
Reads an image from a buffer in memory.
Reads an image from a buffer in memory.
.. ocv:function:: Mat imdecode( InputArray buf, int flags )
:param buf: Input array of vector of bytes.
@@ -23,15 +19,11 @@ If the buffer is too short or contains invalid data, the empty matrix is returne
See
:ref:`imread` for the list of supported formats and flags description.
.. index:: imencode
.. _imencode:
imencode
------------
.. ocv:function:: bool imencode( const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>())
Encode an image into a memory buffer.
Encode an image into a memory buffer.
.. ocv:function:: bool imencode( const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>())
:param ext: File extension that defines the output format.
@@ -45,15 +37,11 @@ The function compresses the image and stores it in the memory buffer that is res
See
:ref:`imwrite` for the list of supported formats and flags description.
.. index:: imread
.. _imread:
imread
----------
.. ocv:function:: Mat imread( const string& filename, int flags=1 )
Loads an image from a file.
Loads an image from a file.
.. ocv:function:: Mat imread( const string& filename, int flags=1 )
:param filename: Name of file to be loaded.
@@ -89,15 +77,11 @@ The function ``imread`` loads an image from the specified file and returns it. I
* On Linux*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, "libjpeg-dev", in Debian* and Ubuntu*) to get the codec support or turn on the ``OPENCV_BUILD_3RDPARTY_LIBS`` flag in CMake.
.. index:: imwrite
.. _imwrite:
imwrite
-----------
.. ocv:function:: bool imwrite( const string& filename, InputArray img, const vector<int>& params=vector<int>())
Saves an image to a specified file.
Saves an image to a specified file.
.. ocv:function:: bool imwrite( const string& filename, InputArray img, const vector<int>& params=vector<int>())
:param filename: Name of the file.
@@ -116,13 +100,9 @@ The function ``imwrite`` saves the image to the specified file. The image format
:ref:`Mat::convertTo` , and
:ref:`cvtColor` to convert it before saving. Or, use the universal XML I/O functions to save the image to XML or YAML format.
.. index:: VideoCapture
.. _VideoCapture:
VideoCapture
------------
.. c:type:: VideoCapture
.. ocv:class:: VideoCapture
Class for video capturing from video files or cameras ::
@@ -202,30 +182,25 @@ The class provides C++ video capturing API. Here is how the class can be used: :
}
.. index:: VideoCapture::VideoCapture
.. _VideoCapture::VideoCapture:
VideoCapture::VideoCapture
------------------------------
VideoCapture constructors.
.. ocv:function:: VideoCapture::VideoCapture()
.. ocv:function:: VideoCapture::VideoCapture(const string& filename)
.. ocv:function:: VideoCapture::VideoCapture(int device)
VideoCapture constructors.
:param filename: name of the opened video file
:param device: id of the opened video capturing device (i.e. a camera index).
.. index:: VideoCapture::get
.. _VideoCapture::get:
VideoCapture::get
---------------------
Returns the specified ``VideoCapture`` property
.. ocv:function:: double VideoCapture::get(int property_id)
:param property_id: Property identifier. It can be one of the following:
@@ -271,15 +246,11 @@ VideoCapture::get
**Note**: When querying a property that is not supported by the backend used by the ``VideoCapture`` class, value 0 is returned.
.. index:: VideoCapture::set
.. _VideoCapture::set:
VideoCapture::set
---------------------
.. ocv:function:: bool VideoCapture::set(int property_id, double value)
Sets a property in the ``VideoCapture``.
Sets a property in the VideoCapture backend.
.. ocv:function:: bool VideoCapture::set(int property_id, double value)
:param property_id: Property identifier. It can be one of the following:
@@ -323,15 +294,9 @@ VideoCapture::set
:param value: Value of the property.
.. index:: VideoWriter
.. _VideoWriter:
VideoWriter
-----------
.. c:type:: VideoWriter
.. ocv:class:: VideoWriter
Video writer class ::
+16 -45
View File
@@ -3,15 +3,11 @@ User Interface
.. highlight:: cpp
.. index:: createTrackbar
.. _createTrackbar:
createTrackbar
------------------
.. ocv:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0)
Creates a trackbar and attaches it to the specified window.
Creates a trackbar and attaches it to the specified window.
.. ocv:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0)
:param trackbarname: Name of the created trackbar.
@@ -41,13 +37,11 @@ is NULL.
Clicking the label of each trackbar enables editing the trackbar values manually for a more accurate control of it.
.. index:: getTrackbarPos
getTrackbarPos
------------------
.. ocv:function:: int getTrackbarPos( const string& trackbarname, const string& winname )
Returns the trackbar position.
Returns the trackbar position.
.. ocv:function:: int getTrackbarPos( const string& trackbarname, const string& winname )
:param trackbarname: Name of the trackbar.
@@ -61,15 +55,11 @@ Qt-specific details:
* **winname** Name of the window that is the parent of the trackbar. It can be NULL if the trackbar is attached to the control panel.
.. index:: imshow
.. _imshow:
imshow
----------
.. ocv:function:: void imshow( const string& winname, InputArray image )
Displays an image in the specified window.
Displays an image in the specified window.
.. ocv:function:: void imshow( const string& winname, InputArray image )
:param winname: Name of the window.
@@ -86,15 +76,12 @@ The function ``imshow`` displays an image in the specified window. If the window
*
If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].
.. index:: namedWindow
.. _namedWindow:
namedWindow
---------------
.. ocv:function:: void namedWindow( const string& winname, int flags )
Creates a window.
Creates a window.
.. ocv:function:: void namedWindow( const string& winname, int flags )
:param name: Name of the window in the window caption that may be used as a window identifier.
@@ -129,43 +116,31 @@ Qt-specific details:
..
.. index:: destroyWindow
.. _destroyWindow:
destroyWindow
-------------
.. ocv:function:: void destroyWindow( const string &winname )
Destroys a window.
Destroys a window.
.. ocv:function:: void destroyWindow( const string &winname )
:param winname: Name of the window to be destroyed.
The function ``destroyWindow`` destroys the window with the given name.
.. index:: destroyAllWindows
.. _destroyAllWindows:
destroyAllWindows
-----------------
.. ocv:function:: void destroyAllWindows()
Destroys all of the HighGUI windows.
Destroys all of the HighGUI windows.
.. ocv:function:: void destroyAllWindows()
The function ``destroyAllWindows`` destroys all of the opened HighGUI windows.
.. index:: setTrackbarPos
.. _setTrackbarPos:
setTrackbarPos
------------------
.. ocv:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos )
Sets the trackbar position.
Sets the trackbar position.
.. ocv:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos )
:param trackbarname: Name of the trackbar.
@@ -181,15 +156,11 @@ Qt-specific details:
* **winname** Name of the window that is the parent of the trackbar. It can be NULL if the trackbar is attached to the control panel.
.. index:: waitKey
.. _waitKey:
waitKey
-----------
.. ocv:function:: int waitKey(int delay=0)
Waits for a pressed key.
Waits for a pressed key.
.. ocv:function:: int waitKey(int delay=0)
:param delay: Delay in milliseconds. 0 is the special value that means "forever".
+22 -30
View File
@@ -3,13 +3,13 @@ Feature Detection
.. highlight:: cpp
.. index:: Canny
Canny
---------
.. ocv:function:: void Canny( InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )
Finds edges in an image using the Canny algorithm.
Finds edges in an image using the Canny algorithm.
.. ocv:function:: void Canny( InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )
:param image: Single-channel 8-bit input image.
@@ -26,15 +26,14 @@ Canny
The function finds edges in the input image ``image`` and marks them in the output map ``edges`` using the Canny algorithm. The smallest value between ``threshold1`` and ``threshold2`` is used for edge linking. The largest value is used to find initial segments of strong edges. See
http://en.wikipedia.org/wiki/Canny_edge_detector
.. index:: cornerEigenValsAndVecs
cornerEigenValsAndVecs
----------------------
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
.. ocv:function:: void cornerEigenValsAndVecs( InputArray src, OutputArray dst, int blockSize, int apertureSize, int borderType=BORDER_DEFAULT )
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
:param src: Input single-channel 8-bit or floating-point image.
:param dst: Image to store the results. It has the same size as ``src`` and the type ``CV_32FC(6)`` .
@@ -73,15 +72,14 @@ See Also:
:ocv:func:`cornerHarris`,
:ocv:func:`preCornerDetect`
.. index:: cornerHarris
cornerHarris
------------
Harris edge detector.
.. ocv:function:: void cornerHarris( InputArray src, OutputArray dst, int blockSize, int apertureSize, double k, int borderType=BORDER_DEFAULT )
Harris edge detector.
:param src: Input single-channel 8-bit or floating-point image.
:param dst: Image to store the Harris detector responses. It has the type ``CV_32FC1`` and the same size as ``src`` .
@@ -108,15 +106,14 @@ The function runs the Harris edge detector on the image. Similarly to
Corners in the image can be found as the local maxima of this response map.
.. index:: cornerMinEigenVal
cornerMinEigenVal
-----------------
Calculates the minimal eigenvalue of gradient matrices for corner detection.
.. ocv:function:: void cornerMinEigenVal( InputArray src, OutputArray dst, int blockSize, int apertureSize=3, int borderType=BORDER_DEFAULT )
Calculates the minimal eigenvalue of gradient matrices for corner detection.
:param src: Input single-channel 8-bit or floating-point image.
:param dst: Image to store the minimal eigenvalues. It has the type ``CV_32FC1`` and the same size as ``src`` .
@@ -132,13 +129,13 @@ The function is similar to
:math:`\min(\lambda_1, \lambda_2)` in terms of the formulae in the
:ocv:func:`cornerEigenValsAndVecs` description.
.. index:: cornerSubPix
cornerSubPix
----------------
.. ocv:function:: void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria )
Refines the corner locations.
Refines the corner locations.
.. ocv:function:: void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria )
:param image: Input image.
@@ -188,15 +185,14 @@ where the gradients are summed within a neighborhood ("search window") of
The algorithm sets the center of the neighborhood window at this new center
:math:`q` and then iterates until the center stays within a set threshold.
.. index:: goodFeaturesToTrack
goodFeaturesToTrack
-------------------
Determines strong corners on an image.
.. ocv:function:: void goodFeaturesToTrack( InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=noArray(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 )
Determines strong corners on an image.
:param image: Input 8-bit or floating-point 32-bit, single-channel image.
:param corners: Output vector of detected corners.
@@ -246,15 +242,14 @@ See Also: :ocv:func:`cornerMinEigenVal`,
:ocv:func:`PlanarObjectDetector`,
:ocv:func:`OneWayDescriptor`
.. index:: HoughCircles
HoughCircles
------------
Finds circles in a grayscale image using the Hough transform.
.. ocv:function:: void HoughCircles( InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )
Finds circles in a grayscale image using the Hough transform.
:param image: 8-bit, single-channel, grayscale input image.
:param circles: Output vector of found circles. Each vector is encoded as a 3-element floating-point vector :math:`(x, y, radius)` .
@@ -312,15 +307,14 @@ See Also:
:ocv:func:`fitEllipse`,
:ocv:func:`minEnclosingCircle`
.. index:: HoughLines
HoughLines
----------
Finds lines in a binary image using the standard Hough transform.
.. ocv:function:: void HoughLines( InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
Finds lines in a binary image using the standard Hough transform.
:param image: 8-bit, single-channel binary source image. The image may be modified by the function.
:param lines: Output vector of lines. Each line is represented by a two-element vector :math:`(\rho, \theta)` . :math:`\rho` is the distance from the coordinate origin :math:`(0,0)` (top-left corner of the image). :math:`\theta` is the line rotation angle in radians ( :math:`0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}` ).
@@ -339,15 +333,14 @@ The function implements the standard or standard multi-scale Hough transform alg
:ocv:func:`HoughLinesP` for the code example. Also see http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform.
.. index:: HoughLinesP
HoughLinesP
-----------
Finds line segments in a binary image using the probabilistic Hough transform.
.. ocv:function:: void HoughLinesP( InputArray image, OutputArray lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0 )
Finds line segments in a binary image using the probabilistic Hough transform.
:param image: 8-bit, single-channel binary source image. The image may be modified by the function.
:param lines: Output vector of lines. Each line is represented by a 4-element vector :math:`(x_1, y_1, x_2, y_2)` , where :math:`(x_1,y_1)` and :math:`(x_2, y_2)` are the ending points of each detected line segment.
@@ -427,15 +420,14 @@ And this is the output of the above program in case of the probabilistic Hough t
.. image:: pics/houghp.png
.. index:: preCornerDetect
preCornerDetect
---------------
Calculates a feature map for corner detection.
.. ocv:function:: void preCornerDetect( InputArray src, OutputArray dst, int apertureSize, int borderType=BORDER_DEFAULT )
Calculates a feature map for corner detection.
:param src: Source single-channel 8-bit of floating-point image.
:param dst: Output image that has the type ``CV_32F`` and the same size as ``src`` .
+90 -92
View File
@@ -1,10 +1,8 @@
.. _ImageFiltering:
.. highlight:: cpp
Image Filtering
===============
.. highlight:: cpp
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images (represented as
:ocv:func:`Mat`'s). It means that for each pixel location
:math:`(x,y)` in the source image (normally, rectangular), its neighborhood is considered and used to compute the response. In case of a linear filter, it is a weighted sum of pixel values. In case of morphological operations, it is the minimum or maximum values, and so on. The computed response is stored in the destination image at the same location
@@ -14,7 +12,7 @@ Another common feature of the functions and classes described in this section is
:math:`3 \times 3` filter, then, when processing the left-most pixels in each row, you need pixels to the left of them, that is, outside of the image. You can let these pixels be the same as the left-most image pixels ("replicated border" extrapolation method), or assume that all the non-existing pixels are zeros ("contant border" extrapolation method), and so on.
OpenCV enables you to specify the extrapolation method. For details, see the function :ocv:func:`borderInterpolate` and discussion of the ``borderType`` parameter in various functions below.
.. index:: BaseColumnFilter
BaseColumnFilter
----------------
@@ -63,7 +61,7 @@ See Also:
:ocv:func:`getLinearColumnFilter`,
:ocv:func:`getMorphologyColumnFilter`
.. index:: BaseFilter
BaseFilter
----------
@@ -112,7 +110,7 @@ See Also:
:ocv:func:`getLinearFilter`,
:ocv:func:`getMorphologyFilter`
.. index:: BaseRowFilter
BaseRowFilter
-------------
@@ -154,7 +152,7 @@ See Also:
:ocv:func:`getMorphologyRowFilter`,
:ocv:func:`getRowSumFilter`
.. index:: FilterEngine
FilterEngine
------------
@@ -368,13 +366,13 @@ See Also:
:ocv:func:`createMorphologyFilter`,
:ocv:func:`createSeparableLinearFilter`
.. index:: bilateralFilter
bilateralFilter
-------------------
.. ocv:function:: void bilateralFilter( InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )
Applies the bilateral filter to an image.
Applies the bilateral filter to an image.
.. ocv:function:: void bilateralFilter( InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )
:param src: Source 8-bit or floating-point, 1-channel or 3-channel image.
@@ -397,13 +395,13 @@ http://www.dai.ed.ac.uk/CVonline/LOCAL\_COPIES/MANDUCHI1/Bilateral\_Filtering.ht
This filter doesn't work inplace.
.. index:: blur
blur
--------
.. ocv:function:: void blur( InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT )
Smoothes an image using the normalized box filter.
Smoothes an image using the normalized box filter.
.. ocv:function:: void blur( InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -429,13 +427,13 @@ See Also:
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`
.. index:: borderInterpolate
borderInterpolate
---------------------
.. ocv:function:: int borderInterpolate( int p, int len, int borderType )
Computes the source location of an extrapolated pixel.
Computes the source location of an extrapolated pixel.
.. ocv:function:: int borderInterpolate( int p, int len, int borderType )
:param p: 0-based coordinate of the extrapolated pixel along one of the axes, likely <0 or >= ``len`` .
@@ -457,13 +455,13 @@ See Also:
:ocv:func:`FilterEngine`,
:ocv:func:`copyMakeBorder`
.. index:: boxFilter
boxFilter
-------------
.. ocv:function:: void boxFilter( InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT )
Smoothes an image using the box filter.
Smoothes an image using the box filter.
.. ocv:function:: void boxFilter( InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -500,13 +498,13 @@ See Also:
:ocv:func:`medianBlur`,
:ocv:func:`integral`
.. index:: buildPyramid
buildPyramid
----------------
.. ocv:function:: void buildPyramid( InputArray src, OutputArrayOfArrays dst, int maxlevel )
Constructs the Gaussian pyramid for an image.
Constructs the Gaussian pyramid for an image.
.. ocv:function:: void buildPyramid( InputArray src, OutputArrayOfArrays dst, int maxlevel )
:param src: Source image. Check :ocv:func:`pyrDown` for the list of supported types.
@@ -518,13 +516,13 @@ buildPyramid
The function constructs a vector of images and builds the Gaussian pyramid by recursively applying
:ocv:func:`pyrDown` to the previously built pyramid layers, starting from ``dst[0]==src`` .
.. index:: copyMakeBorder
copyMakeBorder
------------------
.. ocv:function:: void copyMakeBorder( InputArray src, OutputArray dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() )
Forms a border around an image.
Forms a border around an image.
.. ocv:function:: void copyMakeBorder( InputArray src, OutputArray dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() )
:param src: Source image.
@@ -558,18 +556,18 @@ The function supports the mode when ``src`` is already in the middle of ``dst``
See Also:
:ocv:func:`borderInterpolate`
.. index:: createBoxFilter
createBoxFilter
-------------------
Returns a box filter engine.
.. ocv:function:: Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT)
.. ocv:function:: Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType, int ksize, int anchor=-1)
.. ocv:function:: Ptr<BaseColumnFilter> getColumnSumFilter(int sumType, int dstType, int ksize, int anchor=-1, double scale=1)
Returns a box filter engine.
:param srcType: Source image type.
:param sumType: Intermediate horizontal sum type that must have as many channels as ``srcType`` .
@@ -600,13 +598,13 @@ See Also:
:ocv:func:`blur`,
:ocv:func:`boxFilter`
.. index:: createDerivFilter
createDerivFilter
---------------------
.. ocv:function:: Ptr<FilterEngine> createDerivFilter( int srcType, int dstType, int dx, int dy, int ksize, int borderType=BORDER_DEFAULT )
Returns an engine for computing image derivatives.
Returns an engine for computing image derivatives.
.. ocv:function:: Ptr<FilterEngine> createDerivFilter( int srcType, int dstType, int dx, int dy, int ksize, int borderType=BORDER_DEFAULT )
:param srcType: Source image type.
@@ -632,13 +630,13 @@ See Also:
:ocv:func:`Scharr`,
:ocv:func:`Sobel`
.. index:: createGaussianFilter
createGaussianFilter
------------------------
.. ocv:function:: Ptr<FilterEngine> createGaussianFilter( int type, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT)
Returns an engine for smoothing images with the Gaussian filter.
Returns an engine for smoothing images with the Gaussian filter.
.. ocv:function:: Ptr<FilterEngine> createGaussianFilter( int type, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT)
:param type: Source and destination image type.
@@ -660,16 +658,16 @@ See Also:
:ocv:func:`getGaussianKernel`,
:ocv:func:`GaussianBlur`
.. index:: createLinearFilter
createLinearFilter
----------------------
Creates a non-separable linear filter engine.
.. ocv:function:: Ptr<FilterEngine> createLinearFilter(int srcType, int dstType, InputArray kernel, Point _anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
.. ocv:function:: Ptr<BaseFilter> getLinearFilter(int srcType, int dstType, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int bits=0)
Creates a non-separable linear filter engine.
:param srcType: Source image type.
:param dstType: Destination image type that must have as many channels as ``srcType`` .
@@ -693,10 +691,12 @@ See Also:
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`filter2D`
.. index:: createMorphologyFilter
createMorphologyFilter
--------------------------
Creates an engine for non-separable morphological operations.
.. ocv:function:: Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1), int rowBorderType=BORDER_CONSTANT, int columnBorderType=-1, const Scalar& borderValue=morphologyDefaultBorderValue())
.. ocv:function:: Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1))
@@ -707,8 +707,6 @@ createMorphologyFilter
.. ocv:function:: Scalar morphologyDefaultBorderValue()
Creates an engine for non-separable morphological operations.
:param op: Morphology operation id, ``MORPH_ERODE`` or ``MORPH_DILATE`` .
:param type: Input/output image type.
@@ -736,18 +734,18 @@ See Also:
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`FilterEngine`
.. index:: createSeparableLinearFilter
createSeparableLinearFilter
-------------------------------
Creates an engine for a separable linear filter.
.. ocv:function:: Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType, InputArray rowKernel, InputArray columnKernel, Point anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
.. ocv:function:: Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType, InputArray columnKernel, int anchor, int symmetryType, double delta=0, int bits=0)
.. ocv:function:: Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType, InputArray rowKernel, int anchor, int symmetryType)
Creates an engine for a separable linear filter.
:param srcType: Source array type.
:param dstType: Destination image type that must have as many channels as ``srcType`` .
@@ -781,13 +779,13 @@ See Also:
:ocv:func:`createLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getKernelType`
.. index:: dilate
dilate
----------
.. ocv:function:: void dilate( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Dilates an image by using a specific structuring element.
Dilates an image by using a specific structuring element.
.. ocv:function:: void dilate( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
:param src: Source image.
@@ -815,13 +813,13 @@ See Also:
:ocv:func:`erode`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
.. index:: erode
erode
---------
.. ocv:function:: void erode( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Erodes an image by using a specific structuring element.
Erodes an image by using a specific structuring element.
.. ocv:function:: void erode( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
:param src: Source image.
@@ -850,13 +848,13 @@ See Also:
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
.. index:: filter2D
filter2D
------------
.. ocv:function:: void filter2D( InputArray src, OutputArray dst, int ddepth, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
Convolves an image with the kernel.
Convolves an image with the kernel.
.. ocv:function:: void filter2D( InputArray src, OutputArray dst, int ddepth, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -891,13 +889,13 @@ See Also:
:ocv:func:`dft`,
:ocv:func:`matchTemplate`
.. index:: GaussianBlur
GaussianBlur
----------------
.. ocv:function:: void GaussianBlur( InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT )
Smoothes an image using a Gaussian filter.
Smoothes an image using a Gaussian filter.
.. ocv:function:: void GaussianBlur( InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -918,13 +916,13 @@ See Also:
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`medianBlur`
.. index:: getDerivKernels
getDerivKernels
-------------------
.. ocv:function:: void getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F )
Returns filter coefficients for computing spatial image derivatives.
Returns filter coefficients for computing spatial image derivatives.
.. ocv:function:: void getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F )
:param kx: Output matrix of row filter coefficients. It has the type ``ktype`` .
@@ -947,13 +945,13 @@ The function computes and returns the filter coefficients for spatial image deri
:ocv:func:`sepFilter2D` or to
:ocv:func:`createSeparableLinearFilter` .
.. index:: getGaussianKernel
getGaussianKernel
---------------------
.. ocv:function:: Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F )
Returns Gaussian filter coefficients.
Returns Gaussian filter coefficients.
.. ocv:function:: Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F )
:param ksize: Aperture size. It should be odd ( :math:`\texttt{ksize} \mod 2 = 1` ) and positive.
@@ -984,13 +982,13 @@ See Also:
:ocv:func:`getStructuringElement`,
:ocv:func:`GaussianBlur`
.. index:: getKernelType
getKernelType
-----------------
.. ocv:function:: int getKernelType(InputArray kernel, Point anchor)
Returns the kernel type.
Returns the kernel type.
.. ocv:function:: int getKernelType(InputArray kernel, Point anchor)
:param kernel: 1D array of the kernel coefficients to analyze.
@@ -1007,13 +1005,13 @@ The function analyzes the kernel coefficients and returns the corresponding kern
* **KERNEL_SMOOTH** All the kernel elements are non-negative and summed to 1. For example, the Gaussian kernel is both smooth kernel and symmetrical, so the function returns ``KERNEL_SMOOTH | KERNEL_SYMMETRICAL`` .
* **KERNEL_INTEGER** All the kernel coefficients are integer numbers. This flag can be combined with ``KERNEL_SYMMETRICAL`` or ``KERNEL_ASYMMETRICAL`` .
.. index:: getStructuringElement
getStructuringElement
-------------------------
.. ocv:function:: Mat getStructuringElement(int shape, Size esize, Point anchor=Point(-1,-1))
Returns a structuring element of the specified size and shape for morphological operations.
Returns a structuring element of the specified size and shape for morphological operations.
.. ocv:function:: Mat getStructuringElement(int shape, Size esize, Point anchor=Point(-1,-1))
:param shape: Element shape that could be one of the following:
@@ -1041,13 +1039,13 @@ The function constructs and returns the structuring element that can be then pas
:ocv:func:`dilate` or
:ocv:func:`morphologyEx` . But you can also construct an arbitrary binary mask yourself and use it as the structuring element.
.. index:: medianBlur
medianBlur
--------------
.. ocv:function:: void medianBlur( InputArray src, OutputArray dst, int ksize )
Smoothes an image using the median filter.
Smoothes an image using the median filter.
.. ocv:function:: void medianBlur( InputArray src, OutputArray dst, int ksize )
:param src: Source 1-, 3-, or 4-channel image. When ``ksize`` is 3 or 5, the image depth should be ``CV_8U`` , ``CV_16U`` , or ``CV_32F`` . For larger aperture sizes, it can only be ``CV_8U`` .
@@ -1064,13 +1062,13 @@ See Also:
:ocv:func:`boxFilter`,
:ocv:func:`GaussianBlur`
.. index:: morphologyEx
morphologyEx
----------------
.. ocv:function:: void morphologyEx( InputArray src, OutputArray dst, int op, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Performs advanced morphological transformations.
Performs advanced morphological transformations.
.. ocv:function:: void morphologyEx( InputArray src, OutputArray dst, int op, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
:param src: Source image.
@@ -1135,13 +1133,13 @@ See Also:
:ocv:func:`erode`,
:ocv:func:`createMorphologyFilter`
.. index:: Laplacian
Laplacian
-------------
.. ocv:function:: void Laplacian( InputArray src, OutputArray dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the Laplacian of an image.
Calculates the Laplacian of an image.
.. ocv:function:: void Laplacian( InputArray src, OutputArray dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -1174,13 +1172,13 @@ See Also:
:ocv:func:`Sobel`,
:ocv:func:`Scharr`
.. index:: pyrDown
pyrDown
-----------
.. ocv:function:: void pyrDown( InputArray src, OutputArray dst, const Size& dstsize=Size())
Smoothes an image and downsamples it.
Smoothes an image and downsamples it.
.. ocv:function:: void pyrDown( InputArray src, OutputArray dst, const Size& dstsize=Size())
:param src: Source image.
@@ -1201,13 +1199,13 @@ The function performs the downsampling step of the Gaussian pyramid construction
Then, it downsamples the image by rejecting even rows and columns.
.. index:: pyrUp
pyrUp
---------
.. ocv:function:: void pyrUp( InputArray src, OutputArray dst, const Size& dstsize=Size())
Upsamples an image and then smoothes it.
Upsamples an image and then smoothes it.
.. ocv:function:: void pyrUp( InputArray src, OutputArray dst, const Size& dstsize=Size())
:param src: Source image.
@@ -1223,13 +1221,13 @@ pyrUp
The function performs the upsampling step of the Gaussian pyramid construction though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in
:ocv:func:`pyrDown` multiplied by 4.
.. index:: sepFilter2D
sepFilter2D
---------------
.. ocv:function:: void sepFilter2D( InputArray src, OutputArray dst, int ddepth, InputArray rowKernel, InputArray columnKernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
Applies a separable linear filter to an image.
Applies a separable linear filter to an image.
.. ocv:function:: void sepFilter2D( InputArray src, OutputArray dst, int ddepth, InputArray rowKernel, InputArray columnKernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -1257,13 +1255,13 @@ See Also:
:ocv:func:`boxFilter`,
:ocv:func:`blur`
.. index:: Sobel
Sobel
---------
.. ocv:function:: void Sobel( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
.. ocv:function:: void Sobel( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -1330,13 +1328,13 @@ See Also:
:ocv:func:`filter2D`,
:ocv:func:`GaussianBlur`
.. index:: Scharr
Scharr
----------
.. ocv:function:: void Scharr( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the first x- or y- image derivative using Scharr operator.
Calculates the first x- or y- image derivative using Scharr operator.
.. ocv:function:: void Scharr( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
:param src: Source image.
@@ -1,6 +1,7 @@
Geometric Image Transformations
===============================
.. highlight:: cpp
The functions in this section perform various geometrical transformations of 2D images. They do not change the image content but deform the pixel grid and map this deformed grid to the destination image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from destination to the source. That is, for each pixel
:math:`(x, y)` of the destination image, the functions compute coordinates of the corresponding "donor" pixel in the source image and copy the pixel value:
@@ -32,17 +33,12 @@ The actual implementations of the geometrical transformations, from the most gen
:math:`(f_x(x,y), f_y(x,y))` is taken as the interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See
:ref:`Resize` for details.
.. index:: convertMaps
.. _convertMaps:
convertMaps
-----------
Converts image transformation maps from one representation to another.
.. ocv:function:: void convertMaps( InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation=false )
Converts image transformation maps from one representation to another.
:param map1: The first input map of type ``CV_16SC2`` , ``CV_32FC1`` , or ``CV_32FC2`` .
:param map2: The second input map of type ``CV_16UC1`` , ``CV_32FC1`` , or none (empty matrix), respectively.
@@ -73,13 +69,13 @@ See Also:
:ocv:func:`undisort`,
:ocv:func:`initUndistortRectifyMap`
.. index:: getAffineTransform
getAffineTransform
----------------------
.. ocv:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
Calculates an affine transform from three pairs of the corresponding points.
Calculates an affine transform from three pairs of the corresponding points.
.. ocv:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
:param src: Coordinates of triangle vertices in the source image.
@@ -104,15 +100,12 @@ See Also:
:ocv:func:`transform`
.. index:: getPerspectiveTransform
.. _getPerspectiveTransform:
getPerspectiveTransform
---------------------------
.. ocv:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
Calculates a perspective transform from four pairs of the corresponding points.
Calculates a perspective transform from four pairs of the corresponding points.
.. ocv:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
:param src: Coordinates of quadrangle vertices in the source image.
@@ -130,22 +123,19 @@ where
dst(i)=(x'_i,y'_i),
src(i)=(x_i, y_i),
i=0,1,2
i=0,1,2,3
See Also:
:ocv:func:`findHomography`,
:ocv:func:`warpPerspective`,
:ocv:func:`perspectiveTransform`
.. index:: getRectSubPix
.. getRectSubPix:
getRectSubPix
-----------------
.. ocv:function:: void getRectSubPix( InputArray image, Size patchSize, Point2f center, OutputArray dst, int patchType=-1 )
Retrieves a pixel rectangle from an image with sub-pixel accuracy.
Retrieves a pixel rectangle from an image with sub-pixel accuracy.
.. ocv:function:: void getRectSubPix( InputArray image, Size patchSize, Point2f center, OutputArray dst, int patchType=-1 )
:param src: Source image.
@@ -175,15 +165,12 @@ See Also:
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`
.. index:: getRotationMatrix2D
.. _getRotationMatrix2D:
getRotationMatrix2D
-----------------------
.. ocv:function:: Mat getRotationMatrix2D( Point2f center, double angle, double scale )
Calculates an affine matrix of 2D rotation.
Calculates an affine matrix of 2D rotation.
.. ocv:function:: Mat getRotationMatrix2D( Point2f center, double angle, double scale )
:param center: Center of the rotation in the source image.
@@ -210,15 +197,15 @@ See Also:
:ocv:func:`warpAffine`,
:ocv:func:`transform`
.. index:: invertAffineTransform
.. _invertAffineTransform:
invertAffineTransform
-------------------------
.. ocv:function:: void invertAffineTransform(InputArray M, OutputArray iM)
Inverts an affine transformation.
Inverts an affine transformation.
.. ocv:function:: void invertAffineTransform(InputArray M, OutputArray iM)
:param M: Original affine transformation.
@@ -234,17 +221,16 @@ The function computes an inverse affine transformation represented by
The result is also a
:math:`2 \times 3` matrix of the same type as ``M`` .
.. index:: remap
.. _remap:
remap
-----
Applies a generic geometrical transformation to an image.
.. ocv:function:: void remap( InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies a generic geometrical transformation to an image.
:param src: Source image.
:param dst: Destination image. It has the same size as ``map1`` and the same type as ``src`` .
@@ -279,17 +265,14 @@ representations of a map is that they can yield much faster (~2x) remapping oper
This function cannot operate in-place.
.. index:: resize
.. _resize:
resize
----------
Resizes an image.
.. ocv:function:: void resize( InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR )
Resizes an image.
:param src: Source image.
:param dst: Destination image. It has the size ``dsize`` (when it is non-zero) or the size computed from ``src.size()`` , ``fx`` , and ``fy`` . The type of ``dst`` is the same as of ``src`` .
@@ -346,15 +329,14 @@ See Also:
:ocv:func:`warpPerspective`,
:ocv:func:`remap`
.. index:: warpAffine
.. _warpAffine:
warpAffine
--------------
.. ocv:function:: void warpAffine( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies an affine transformation to an image.
Applies an affine transformation to an image.
.. ocv:function:: void warpAffine( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
:param src: Source image.
@@ -387,13 +369,13 @@ See Also:
:ocv:func:`getRectSubPix`,
:ocv:func:`transform`
.. index:: warpPerspective
warpPerspective
-------------------
.. ocv:function:: void warpPerspective( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies a perspective transformation to an image.
Applies a perspective transformation to an image.
.. ocv:function:: void warpPerspective( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
:param src: Source image.
@@ -428,15 +410,14 @@ See Also:
:ocv:func:`perspectiveTransform`
.. index:: initUndistortRectifyMap
initUndistortRectifyMap
---------------------------
Computes the undistortion and rectification transformation map.
.. ocv:function:: void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2 )
Computes the undistortion and rectification transformation map.
:param cameraMatrix: Input camera matrix :math:`A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
:param distCoeffs: Input vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
@@ -483,13 +464,13 @@ In case of a stereo camera, this function is called twice: once for each camera
where ``cameraMatrix`` can be chosen arbitrarily.
.. index:: getDefaultNewCameraMatrix
getDefaultNewCameraMatrix
-----------------------------
.. ocv:function:: Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgSize=Size(), bool centerPrincipalPoint=false )
Returns the default new camera matrix.
Returns the default new camera matrix.
.. ocv:function:: Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgSize=Size(), bool centerPrincipalPoint=false )
:param cameraMatrix: Input camera matrix.
@@ -516,13 +497,13 @@ By default, the undistortion functions in OpenCV (see
:ref:`undistort`) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.
.. index:: undistort
undistort
-------------
.. ocv:function:: void undistort( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix=noArray() )
Transforms an image to compensate for lens distortion.
Transforms an image to compensate for lens distortion.
.. ocv:function:: void undistort( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix=noArray() )
:param src: Input (distorted) image.
@@ -551,13 +532,13 @@ The camera matrix and the distortion parameters can be determined using
:math:`c_y` need to be scaled accordingly, while the distortion coefficients remain the same.
.. index:: undistortPoints
undistortPoints
-------------------
.. ocv:function:: void undistortPoints( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray R=noArray(), InputArray P=noArray())
Computes the ideal point coordinates from the observed point coordinates.
Computes the ideal point coordinates from the observed point coordinates.
.. ocv:function:: void undistortPoints( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray R=noArray(), InputArray P=noArray())
:param src: Observed point coordinates, 1xN or Nx1 2-channel (CV_32FC2 or CV_64FC2).
+14 -16
View File
@@ -3,16 +3,16 @@ Histograms
.. highlight:: cpp
.. index:: calcHist
calcHist
------------
Calculates a histogram of a set of arrays.
.. ocv:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
.. ocv:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, InputArray mask, SparseMat& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
Calculates a histogram of a set of arrays.
:param arrays: Source arrays. They all should have the same depth, ``CV_8U`` or ``CV_32F`` , and the same size. Each of them can have an arbitrary number of channels.
:param narrays: Number of source arrays.
@@ -95,16 +95,16 @@ input arrays at the same location. The sample below shows how to compute a 2D Hu
}
.. index:: calcBackProject
calcBackProject
-------------------
Calculates the back projection of a histogram.
.. ocv:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, InputArray hist, OutputArray backProject, const float** ranges, double scale=1, bool uniform=true )
.. ocv:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, const SparseMat& hist, OutputArray backProject, const float** ranges, double scale=1, bool uniform=true )
Calculates the back projection of a histogram.
:param arrays: Source arrays. They all should have the same depth, ``CV_8U`` or ``CV_32F`` , and the same size. Each of them can have an arbitrary number of channels.
:param narrays: Number of source arrays.
@@ -138,17 +138,16 @@ This is an approximate algorithm of the
See Also:
:ocv:func:`calcHist`
.. index:: compareHist
compareHist
-----------
Compares two histograms.
.. ocv:function:: double compareHist( InputArray H1, InputArray H2, int method )
.. ocv:function:: double compareHist( const SparseMat& H1, const SparseMat& H2, int method )
Compares two histograms.
:param H1: The first compared histogram.
:param H2: The second compared histogram of the same size as ``H1`` .
@@ -204,15 +203,14 @@ While the function works well with 1-, 2-, 3-dimensional dense histograms, it ma
:ocv:func:`EMD` function.
.. index:: EMD
EMD
------
Computes the "minimal work" distance between two weighted point configurations.
.. ocv:function:: float EMD( InputArray signature1, InputArray signature2, int distType, InputArray cost=noArray(), float* lowerBound=0, OutputArray flow=noArray() )
Computes the "minimal work" distance between two weighted point configurations.
:param signature1: The first signature, a :math:`\texttt{size1}\times \texttt{dims}+1` floating-point matrix. Each row stores the point weight followed by the point coordinates. The matrix is allowed to have a single column (weights only) if the user-defined cost matrix is used.
:param signature2: The second signature of the same format as ``signature1`` , though the number of rows may be different. The total weights may be different, in this case an extra "dummy" point is added to either ``signature1`` or ``signature2`` .
@@ -228,13 +226,13 @@ EMD
The function computes the earth mover distance and/or a lower boundary of the distance between the two weighted point configurations. One of the applications described in :ref:`RubnerSept98` is multi-dimensional histogram comparison for image retrieval. EMD is a transportation problem that is solved using some modification of a simplex algorithm, thus the complexity is exponential in the worst case, though, on average it is much faster. In the case of a real metric the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used to determine roughly whether the two signatures are far enough so that they cannot relate to the same object.
.. index:: equalizeHist
equalizeHist
----------------
.. ocv:function:: void equalizeHist( InputArray src, OutputArray dst )
Equalizes the histogram of a grayscale image.
Equalizes the histogram of a grayscale image.
.. ocv:function:: void equalizeHist( InputArray src, OutputArray dst )
:param src: Source 8-bit single channel image.
@@ -3,15 +3,12 @@ Miscellaneous Image Transformations
.. highlight:: cpp
.. index:: adaptiveThreshold
.. _adaptiveThreshold:
adaptiveThreshold
---------------------
.. ocv:function:: void adaptiveThreshold( InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C )
Applies an adaptive threshold to an array.
Applies an adaptive threshold to an array.
.. ocv:function:: void adaptiveThreshold( InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C )
:param src: Source 8-bit single-channel image.
@@ -64,15 +61,12 @@ See Also:
:ocv:func:`GaussianBlur`
.. index:: cvtColor
.. _cvtColor:
cvtColor
------------
.. ocv:function:: void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 )
Converts an image from one color space to another.
Converts an image from one color space to another.
.. ocv:function:: void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 )
:param src: Source image: 8-bit unsigned, 16-bit unsigned ( ``CV_16UC...`` ), or single-precision floating-point.
@@ -399,18 +393,15 @@ The function can do the following transformations:
columns, respectively. For example, the above pattern has a very
popular "BG" type.
.. index:: distanceTransform
.. _distanceTransform:
distanceTransform
---------------------
Calculates the distance to the closest zero pixel for each pixel of the source image.
.. ocv:function:: void distanceTransform( InputArray src, OutputArray dst, int distanceType, int maskSize )
.. ocv:function:: void distanceTransform( InputArray src, OutputArray dst, OutputArray labels, int distanceType, int maskSize )
Calculates the distance to the closest zero pixel for each pixel of the source image.
:param src: 8-bit, single-channel (binary) source image.
:param dst: Output image with calculated distances. It is a 32-bit floating-point, single-channel image of the same size as ``src`` .
@@ -467,18 +458,18 @@ In this mode, the complexity is still linear.
That is, the function provides a very fast way to compute the Voronoi diagram for a binary image.
Currently, the second variant can use only the approximate distance transform algorithm.
.. index:: floodFill
.. _floodFill:
floodFill
-------------
Fills a connected component with the given color.
.. ocv:function:: int floodFill( InputOutputArray image, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
.. ocv:function:: int floodFill( InputOutputArray image, InputOutputArray mask, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
Fills a connected component with the given color.
:param image: Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the ``FLOODFILL_MASK_ONLY`` flag is set in the second variant of the function. See the details below.
:param mask: (For the second function only) Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of initializing the ``mask`` content. Flood-filling cannot go across non-zero pixels in the mask. For example, an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask in multiple calls to the function to make sure the filled area does not overlap.
@@ -569,15 +560,15 @@ Use these functions to either mark a connected component with the specified colo
See Also:
:ocv:func:`findContours`
.. index:: inpaint
.. _inpaint:
inpaint
-----------
.. ocv:function:: void inpaint( InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags )
Restores the selected region in an image using the region neighborhood.
Restores the selected region in an image using the region neighborhood.
.. ocv:function:: void inpaint( InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags )
:param src: Input 8-bit 1-channel or 3-channel image.
@@ -597,18 +588,18 @@ The function reconstructs the selected image area from the pixel near the area b
http://en.wikipedia.org/wiki/Inpainting
for more details.
.. index:: integral
integral
------------
Calculates the integral of an image.
.. ocv:function:: void integral( InputArray image, OutputArray sum, int sdepth=-1 )
.. ocv:function:: void integral( InputArray image, OutputArray sum, OutputArray sqsum, int sdepth=-1 )
.. ocv:function:: void integral( InputArray image, OutputArray sum, OutputArray sqsum, OutputArray tilted, int sdepth=-1 )
Calculates the integral of an image.
:param image: Source image as :math:`W \times H` , 8-bit or floating-point (32f or 64f).
:param sum: Integral image as :math:`(W+1)\times (H+1)` , 32-bit integer or floating-point (32f or 64f).
@@ -645,15 +636,15 @@ As a practical example, the next figure shows the calculation of the integral of
.. image:: pics/integral.png
.. index:: threshold
.. _threshold:
threshold
-------------
.. ocv:function:: double threshold( InputArray src, OutputArray dst, double thresh, double maxVal, int thresholdType )
Applies a fixed-level threshold to each array element.
Applies a fixed-level threshold to each array element.
.. ocv:function:: double threshold( InputArray src, OutputArray dst, double thresh, double maxVal, int thresholdType )
:param src: Source array (single-channel, 8-bit of 32-bit floating point)
@@ -718,13 +709,13 @@ See Also:
:ocv:func:`min`,
:ocv:func:`max`
.. index:: watershed
watershed
-------------
.. ocv:function:: void watershed( InputArray image, InputOutputArray markers )
Performs a marker-based image segmentation using the watershed algrorithm.
Performs a marker-based image segmentation using the watershed algrorithm.
.. ocv:function:: void watershed( InputArray image, InputOutputArray markers )
:param image: Input 8-bit 3-channel image.
@@ -756,15 +747,14 @@ can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo).
See Also:
:ocv:func:`findContours`
.. index:: grabCut
grabCut
-------
Runs the GrabCut algorithm.
.. ocv:function:: void grabCut(InputArray image, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, int mode )
Runs the GrabCut algorithm.
:param image: Input 8-bit 3-channel image.
:param mask: Input/output 8-bit single-channel mask. The mask is initialized by the function when ``mode`` is set to ``GC_INIT_WITH_RECT``. Its elements may have one of following values:
@@ -3,13 +3,11 @@ Motion Analysis and Object Tracking
.. highlight:: cpp
.. index:: accumulate
accumulate
--------------
.. ocv:function:: void accumulate( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
Adds an image to the accumulator.
Adds an image to the accumulator.
.. ocv:function:: void accumulate( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
@@ -32,13 +30,13 @@ See Also:
:ocv:func:`accumulateProduct`,
:ocv:func:`accumulateWeighted`
.. index:: accumulateSquare
accumulateSquare
--------------------
.. ocv:function:: void accumulateSquare( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
Adds the square of a source image to the accumulator.
Adds the square of a source image to the accumulator.
.. ocv:function:: void accumulateSquare( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
@@ -59,13 +57,13 @@ See Also:
:ocv:func:`accumulateProduct`,
:ocv:func:`accumulateWeighted`
.. index:: accumulateProduct
accumulateProduct
---------------------
.. ocv:function:: void accumulateProduct( InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=noArray() )
Adds the per-element product of two input images to the accumulator.
Adds the per-element product of two input images to the accumulator.
.. ocv:function:: void accumulateProduct( InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=noArray() )
:param src1: The first input image, 1- or 3-channel, 8-bit or 32-bit floating point.
@@ -88,13 +86,13 @@ See Also:
:ocv:func:`accumulateSquare`,
:ocv:func:`accumulateWeighted`
.. index:: accumulateWeighted
accumulateWeighted
----------------------
.. ocv:function:: void accumulateWeighted( InputArray src, InputOutputArray dst, double alpha, InputArray mask=noArray() )
Updates a running average.
Updates a running average.
.. ocv:function:: void accumulateWeighted( InputArray src, InputOutputArray dst, double alpha, InputArray mask=noArray() )
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
+2 -4
View File
@@ -3,13 +3,11 @@ Object Detection
.. highlight:: cpp
.. index:: matchTemplate
matchTemplate
-----------------
.. ocv:function:: void matchTemplate( InputArray image, InputArray temp, OutputArray result, int method )
Compares a template against overlapped image regions.
Compares a template against overlapped image regions.
.. ocv:function:: void matchTemplate( InputArray image, InputArray temp, OutputArray result, int method )
:param image: Image where the search is running. It must be 8-bit or 32-bit floating-point.
@@ -3,13 +3,18 @@ Structural Analysis and Shape Descriptors
.. highlight:: cpp
.. index:: moments
moments
-----------
Calculates all of the moments up to the third order of a polygon or rasterized shape
.. ocv:function:: Moments moments( InputArray array, bool binaryImage=false )
Calculates all of the moments up to the third order of a polygon or rasterized shape where the class ``Moments`` is defined as: ::
:param array: A raster image (single-channel, 8-bit or floating-point 2D array) or an array ( :math:`1 \times N` or :math:`N \times 1` ) of 2D points (``Point`` or ``Point2f`` ).
:param binaryImage: If it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in a structure ``Moments``, defined as: ::
class Moments
{
@@ -28,13 +33,8 @@ moments
double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
};
:param array: A raster image (single-channel, 8-bit or floating-point 2D array) or an array ( :math:`1 \times N` or :math:`N \times 1` ) of 2D points (``Point`` or ``Point2f`` ).
:param binaryImage: If it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape.
In case of a raster image, the spatial moments
:math:`\texttt{Moments::m}_{ji}` are computed as:
In case of a raster image, the spatial moments :math:`\texttt{Moments::m}_{ji}` are computed as:
.. math::
@@ -75,13 +75,13 @@ See Also:
:ocv:func:`contourArea`,
:ocv:func:`arcLength`
.. index:: HuMoments
HuMoments
-------------
.. ocv:function:: void HuMoments( const Moments& moments, double h[7] )
Calculates the seven Hu invariants.
Calculates the seven Hu invariants.
.. ocv:function:: void HuMoments( const Moments& moments, double h[7] )
:param moments: Input moments computed with :ocv:func:`moments` .
:param h: Output Hu invariants.
@@ -103,16 +103,15 @@ These values are proved to be invariants to the image scale, rotation, and refle
See Also:
:ocv:func:`matchShapes`
.. index:: findContours
findContours
----------------
Finds contours in a binary image.
.. ocv:function:: void findContours( InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point())
.. ocv:function:: void findContours( InputOutputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point())
Finds contours in a binary image.
:param image: Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as ``binary`` . You can use :ocv:func:`compare` , :ocv:func:`inRange` , :ocv:func:`threshold` , :ocv:func:`adaptiveThreshold` , :ocv:func:`Canny` , and others to create a binary image out of a grayscale or color one. The function modifies the ``image`` while extracting the contours.
:param contours: Detected contours. Each contour is stored as a vector of points.
@@ -146,13 +145,13 @@ Suzuki85
**Note**:
Source ``image`` is modified by this function.
.. index:: drawContours
drawContours
----------------
.. ocv:function:: void drawContours( InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() )
Draws contours outlines or filled contours.
Draws contours outlines or filled contours.
.. ocv:function:: void drawContours( InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() )
:param image: Destination image.
@@ -217,13 +216,13 @@ The function draws contour outlines in the image if
waitKey(0);
}
.. index:: approxPolyDP
approxPolyDP
----------------
.. ocv:function:: void approxPolyDP( InputArray curve, OutputArray approxCurve, double epsilon, bool closed )
Approximates a polygonal curve(s) with the specified precision.
Approximates a polygonal curve(s) with the specified precision.
.. ocv:function:: void approxPolyDP( InputArray curve, OutputArray approxCurve, double epsilon, bool closed )
:param curve: Input vector of 2d point, stored in ``std::vector`` or ``Mat``.
@@ -238,13 +237,13 @@ http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
See http://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/contours.cpp on how to use the function.
.. index:: arcLength
arcLength
-------------
.. ocv:function:: double arcLength( InputArray curve, bool closed )
Calculates a contour perimeter or a curve length.
Calculates a contour perimeter or a curve length.
.. ocv:function:: double arcLength( InputArray curve, bool closed )
:param curve: Input vector of 2D points, stored in ``std::vector`` or ``Mat``.
@@ -252,26 +251,26 @@ arcLength
The function computes a curve length or a closed contour perimeter.
.. index:: boundingRect
boundingRect
----------------
.. ocv:function:: Rect boundingRect( InputArray points )
Calculates the up-right bounding rectangle of a point set.
Calculates the up-right bounding rectangle of a point set.
.. ocv:function:: Rect boundingRect( InputArray points )
:param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
The function calculates and returns the minimal up-right bounding rectangle for the specified point set.
.. index:: contourArea
contourArea
---------------
.. ocv:function:: double contourArea( InputArray contour, bool oriented=false )
Calculates a contour area.
Calculates a contour area.
.. ocv:function:: double contourArea( InputArray contour, bool oriented=false )
:param contour: Input vector of 2d points (contour vertices), stored in ``std::vector`` or ``Mat``.
:param orientation: Oriented area flag. If it is true, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking sign of the area. By default the parameter is ``false``, which means that the absolute value is returned.
@@ -297,13 +296,13 @@ Here is a short example: ::
"area1 =" << area1 << endl <<
"approx poly vertices" << approx.size() << endl;
.. index:: convexHull
convexHull
--------------
.. ocv:function:: void convexHull( InputArray points, OutputArray hull, bool clockwise=false, bool returnPoints=true )
Finds the convex hull of a point set.
Finds the convex hull of a point set.
.. ocv:function:: void convexHull( InputArray points, OutputArray hull, bool clockwise=false, bool returnPoints=true )
:param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
@@ -318,25 +317,25 @@ Sklansky82
that has
*O(N logN)* complexity in the current implementation. See the OpenCV sample ``convexhull.cpp`` that demonstrates the usage of different function variants.
.. index:: fitEllipse
fitEllipse
--------------
.. ocv:function:: RotatedRect fitEllipse( InputArray points )
Fits an ellipse around a set of 2D points.
Fits an ellipse around a set of 2D points.
.. ocv:function:: RotatedRect fitEllipse( InputArray points )
:param points: Input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function calculates the ellipse that fits (in least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed.
.. index:: fitLine
fitLine
-----------
.. ocv:function:: void fitLine( InputArray points, OutputArray line, int distType, double param, double reps, double aeps )
Fits a line to a 2D or 3D point set.
Fits a line to a 2D or 3D point set.
.. ocv:function:: void fitLine( InputArray points, OutputArray line, int distType, double param, double reps, double aeps )
:param points: Input vector of 2D or 3D points, stored in ``std::vector<>`` or ``Mat``.
@@ -396,37 +395,37 @@ http://en.wikipedia.org/wiki/M-estimator
:math:`w_i` are adjusted to be inversely proportional to
:math:`\rho(r_i)` .
.. index:: isContourConvex
isContourConvex
-------------------
.. ocv:function:: bool isContourConvex( InputArray contour )
Tests a contour convexity.
Tests a contour convexity.
.. ocv:function:: bool isContourConvex( InputArray contour )
:param contour: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function tests whether the input contour is convex or not. The contour must be simple, that is, without self-intersections. Otherwise, the function output is undefined.
.. index:: minAreaRect
minAreaRect
---------------
.. ocv:function:: RotatedRect minAreaRect( InputArray points )
Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
.. ocv:function:: RotatedRect minAreaRect( InputArray points )
:param points: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a specified point set. See the OpenCV sample ``minarea.cpp`` .
.. index:: minEnclosingCircle
minEnclosingCircle
----------------------
.. ocv:function:: void minEnclosingCircle( InputArray points, Point2f& center, float& radius )
Finds a circle of the minimum area enclosing a 2D point set.
Finds a circle of the minimum area enclosing a 2D point set.
.. ocv:function:: void minEnclosingCircle( InputArray points, Point2f& center, float& radius )
:param points: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
@@ -436,13 +435,13 @@ minEnclosingCircle
The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. See the OpenCV sample ``minarea.cpp`` .
.. index:: matchShapes
matchShapes
---------------
.. ocv:function:: double matchShapes( InputArray object1, InputArray object2, int method, double parameter=0 )
Compares two shapes.
Compares two shapes.
.. ocv:function:: double matchShapes( InputArray object1, InputArray object2, int method, double parameter=0 )
:param object1: The first contour or grayscale image.
@@ -486,13 +485,13 @@ and
:math:`A` and
:math:`B` , respectively.
.. index:: pointPolygonTest
pointPolygonTest
--------------------
.. ocv:function:: double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist )
Performs a point-in-contour test.
Performs a point-in-contour test.
.. ocv:function:: double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist )
:param contour: Input contour.
+25 -35
View File
@@ -24,12 +24,14 @@ The boosted model is based on
:math:`K` -component vector. Each component encodes a feature relevant to the learning task at hand. The desired two-class output is encoded as -1 and +1.
Different variants of boosting are known as Discrete Adaboost, Real AdaBoost, LogitBoost, and Gentle AdaBoost
:ref:`[FHT98] <FHT98>` . All of them are very similar in their overall structure. Therefore, this chapter focuses only on the standard two-class Discrete AdaBoost algorithm as shown in the box below??. Initially the same weight is assigned to each sample (step 2). Then, a weak classifier
:ref:`[FHT98] <FHT98>` . All of them are very similar in their overall structure. Therefore, this chapter focuses only on the standard two-class Discrete AdaBoost algorithm, outlined below. Initially the same weight is assigned to each sample (step 2). Then, a weak classifier
:math:`f_{m(x)}` is trained on the weighted training data (step 3a). Its weighted training error and scaling factor
:math:`c_m` is computed (step 3b). The weights are increased for training samples that have been misclassified (step 3c). All weights are then normalized, and the process of finding the next weak classifier continues for another
:math:`M` -1 times. The final classifier
:math:`F(x)` is the sign of the weighted sum over the individual weak classifiers (step 4).
**Two-class Discrete AdaBoost Algorithm**
#.
Set
:math:`N` examples
@@ -41,29 +43,17 @@ Different variants of boosting are known as Discrete Adaboost, Real AdaBoost, Lo
:math:`w_i = 1/N, i = 1,...,N` .
#.
Repeat for
:math:`m` =
:math:`1,2,...,M` :
Repeat for :math:`m = 1,2,...,M` :
#.
Fit the classifier
:math:`f_m(x) \in{-1,1}` , using weights
:math:`w_i` on the training data.
3.1. Fit the classifier :math:`f_m(x) \in{-1,1}`, using weights :math:`w_i` on the training data.
#.
Compute
:math:`err_m = E_w [1_{(y =\neq f_m(x))}], c_m = log((1 - err_m)/err_m)` .
3.2. Compute :math:`err_m = E_w [1_{(y \neq f_m(x))}], c_m = log((1 - err_m)/err_m)` .
#.
Set
:math:`w_i \Leftarrow w_i exp[c_m 1_{(y_i \neq f_m(x_i))}], i = 1,2,...,N,` and renormalize so that
:math:`\Sigma i w_i = 1` .
3.3. Set :math:`w_i \Leftarrow w_i exp[c_m 1_{(y_i \neq f_m(x_i))}], i = 1,2,...,N,` and renormalize so that :math:`\Sigma i w_i = 1` .
#.
Output the classifier sign
:math:`[\Sigma m = 1M c_m f_m(x)]` .
Two-class Discrete AdaBoost Algorithm: Training (steps 1 to 3) and Evaluation (step 4)??you need to revise this section. what is this? a title for the image that is missing?
#. Classify new samples *x* using the formula: :math:`\sign (\Sigma m = 1M c_m f_m(x))` .
.. note:: Similar to the classical boosting methods, the current implementation supports two-class classifiers only. For M
:math:`>` two classes, there is the **AdaBoost.MH** algorithm (described in :ref:`[FHT98] <FHT98>` ) that reduces the problem to the two-class problem, yet with a much larger training set.
@@ -93,6 +83,8 @@ All parameters are public. You can initialize them by a constructor and then ove
CvBoostParams::CvBoostParams
----------------------------
The constructors.
.. ocv:function:: CvBoostParams::CvBoostParams()
.. ocv:function:: CvBoostParams::CvBoostParams( int boost_type, int weak_count, double weight_trim_rate, int max_depth, bool use_surrogates, const float* priors )
@@ -120,10 +112,6 @@ Also there is one parameter that you can set directly.
* **CvBoost::MISCLASS** Default option for discrete AdaBoost.
* **CvBoost::SQERR** Least-square error; only option available for LogitBoost and gentle AdaBoost.
.. index:: CvBoostTree
.. _CvBoostTree:
CvBoostTree
-----------
.. ocv:class:: CvBoostTree
@@ -168,25 +156,25 @@ Boosted tree classifier derived from :ocv:class:`CvStatModel`.
CvBoost::train
--------------
.. ocv:function:: bool CvBoost::train( const Mat& _train_data, int _tflag, const Mat& _responses, const Mat& _var_idx=Mat(), const Mat& _sample_idx=Mat(), const Mat& _var_type=Mat(), const Mat& _missing_mask=Mat(), CvBoostParams params=CvBoostParams(), bool update=false )
Trains a boosted tree classifier.
Trains a boosted tree classifier.
.. ocv:function:: bool CvBoost::train( const Mat& _train_data, int _tflag, const Mat& _responses, const Mat& _var_idx=Mat(), const Mat& _sample_idx=Mat(), const Mat& _var_type=Mat(), const Mat& _missing_mask=Mat(), CvBoostParams params=CvBoostParams(), bool update=false )
The train method follows the common template. The last parameter ``update`` specifies whether the classifier needs to be updated (the new weak tree classifiers added to the existing ensemble) or the classifier needs to be rebuilt from scratch. The responses must be categorical, which means that boosted trees cannot be built for regression, and there should be two classes.
CvBoost::predict
----------------
.. ocv:function:: float CvBoost::predict( const Mat& sample, const Mat& missing=Mat(), const Range& slice=Range::all(), bool rawMode=false, bool returnSum=false ) const
Predicts a response for an input sample.
Predicts a response for an input sample.
.. ocv:function:: float CvBoost::predict( const Mat& sample, const Mat& missing=Mat(), const Range& slice=Range::all(), bool rawMode=false, bool returnSum=false ) const
The method ``CvBoost::predict`` runs the sample through the trees in the ensemble and returns the output class label based on the weighted voting.
CvBoost::prune
--------------
.. ocv:function:: void CvBoost::prune( CvSlice slice )
Removes the specified weak classifiers.
Removes the specified weak classifiers.
.. ocv:function:: void CvBoost::prune( CvSlice slice )
The method removes the specified weak classifiers from the sequence.
@@ -195,30 +183,32 @@ The method removes the specified weak classifiers from the sequence.
CvBoost::calc_error
-------------------
.. ocv:function:: float CvBoost::calc_error( CvMLData* _data, int type , std::vector<float> *resp = 0 )
Returns error of the boosted tree classifier.
Returns error of the boosted tree classifier.
.. ocv:function:: float CvBoost::calc_error( CvMLData* _data, int type , std::vector<float> *resp = 0 )
The method is identical to :ocv:func:`CvDTree::calc_error` but uses the boosted tree classifier as predictor.
CvBoost::get_weak_predictors
----------------------------
Returns the sequence of weak tree classifiers.
.. ocv:function:: CvSeq* CvBoost::get_weak_predictors()
Returns the sequence of weak tree classifiers.
The method returns the sequence of weak classifiers. Each element of the sequence is a pointer to the ``CvBoostTree`` class or to some of its derivatives.
CvBoost::get_params
-------------------
.. ocv:function:: const CvBoostParams& CvBoost::get_params() const
Returns current parameters of the boosted tree classifier.
Returns current parameters of the boosted tree classifier.
.. ocv:function:: const CvBoostParams& CvBoost::get_params() const
CvBoost::get_data
-----------------
Returns used train data of the boosted tree classifier.
.. ocv:function:: const CvDTreeTrainData* CvBoost::get_data() const
Returns used train data of the boosted tree classifier.
+19 -23
View File
@@ -138,14 +138,14 @@ Decision tree training data and shared data for tree ensembles. ::
CvDTreeParams
-------------
.. c:type:: CvDTreeParams
Decision tree training parameters.
.. ocv:class:: CvDTreeParams
The structure contains all the decision tree training parameters. You can initialize it by default constructor and then override any parameters directly before training, or the structure may be fully initialized using the advanced variant of the constructor.
CvDTreeParams::CvDTreeParams
----------------------------
The constructors.
.. ocv:function:: CvDTreeParams::CvDTreeParams()
.. ocv:function:: CvDTreeParams::CvDTreeParams( int max_depth, int min_sample_count, float regression_accuracy, bool use_surrogates, int max_categories, int cv_folds, bool use_1se_rule, bool truncate_pruned_tree, const float* priors )
@@ -182,9 +182,7 @@ CvDTreeTrainData
----------------
.. ocv:class:: CvDTreeTrainData
Decision tree training data and shared data for tree ensembles.
The structure is mostly used internally for storing both standalone trees and tree ensembles efficiently. Basically, it contains the following types of information:
Decision tree training data and shared data for tree ensembles. The structure is mostly used internally for storing both standalone trees and tree ensembles efficiently. Basically, it contains the following types of information:
#. Training parameters, an instance of :ocv:class:`CvDTreeParams`.
@@ -209,13 +207,13 @@ CvDTree
-------
.. ocv:class:: CvDTree
Decision tree.
The class implements a decision tree predictor as described in the beginning of this section.
The class implements a decision tree as described in the beginning of this section.
CvDTree::train
--------------
Trains a decision tree.
.. ocv:function:: bool CvDTree::train( const Mat& train_data, int tflag, const Mat& responses, const Mat& var_idx=Mat(), const Mat& sample_idx=Mat(), const Mat& var_type=Mat(), const Mat& missing_mask=Mat(), CvDTreeParams params=CvDTreeParams() )
.. ocv:function:: bool CvDTree::train( const CvMat* trainData, int tflag, const CvMat* responses, const CvMat* varIdx=0, const CvMat* sampleIdx=0, const CvMat* varType=0, const CvMat* missingDataMask=0, CvDTreeParams params=CvDTreeParams() )
@@ -224,8 +222,6 @@ CvDTree::train
.. ocv:function:: bool CvDTree::train( CvDTreeTrainData* trainData, const CvMat* subsampleIdx )
Trains a decision tree.
There are four ``train`` methods in :ocv:class:`CvDTree`:
* The **first two** methods follow the generic ``CvStatModel::train`` conventions. It is the most complete form. Both data layouts (``tflag=CV_ROW_SAMPLE`` and ``tflag=CV_COL_SAMPLE``) are supported, as well as sample and variable subsets, missing measurements, arbitrary combinations of input and output variable types, and so on. The last parameter contains all of the necessary training parameters (see the :ref:`CvDTreeParams` description).
@@ -238,12 +234,12 @@ There are four ``train`` methods in :ocv:class:`CvDTree`:
CvDTree::predict
----------------
Returns the leaf node of a decision tree corresponding to the input vector.
.. ocv:function:: CvDTreeNode* CvDTree::predict( const Mat& sample, const Mat& missing_data_mask=Mat(), bool raw_mode=false ) const
.. ocv:function:: CvDTreeNode* CvDTree::predict( const CvMat* sample, const CvMat* missingDataMask=0, bool preprocessedInput=false ) const
Returns the leaf node of a decision tree corresponding to the input vector.
:param sample: Sample for prediction.
:param missing_data: Optional input missing measurement mask.
@@ -256,9 +252,9 @@ The method traverses the decision tree and returns the reached leaf node as outp
CvDTree::calc_error
-------------------
.. ocv:function:: float CvDTree::calc_error( CvMLData* trainData, int type, std::vector<float> *resp = 0 )
Returns error of the decision tree.
Returns error of the decision tree.
.. ocv:function:: float CvDTree::calc_error( CvMLData* trainData, int type, std::vector<float> *resp = 0 )
:param data: Data for the decision tree.
@@ -275,33 +271,33 @@ The method calculates error of the decision tree. In case of classification it i
CvDTree::getVarImportance
-------------------------
Returns the variable importance array.
.. ocv:function:: Mat CvDTree::getVarImportance()
.. ocv:function:: const CvMat* CvDTree::get_var_importance()
Returns the variable importance array.
CvDTree::get_root
-----------------
.. ocv:function:: const CvDTreeNode* CvDTree::get_root() const
Returns the root of the decision tree.
Returns the root of the decision tree.
.. ocv:function:: const CvDTreeNode* CvDTree::get_root() const
CvDTree::get_pruned_tree_idx
----------------------------
.. ocv:function:: int CvDTree::get_pruned_tree_idx() const
Returns the ``CvDTree::pruned_tree_idx`` parameter.
Returns the ``CvDTree::pruned_tree_idx`` parameter.
.. ocv:function:: int CvDTree::get_pruned_tree_idx() const
The parameter ``DTree::pruned_tree_idx`` is used to prune a decision tree. See the ``CvDTreeNode::Tn`` parameter.
CvDTree::get_data
-----------------
.. ocv:function:: const CvDTreeTrainData* CvDTree::get_data() const
Returns used train data of the decision tree.
Returns used train data of the decision tree.
.. ocv:function:: const CvDTreeTrainData* CvDTree::get_data() const
Example: building a tree for classifying mushrooms. See the ``mushroom.cpp`` sample that demonstrates how to build and use the
decision tree.
+28 -29
View File
@@ -90,17 +90,17 @@ CvEMParams
----------
.. ocv:class:: CvEMParams
Parameters of the EM algorithm.
All parameters are public. You can initialize them by a constructor and then override some of them directly if you want.
Parameters of the EM algorithm. All parameters are public. You can initialize them by a constructor and then override some of them directly if you want.
CvEMParams::CvEMParams
----------------------
The constructors
.. ocv:function:: CvEMParams::CvEMParams()
.. ocv:function:: CvEMParams::CvEMParams( int nclusters, int cov_mat_type=1/*CvEM::COV_MAT_DIAGONAL*/, int start_step=0/*CvEM::START_AUTO_STEP*/, CvTermCriteria term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON), const CvMat* probs=0, const CvMat* weights=0, const CvMat* means=0, const CvMat** covs=0 )
.. ocv:function:: CvEMParams::CvEMParams( int nclusters, int cov_mat_type=CvEM::COV_MAT_DIAGONAL, int start_step=CvEM::START_AUTO_STEP, CvTermCriteria term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON), const CvMat* probs=0, const CvMat* weights=0, const CvMat* means=0, const CvMat** covs=0 )
:param nclusters: The number of mixtures in the gaussian mixture model.
@@ -149,12 +149,12 @@ CvEM
CvEM::train
-----------
Estimates the Gaussian mixture parameters from a sample set.
.. ocv:function:: void CvEM::train( const Mat& samples, const Mat& sample_idx=Mat(), CvEMParams params=CvEMParams(), Mat* labels=0 )
.. ocv:function:: bool CvEM::train( const CvMat* samples, const CvMat* sampleIdx=0, CvEMParams params=CvEMParams(), CvMat* labels=0 )
Estimates the Gaussian mixture parameters from a sample set.
:param samples: Samples from which the Gaussian mixture model will be estimated.
:param sample_idx: Mask of samples to use. All samples are used by default.
@@ -181,12 +181,12 @@ For an example of clustering random samples of the multi-Gaussian distribution u
CvEM::predict
-------------
Returns a mixture component index of a sample.
.. ocv:function:: float CvEM::predict( const Mat& sample, Mat* probs=0 ) const
.. ocv:function:: float CvEM::predict( const CvMat* sample, CvMat* probs ) const
Returns a mixture component index of a sample.
:param sample: A sample for classification.
:param probs: If it is not null then the method will write posterior probabilities of each component given the sample data to this parameter.
@@ -194,89 +194,88 @@ CvEM::predict
CvEM::getNClusters
------------------
Returns the number of mixture components :math:`M` in the gaussian mixture model.
.. ocv:function:: int CvEM::getNClusters() const
.. ocv:function:: int CvEM::get_nclusters() const
Returns the number of mixture components :math:`M` in the gaussian mixture model.
CvEM::getNClusters
------------------
Returns mixture means :math:`a_k`.
.. ocv:function:: Mat CvEM::getMeans() const
.. ocv:function:: const CvMat* CvEM::get_means() const
Returns mixture means :math:`a_k`.
CvEM::getCovs
-------------
Returns mixture covariance matrices :math:`S_k`.
.. ocv:function:: void CvEM::getCovs(std::vector<cv::Mat>& covs) const
.. ocv:function:: const CvMat** CvEM::get_covs() const
Returns mixture covariance matrices :math:`S_k`.
CvEM::getWeights
----------------
Returns mixture weights :math:`\pi_k`.
.. ocv:function:: Mat CvEM::getWeights() const
.. ocv:function:: const CvMat* CvEM::get_weights() const
Returns mixture weights :math:`\pi_k`.
CvEM::getProbs
--------------
Returns vectors of probabilities for each training sample.
.. ocv:function:: Mat CvEM::getProbs() const
.. ocv:function:: const CvMat* CvEM::get_probs() const
Returns probabilites :math:`p_{i,k}` of sample :math:`i` to belong to a mixture component :math:`k`.
Returns probabilites :math:`p_{i,k}` of sample :math:`i` (that have been passed to the constructor or to :ocv:func:`CvEM::train`) to belong to a mixture component :math:`k`.
CvEM::getLikelihood
-------------------
Returns logarithm of likelihood.
.. ocv:function:: double CvEM::getLikelihood() const
.. ocv:function:: double CvEM::get_log_likelihood() const
Returns logarithm of likelihood.
CvEM::getLikelihoodDelta
------------------------
Returns difference between logarithm of likelihood on the last iteration and logarithm of likelihood on the previous iteration.
.. ocv:function:: double CvEM::getLikelihoodDelta() const
.. ocv:function:: double CvEM::get_log_likelihood_delta() const
Returns difference between logarithm of likelihood on the last iteration and logarithm of likelihood on the previous iteration.
CvEM::write_params
------------------
.. ocv:function:: void CvEM::write_params( CvFileStorage* fs ) const
Writes used parameters of the EM algorithm to a file storage.
Writes used parameters of the EM algorithm to a file storage.
.. ocv:function:: void CvEM::write_params( CvFileStorage* fs ) const
:param fs: A file storage where parameters will be written.
CvEM::read_params
-----------------
.. ocv:function:: void CvEM::read_params( CvFileStorage* fs, CvFileNode* node )
Reads parameters of the EM algorithm.
Reads parameters of the EM algorithm.
.. ocv:function:: void CvEM::read_params( CvFileStorage* fs, CvFileNode* node )
:param fs: A file storage with parameters of the EM algorithm.
:param node: The parent map. If it is NULL, the function searches a node with parameters in all the top-level nodes (streams), starting with the first one.
Read parameters will be used for the EM algorithm in this ``CvEM`` object.
For example of clustering random samples of multi-Gaussian distribution using EM see em.cpp sample in OpenCV distribution.
The function reads EM parameters from the specified file storage node. For example of clustering random samples of multi-Gaussian distribution using EM see em.cpp sample in OpenCV distribution.
+16 -37
View File
@@ -14,8 +14,6 @@ Decision trees (:ocv:class:`CvDTree`) usage as base learners allows to process o
and categorical variables.
.. _Training the GBT model:
Training the GBT model
----------------------
@@ -91,8 +89,6 @@ is a regularization parameter from the interval :math:`(0,1]`, futher called
*shrinkage*.
.. _Predicting with GBT model:
Predicting with the GBT Model
-------------------------
@@ -104,9 +100,6 @@ For classification problems, the result is :math:`\arg\max_{i=1..K}(f_i(x))`.
.. highlight:: cpp
.. index:: CvGBTreesParams
.. _CvGBTreesParams:
CvGBTreesParams
---------------
.. ocv:class:: CvGBTreesParams
@@ -158,11 +151,6 @@ By default the following constructor is used:
CvGBTreesParams(CvGBTrees::SQUARED_LOSS, 200, 0.8f, 0.01f, 3, false)
: CvDTreeParams( 3, 10, 0, false, 10, 0, false, false, 0 )
.. index:: CvGBTrees
.. _CvGBTrees:
CvGBTrees
---------
.. ocv:class:: CvGBTrees
@@ -231,19 +219,18 @@ GBT model. ::
};
.. index:: CvGBTrees::train
.. _CvGBTrees::train:
CvGBTrees::train
----------------
<<<<<<< .mine
Trains a Gradient boosted tree model.
.. ocv:function:: bool train(const Mat & trainData, int tflag, const Mat & responses, const Mat & varIdx=Mat(), const Mat & sampleIdx=Mat(), const Mat & varType=Mat(), const Mat & missingDataMask=Mat(), CvGBTreesParams params=CvGBTreesParams(), bool update=false)
=======
.. ocv:function:: bool CvGBTrees::train(const Mat& trainData, int tflag, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), const Mat& varType=Mat(), const Mat& missingDataMask=Mat(), CvGBTreesParams params=CvGBTreesParams(), bool update=false)
>>>>>>> .r5669
.. ocv:function:: bool CvGBTrees::train(CvMLData* data, CvGBTreesParams params=CvGBTreesParams(), bool update=false)
Trains a Gradient boosted tree model.
The first train method follows the common template (see :ocv:func:`CvStatModel::train`).
Both ``tflag`` values (``CV_ROW_SAMPLE``, ``CV_COL_SAMPLE``) are supported.
``trainData`` must be of the ``CV_32F`` type. ``responses`` must be a matrix of type
@@ -259,15 +246,15 @@ All parameters specific to the GBT model are passed into the training function
as a :ocv:class:`CvGBTreesParams` structure.
.. index:: CvGBTrees::predict
.. _CvGBTrees::predict:
CvGBTrees::predict
------------------
<<<<<<< .mine
Predicts a response for an input sample.
=======
.. ocv:function:: float CvGBTrees::predict(const Mat& sample, const Mat& missing=Mat(), const Range& slice = Range::all(), int k=-1) const
>>>>>>> .r5669
Predicts a response for an input sample.
.. ocv:function:: float predict(const Mat & sample, const Mat & missing=Mat(), const Range & slice = Range::all(), int k=-1) const
:param sample: Input feature vector that has the same format as every training set
element. If not all the variables were actualy used during training,
@@ -302,30 +289,22 @@ prediction if the OpenCV is built with the TBB library. In this case, prediction
of single trees are computed in a parallel fashion.
.. index:: CvGBTrees::clear
.. _CvGBTrees::clear:
CvGBTrees::clear
----------------
.. ocv:function:: void CvGBTrees::clear()
Clears the model.
Clears the model.
.. ocv:function:: void CvGBTrees::clear()
The finction deletes the data set information and all the weak models and sets all internal
The function deletes the data set information and all the weak models and sets all internal
variables to the initial state. The function is called in :ocv:func:`CvGBTrees::train` and in the
destructor.
.. index:: CvGBTrees::calc_error
.. _CvGBTrees::calc_error:
CvGBTrees::calc_error
---------------------
.. ocv:function:: float CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp = 0 )
Calculates a training or testing error.
Calculates a training or testing error.
.. ocv:function:: float CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp = 0 )
:param _data: Data set.
+4 -16
View File
@@ -7,10 +7,6 @@ The algorithm caches all training samples and predicts the response for a new sa
**K**
) of the nearest neighbors of the sample using voting, calculating weighted sum, and so on. The method is sometimes referred to as "learning by example" because for prediction it looks for the feature vector with a known response that is closest to the given vector.
.. index:: CvKNearest
.. _CvKNearest:
CvKNearest
----------
.. ocv:class:: CvKNearest
@@ -45,15 +41,11 @@ K-Nearest Neighbors model. ::
};
.. index:: CvKNearest::train
.. _CvKNearest::train:
CvKNearest::train
-----------------
.. ocv:function:: bool CvKNearest::train( const Mat& _train_data, const Mat& _responses, const Mat& _sample_idx=Mat(), bool is_regression=false, int _max_k=32, bool _update_base=false )
Trains the model.
Trains the model.
.. ocv:function:: bool CvKNearest::train( const Mat& _train_data, const Mat& _responses, const Mat& _sample_idx=Mat(), bool is_regression=false, int _max_k=32, bool _update_base=false )
The method trains the K-Nearest model. It follows the conventions of the generic ``train`` approach with the following limitations:
@@ -67,15 +59,11 @@ The parameter ``_max_k`` specifies the number of maximum neighbors that may be p
The parameter ``_update_base`` specifies whether the model is trained from scratch
( ``_update_base=false`` ), or it is updated using the new training data ( ``_update_base=true`` ). In the latter case, the parameter ``_max_k`` must not be larger than the original value.
.. index:: CvKNearest::find_nearest
.. _CvKNearest::find_nearest:
CvKNearest::find_nearest
------------------------
.. ocv:function:: float CvKNearest::find_nearest( const Mat& _samples, int k, Mat* results=0, const float** neighbors=0, Mat* neighbor_responses=0, Mat* dist=0 ) const
Finds the neighbors for input vectors.
Finds the neighbors for input vectors.
.. ocv:function:: float CvKNearest::find_nearest( const Mat& _samples, int k, Mat* results=0, const float** neighbors=0, Mat* neighbor_responses=0, Mat* dist=0 ) const
For each input vector (a row of the matrix ``_samples`` ), the method finds the
:math:`\texttt{k} \le
+67 -39
View File
@@ -56,156 +56,184 @@ Class for loading the data from a ``.csv`` file.
CvMLData::read_csv
------------------
Reads the data set from a ``.csv``-like ``filename`` file and stores all read values in a matrix.
.. ocv:function:: int CvMLData::read_csv(const char* filename);
Reads the data set from a ``.csv``-like ``filename`` file and stores all read values in a matrix.
:param filename: The input file name
While reading the data, the method tries to define the type of variables (predictors and responses): ordered or categorical. If a value of the variable is not numerical (except for the label for a missing value), the type of the variable is set to ``CV_VAR_CATEGORICAL``. If all existing values of the variable are numerical, the type of the variable is set to ``CV_VAR_ORDERED``. So, the default definition of variables types works correctly for all cases except the case of a categorical variable with numerical class labeles. In this case, the type ``CV_VAR_ORDERED`` is set. You should change the type to ``CV_VAR_CATEGORICAL`` using the method :ocv:func:`CvMLData::change_var_type`. For categorical variables, a common map is built to convert a string class label to the numerical class label. Use :ocv:func:`CvMLData::get_class_labels_map` to obtain this map.
Also, when reading the data, the method constructs the mask of missing values. For example, values are egual to `'?'`.
CvMLData::get_values
--------------------
Returns a pointer to the matrix of predictors and response values
.. ocv:function:: const CvMat* CvMLData::get_values() const;
Returns a pointer to the matrix of predictor and response ``values`` or ``0`` if the data has not been loaded from the file yet.
The method returns a pointer to the matrix of predictor and response ``values`` or ``0`` if the data has not been loaded from the file yet.
The row count of this matrix equals the sample count. The column count equals predictors ``+ 1`` for the response (if exists) count. This means that each row of the matrix contains values of one sample predictor and response. The matrix type is ``CV_32FC1``.
CvMLData::get_responses
-----------------------
Returns a pointer to the matrix of response values
.. ocv:function:: const CvMat* CvMLData::get_responses();
Returns a pointer to the matrix of response values or throws an exception if the data has not been loaded from the file yet.
The method returns a pointer to the matrix of response values or throws an exception if the data has not been loaded from the file yet.
This is a single-column matrix of the type ``CV_32FC1``. Its row count is equal to the sample count, one column and .
CvMLData::get_missing
---------------------
Returns a pointer to the mask matrix of missing values
.. ocv:function:: const CvMat* CvMLData::get_missing() const;
Returns a pointer to the mask matrix of missing values or throws an exception if the data has not been loaded from the file yet.
The method returns a pointer to the mask matrix of missing values or throws an exception if the data has not been loaded from the file yet.
This matrix has the same size as the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) and the type ``CV_8UC1``.
CvMLData::set_response_idx
--------------------------
Specifies index of response column in the data matrix
.. ocv:function:: void CvMLData::set_response_idx( int idx );
Sets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
The method sets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
The old response columns become predictors. If ``idx < 0``, there is no response.
CvMLData::get_response_idx
----------
--------------------------
Returns index of the response column in the loaded data matrix
.. ocv:function:: int CvMLData::get_response_idx() const;
Gets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
The method returns the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
If ``idx < 0``, there is no response.
CvMLData::set_train_test_split
------------------------------
Divides the read data set into two disjoint training and test subsets.
.. ocv:function:: void CvMLData::set_train_test_split( const CvTrainTestSplit * spl );
Divides the read data set into two disjoint training and test subsets.
This method sets parameters for such a split using ``spl`` (see :ocv:class:`CvTrainTestSplit`) or throws an exception if the data has not been loaded from the file yet.
CvMLData::get_train_sample_idx
------------------------------
Returns the matrix of sample indices for a training subset
.. ocv:function:: const CvMat* CvMLData::get_train_sample_idx() const;
Divides the data set into training and test subsets by setting a split (see :ocv:func:`CvMLData::set_train_test_split`).
The current method returns the matrix of sample indices for a training subset. This is a single-row matrix of the type ``CV_32SC1``. If data split is not set, the method returns ``0``. If the data has not been loaded from the file yet, an exception is thrown.
The method returns the matrix of sample indices for a training subset. This is a single-row matrix of the type ``CV_32SC1``. If data split is not set, the method returns ``0``. If the data has not been loaded from the file yet, an exception is thrown.
CvMLData::get_test_sample_idx
-----------------------------
Returns the matrix of sample indices for a testing subset
.. ocv:function:: const CvMat* CvMLData::get_test_sample_idx() const;
Provides functionality similar to :ocv:func:`CvMLData::get_train_sample_idx` but for a test subset.
CvMLData::mix_train_and_test_idx
--------------------------------
Mixes the indices of training and test samples
.. ocv:function:: void CvMLData::mix_train_and_test_idx();
Mixes the indices of training and test samples preserving sizes of training and test subsets if the data split is set by :ocv:func:`CvMLData::get_values`. If the data has not been loaded from the file yet, an exception is thrown.
The method shuffles the indices of training and test samples preserving sizes of training and test subsets if the data split is set by :ocv:func:`CvMLData::get_values`. If the data has not been loaded from the file yet, an exception is thrown.
CvMLData::get_var_idx
---------------------
Returns the indices of the active variables in the data matrix
.. ocv:function:: const CvMat* CvMLData::get_var_idx();
Returns the indices of variables (columns) used in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`).
The method returns the indices of variables (columns) used in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`).
The function returns `0`` if the used subset is not set. It throws an exception if the data has not been loaded from the file yet. Returned matrix is a single-row matrix of the type ``CV_32SC1``. Its column count is equal to the size of the used variable subset.
It returns ``0`` if the used subset is not set. It throws an exception if the data has not been loaded from the file yet. Returned matrix is a single-row matrix of the type ``CV_32SC1``. Its column count is equal to the size of the used variable subset.
CvMLData::chahge_var_idx
------------------------
Enables or disables particular variable in the loaded data
.. ocv:function:: void CvMLData::chahge_var_idx( int vi, bool state );
Controls the data set by changing the number of variables.??
By default, after reading the data set all variables in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) are used. But you may want to use only a subset of variables and include/exclude (depending on ``state`` value) a variable with the ``vi`` index from the used subset. If the data has not been loaded from the file yet, an exception is thrown.
CvMLData::get_var_types
-----------------------
Returns a matrix of the variable types.
.. ocv:function:: const CvMat* CvMLData::get_var_types();
Returns a matrix of used variable types.
The function returns a single-row matrix of the type ``CV_8UC1``. column count equel to used variables count and type . If data has not been loaded from file yet an exception is thrown.
The function returns a single-row matrix of the type ``CV_8UC1``, where each element is set to either ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``. The number of columns is equal to the number of variables. If data has not been loaded from file yet an exception is thrown.
CvMLData::set_var_types
-----------------------
Sets the variables types in the loaded data.
.. ocv:function:: void CvMLData::set_var_types( const char* str );
Sets variables types according to the given string ``str``.
In the string, a variable type is followed by a list of variables indices. For example: ``"ord[0-17],cat[18]"``, ``"ord[0,2,4,10-12], cat[1,3,5-9,13,14]"``, ``"cat"`` (all variables are categorical), ``"ord"`` (all variables are ordered).
CvMLData::get_var_type
----------------------
Returns type of the specified variable
.. ocv:function:: int CvMLData::get_var_type( int var_idx ) const;
Returns the type of a variable by the index ``var_idx`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
The method returns the type of a variable by the index ``var_idx`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
CvMLData::change_var_type
-------------------------
Changes type of the specified variable
.. ocv:function:: void CvMLData::change_var_type( int var_idx, int type);
Changes type of variable with index ``var_idx`` from existing type to ``type`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
The method changes type of variable with index ``var_idx`` from existing type to ``type`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
CvMLData::set_delimiter
-----------------------
Sets the delimiter in the file used to separate input numbers
.. ocv:function:: void CvMLData::set_delimiter( char ch );
Sets the delimiter for variable values in a file. For example: ``','`` (default), ``';'``, ``' '`` (space), or other characters. The float separator ``'.'`` is not allowed.
The method sets the delimiter for variables in a file. For example: ``','`` (default), ``';'``, ``' '`` (space), or other characters. The floating-point separator ``'.'`` is not allowed.
CvMLData::get_delimiter
-----------------------
Returns the currently used delimiter character.
.. ocv:function:: char CvMLData::get_delimiter() const;
Gets the set delimiter character.
CvMLData::set_miss_ch
---------------------
Sets the character used to specify missing values
.. ocv:function:: void CvMLData::set_miss_ch( char ch );
Sets the character for a missing value. For example: ``'?'`` (default), ``'-'``. The float separator ``'.'`` is not allowed.
The method sets the character used to specify missing values. For example: ``'?'`` (default), ``'-'``. The floating-point separator ``'.'`` is not allowed.
CvMLData::get_miss_ch
---------------------
.. ocv:function:: char CvMLData::get_miss_ch() const;
Returns the currently used missing value character.
Gets the character for a missing value.
.. ocv:function:: char CvMLData::get_miss_ch() const;
CvMLData::get_class_labels_map
-------------------------------
Returns a map that converts strings to labels.
.. ocv:function:: const std::map<std::string, int>& CvMLData::get_class_labels_map() const;
Returns a map that converts string class labels to the numerical class labels. It can be used to get an original class label as in a file.
The method returns a map that converts string class labels to the numerical class labels. It can be used to get an original class label as in a file.
CvTrainTestSplit
----------------
+4 -19
View File
@@ -100,9 +100,6 @@ References:
*
M. Riedmiller and H. Braun, *A Direct Adaptive Method for Faster Backpropagation Learning: The RPROP Algorithm*, Proc. ICNN, San Francisco (1993).
.. index:: CvANN_MLP_TrainParams
.. _CvANN_MLP_TrainParams:
CvANN_MLP_TrainParams
---------------------
@@ -133,10 +130,6 @@ Parameters of the MLP training algorithm. ::
The structure has a default constructor that initializes parameters for the ``RPROP`` algorithm. There is also a more advanced constructor to customize the parameters and/or choose the back-propagation algorithm. Finally, the individual parameters can be adjusted after the structure is created.
.. index:: CvANN_MLP
.. _CvANN_MLP:
CvANN_MLP
---------
.. ocv:class:: CvANN_MLP
@@ -224,15 +217,11 @@ MLP model. ::
Unlike many other models in ML that are constructed and trained at once, in the MLP model these steps are separated. First, a network with the specified topology is created using the non-default constructor or the method ``create`` . All the weights are set to zeros. Then, the network is trained using a set of input and output vectors. The training procedure can be repeated more than once, that is, the weights can be adjusted based on the new training data.
.. index:: CvANN_MLP::create
.. _CvANN_MLP::create:
CvANN_MLP::create
-----------------
.. ocv:function:: void CvANN_MLP::create( const Mat& _layer_sizes, int _activ_func=SIGMOID_SYM, double _f_param1=0, double _f_param2=0 )
Constructs MLP with the specified topology.
Constructs MLP with the specified topology.
.. ocv:function:: void CvANN_MLP::create( const Mat& _layer_sizes, int _activ_func=SIGMOID_SYM, double _f_param1=0, double _f_param2=0 )
:param _layer_sizes: Integer vector specifying the number of neurons in each layer including the input and output layers.
@@ -242,15 +231,11 @@ CvANN_MLP::create
The method creates an MLP network with the specified topology and assigns the same activation function to all the neurons.
.. index:: CvANN_MLP::train
.. _CvANN_MLP::train:
CvANN_MLP::train
----------------
.. ocv:function:: int CvANN_MLP::train( const Mat& _inputs, const Mat& _outputs, const Mat& _sample_weights, const Mat& _sample_idx=Mat(), CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), int flags=0 )
Trains/updates MLP.
Trains/updates MLP.
.. ocv:function:: int CvANN_MLP::train( const Mat& _inputs, const Mat& _outputs, const Mat& _sample_weights, const Mat& _sample_idx=Mat(), CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), int flags=0 )
:param _inputs: Floating-point matrix of input vectors, one vector per row.
+4 -14
View File
@@ -9,8 +9,6 @@ This simple classification model assumes that feature vectors from each class ar
[Fukunaga90] K. Fukunaga. *Introduction to Statistical Pattern Recognition*. second ed., New York: Academic Press, 1990.
.. index:: CvNormalBayesClassifier
CvNormalBayesClassifier
-----------------------
.. ocv:class:: CvNormalBayesClassifier
@@ -42,15 +40,11 @@ Bayes classifier for normally distributed data. ::
};
.. index:: CvNormalBayesClassifier::train
.. _CvNormalBayesClassifier::train:
CvNormalBayesClassifier::train
------------------------------
.. ocv:function:: bool CvNormalBayesClassifier::train( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx =Mat(), const Mat& _sample_idx=Mat(), bool update=false )
Trains the model.
Trains the model.
.. ocv:function:: bool CvNormalBayesClassifier::train( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx =Mat(), const Mat& _sample_idx=Mat(), bool update=false )
The method trains the Normal Bayes classifier. It follows the conventions of the generic ``train`` approach with the following limitations:
@@ -61,15 +55,11 @@ The method trains the Normal Bayes classifier. It follows the conventions of the
In addition, there is an ``update`` flag that identifies whether the model should be trained from scratch ( ``update=false`` ) or should be updated using the new training data ( ``update=true`` ).
.. index:: CvNormalBayesClassifier::predict
.. _CvNormalBayesClassifier::predict:
CvNormalBayesClassifier::predict
--------------------------------
.. ocv:function:: float CvNormalBayesClassifier::predict( const Mat& samples, Mat* results=0 ) const
Predicts the response for sample(s).
Predicts the response for sample(s).
.. ocv:function:: float CvNormalBayesClassifier::predict( const Mat& samples, Mat* results=0 ) const
The method ``predict`` estimates the most probable classes for input vectors. Input vectors (one or more) are stored as rows of the matrix ``samples`` . In case of multiple input vectors, there should be one output vector ``results`` . The predicted class for a single input vector is returned by the method.
+21 -20
View File
@@ -63,6 +63,8 @@ The set of training parameters for the forest is a superset of the training para
CvRTParams::CvRTParams:
-----------------------
The constructors.
.. ocv:function:: CvRTParams::CvRTParams()
.. ocv:function:: CvRTParams::CvRTParams( int max_depth, int min_sample_count, float regression_accuracy, bool use_surrogates, int max_categories, const float* priors, bool calc_var_importance, int nactive_vars, int max_num_of_trees_in_the_forest, float forest_accuracy, int termcrit_type )
@@ -95,24 +97,24 @@ CvRTrees
CvRTrees::train
---------------
Trains the Random Trees model.
.. ocv:function:: bool CvRTrees::train( CvMLData* data, CvRTParams params=CvRTParams() )
.. ocv:function:: bool CvRTrees::train( const Mat& trainData, int tflag, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), const Mat& varType=Mat(), const Mat& missingDataMask=Mat(), CvRTParams params=CvRTParams() )
.. ocv:function:: bool CvRTrees::train( const CvMat* trainData, int tflag, const CvMat* responses, const CvMat* varIdx=0, const CvMat* sampleIdx=0, const CvMat* varType=0, const CvMat* missingDataMask=0, CvRTParams params=CvRTParams() )
Trains the Random Tree model.
The method :ocv:func:`CvRTrees::train` is very similar to the method :ocv:func:`CvDTree::train` and follows the generic method :ocv:func:`CvStatModel::train` conventions. All the parameters specific to the algorithm training are passed as a :ocv:class:`CvRTParams` instance. The estimate of the training error (``oob-error``) is stored in the protected class member ``oob_error``.
CvRTrees::predict
-----------------
Predicts the output for an input sample.
.. ocv:function:: double CvRTrees::predict( const Mat& sample, const Mat& missing=Mat() ) const
.. ocv:function:: float CvRTrees::predict( const CvMat* sample, const CvMat* missing = 0 ) const
Predicts the output for an input sample.
:param sample: Sample for classification.
:param missing: Optional missing measurement mask of the sample.
@@ -122,12 +124,12 @@ The input parameters of the prediction method are the same as in :ocv:func:`CvDT
CvRTrees::predict_prob
----------------------
Returns a fuzzy-predicted class label.
.. ocv:function:: float CvRTrees::predict_prob( const cv::Mat& sample, const cv::Mat& missing = cv::Mat() ) const
.. ocv:function:: float CvRTrees::predict_prob( const CvMat* sample, const CvMat* missing = 0 ) const
Returns a fuzzy predicted class label.
:param sample: Sample for classification.
:param missing: Optional missing measurement mask of the sample.
@@ -137,20 +139,20 @@ The function works for binary classification problems only. It returns the numbe
CvRTrees::getVarImportance
----------------------------
Returns the variable importance array.
.. ocv:function:: Mat CvRTrees::getVarImportance()
.. ocv:function:: const CvMat* CvRTrees::get_var_importance()
Returns the variable importance array.
The method returns the variable importance vector, computed at the training stage when ``CvRTParams::calc_var_importance`` is set to true. If this flag was set to false, the ``NULL`` pointer is returned. This differs from the decision trees where variable importance can be computed anytime after the training.
CvRTrees::get_proximity
-----------------------
.. ocv:function:: float CvRTrees::get_proximity( const CvMat* sample1, const CvMat* sample2, const CvMat* missing1 = 0, const CvMat* missing2 = 0 ) const
Retrieves the proximity measure between two training samples.
Retrieves the proximity measure between two training samples.
.. ocv:function:: float CvRTrees::get_proximity( const CvMat* sample1, const CvMat* sample2, const CvMat* missing1 = 0, const CvMat* missing2 = 0 ) const
:param sample_1: The first sample.
@@ -164,41 +166,40 @@ The method returns proximity measure between any two samples. This is a ratio of
CvRTrees::calc_error
--------------------
Returns error of the random forest.
.. ocv:function:: float CvRTrees::calc_error( CvMLData* data, int type, std::vector<float> *resp = 0 )
Returns error of the random forest.
The method is identical to :ocv:func:`CvDTree::calc_error` but uses the random forest as predictor.
CvRTrees::get_train_error
-------------------------
.. ocv:function:: float CvRTrees::get_train_error()
Returns the train error.
Returns the train error.
.. ocv:function:: float CvRTrees::get_train_error()
The method works for classification problems only. It returns the proportion of incorrectly classified train samples.
CvRTrees::get_rng
-----------------
.. ocv:function:: CvRNG* CvRTrees::get_rng()
Returns the state of the used random number generator.
Returns the state of the used random number generator.
.. ocv:function:: CvRNG* CvRTrees::get_rng()
CvRTrees::get_tree_count
------------------------
.. ocv:function:: int CvRTrees::get_tree_count() const
Returns the number of trees in the constructed random forest.
Returns the number of trees in the constructed random forest.
.. ocv:function:: int CvRTrees::get_tree_count() const
CvRTrees::get_tree
------------------
Returns the specific decision tree in the constructed random forest.
.. ocv:function:: CvForestTree* CvRTrees::get_tree(int i) const
Returns the specific decision tree in the constructed random forest.
:param i: Index of the decision tree.
+20 -20
View File
@@ -42,25 +42,25 @@ In this declaration, some methods are commented off. These are methods for which
CvStatModel::CvStatModel
------------------------
.. ocv:function:: CvStatModel::CvStatModel()
The default constuctor.
Serves as a default constructor.
.. ocv:function:: CvStatModel::CvStatModel()
Each statistical model class in ML has a default constructor without parameters. This constructor is useful for a two-stage model construction, when the default constructor is followed by ``train()`` or ``load()`` .
CvStatModel::CvStatModel(...)
-----------------------------
.. ocv:function:: CvStatModel::CvStatModel( const Mat& train_data ... )
The training constructor.
Serves as a training constructor.
.. ocv:function:: CvStatModel::CvStatModel( const Mat& train_data ... )
Most ML classes provide a single-step constructor and train constructors. This constructor is equivalent to the default constructor, followed by the ``train()`` method with the parameters that are passed to the constructor.
CvStatModel::~CvStatModel
-------------------------
.. ocv:function:: CvStatModel::~CvStatModel()
The virtual destructor.
Serves as a virtual destructor.
.. ocv:function:: CvStatModel::~CvStatModel()
The destructor of the base class is declared as virtual. So, it is safe to write the following code: ::
@@ -77,43 +77,43 @@ Normally, the destructor of each derived class does nothing. But in this instanc
CvStatModel::clear
------------------
.. ocv:function:: void CvStatModel::clear()
Deallocates memory and resets the model state.
Deallocates memory and resets the model state.
.. ocv:function:: void CvStatModel::clear()
The method ``clear`` does the same job as the destructor: it deallocates all the memory occupied by the class members. But the object itself is not destructed and can be reused further. This method is called from the destructor, from the ``train`` methods of the derived classes, from the methods ``load()``, ``read()``, or even explicitly by the user.
CvStatModel::save
-----------------
.. ocv:function:: void CvStatModel::save( const char* filename, const char* name=0 )
Saves the model to a file.
Saves the model to a file.
.. ocv:function:: void CvStatModel::save( const char* filename, const char* name=0 )
The method ``save`` saves the complete model state to the specified XML or YAML file with the specified name or default name (which depends on a particular class). *Data persistence* functionality from ``CxCore`` is used.
CvStatModel::load
-----------------
.. ocv:function:: void CvStatModel::load( const char* filename, const char* name=0 )
Loads the model from a file.
Loads the model from a file.
.. ocv:function:: void CvStatModel::load( const char* filename, const char* name=0 )
The method ``load`` loads the complete model state with the specified name (or default model-dependent name) from the specified XML or YAML file. The previous model state is cleared by ``clear()`` .
CvStatModel::write
------------------
.. ocv:function:: void CvStatModel::write( CvFileStorage* storage, const char* name )
Writes the model to the file storage.
Writes the model to the file storage.
.. ocv:function:: void CvStatModel::write( CvFileStorage* storage, const char* name )
The method ``write`` stores the complete model state in the file storage with the specified name or default name (which depends on the particular class). The method is called by ``save()`` .
CvStatModel::read
-----------------
.. ocv:function:: void CvStatModel::read( CvFileStorage* storage, CvFileNode* node )
Reads the model from the file storage.
Reads the model from the file storage.
.. ocv:function:: void CvStatModel::read( CvFileStorage* storage, CvFileNode* node )
The method ``read`` restores the complete model state from the specified node of the file storage. Use the function
:ocv:func:`GetFileNodeByName` to locate the node.
@@ -122,9 +122,9 @@ The previous model state is cleared by ``clear()`` .
CvStatModel::train
------------------
.. ocv:function:: bool CvStatModel::train( const Mat& train_data, [int tflag,] ..., const Mat& responses, ..., [const Mat& var_idx,] ..., [const Mat& sample_idx,] ... [const Mat& var_type,] ..., [const Mat& missing_mask,] <misc_training_alg_params> ... )
Trains the model.
Trains the model.
.. ocv:function:: bool CvStatModel::train( const Mat& train_data, [int tflag,] ..., const Mat& responses, ..., [const Mat& var_idx,] ..., [const Mat& sample_idx,] ... [const Mat& var_type,] ..., [const Mat& missing_mask,] <misc_training_alg_params> ... )
The method trains the statistical model using a set of input feature vectors and the corresponding output values (responses). Both input and output vectors/values are passed as matrices. By default, the input feature vectors are stored as ``train_data`` rows, that is, all the components (features) of a training vector are stored continuously. However, some algorithms can handle the transposed representation when all values of each particular feature (component/input variable) over the whole input set are stored continuously. If both layouts are supported, the method includes the ``tflag`` parameter that specifies the orientation as follows:
@@ -150,9 +150,9 @@ Usually, the previous model state is cleared by ``clear()`` before running the t
CvStatModel::predict
--------------------
.. ocv:function:: float CvStatModel::predict( const Mat& sample[, <prediction_params>] ) const
Predicts the response for a sample.
Predicts the response for a sample.
.. ocv:function:: float CvStatModel::predict( const Mat& sample[, <prediction_params>] ) const
The method is used to predict the response for a new sample. In case of a classification, the method returns the class label. In case of a regression, the method returns the output function value. The input sample must have as many components as the ``train_data`` passed to ``train`` contains. If the ``var_idx`` parameter is passed to ``train`` , it is remembered and then is used to extract only the necessary components from the input sample in the method ``predict`` .
+11 -38
View File
@@ -21,10 +21,6 @@ There are a lot of good references on SVM. You may consider starting with the fo
http://www.csie.ntu.edu.tw/~cjlin/libsvm/
)
.. index:: CvSVM
.. _CvSVM:
CvSVM
-----
.. ocv:class:: CvSVM
@@ -84,10 +80,6 @@ Support Vector Machines. ::
};
.. index:: CvSVMParams
.. _CvSVMParams:
CvSVMParams
-----------
.. ocv:class:: CvSVMParams
@@ -119,15 +111,11 @@ SVM training parameters. ::
The structure must be initialized and passed to the training method of
:ocv:class:`CvSVM` .
.. index:: CvSVM::train
.. _CvSVM::train:
CvSVM::train
------------
.. ocv:function:: bool CvSVM::train( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx=Mat(), const Mat& _sample_idx=Mat(), CvSVMParams _params=CvSVMParams() )
Trains an SVM.
Trains an SVM.
.. ocv:function:: bool CvSVM::train( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx=Mat(), const Mat& _sample_idx=Mat(), CvSVMParams _params=CvSVMParams() )
The method trains the SVM model. It follows the conventions of the generic ``train`` approach with the following limitations:
@@ -142,15 +130,12 @@ The method trains the SVM model. It follows the conventions of the generic ``tra
All the other parameters are gathered in the
:ocv:class:`CvSVMParams` structure.
.. index:: CvSVM::train_auto
.. _CvSVM::train_auto:
CvSVM::train_auto
-----------------
.. ocv:function:: train_auto( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx, const Mat& _sample_idx, CvSVMParams params, int k_fold = 10, CvParamGrid C_grid = get_default_grid(CvSVM::C), CvParamGrid gamma_grid = get_default_grid(CvSVM::GAMMA), CvParamGrid p_grid = get_default_grid(CvSVM::P), CvParamGrid nu_grid = get_default_grid(CvSVM::NU), CvParamGrid coef_grid = get_default_grid(CvSVM::COEF), CvParamGrid degree_grid = get_default_grid(CvSVM::DEGREE) )
Trains an SVM with optimal parameters.
Trains an SVM with optimal parameters.
.. ocv:function:: train_auto( const Mat& _train_data, const Mat& _responses, const Mat& _var_idx, const Mat& _sample_idx, CvSVMParams params, int k_fold = 10, CvParamGrid C_grid = get_default_grid(CvSVM::C), CvParamGrid gamma_grid = get_default_grid(CvSVM::GAMMA), CvParamGrid p_grid = get_default_grid(CvSVM::P), CvParamGrid nu_grid = get_default_grid(CvSVM::NU), CvParamGrid coef_grid = get_default_grid(CvSVM::COEF), CvParamGrid degree_grid = get_default_grid(CvSVM::DEGREE) )
:param k_fold: Cross-validation parameter. The training set is divided into ``k_fold`` subsets. One subset is used to train the model, the others form the test set. So, the SVM algorithm is executed ``k_fold`` times.
@@ -186,15 +171,11 @@ This function works for the classification
as well as for the regression
( ``params.svm_type=CvSVM::EPS_SVR`` or ``params.svm_type=CvSVM::NU_SVR`` ). If ``params.svm_type=CvSVM::ONE_CLASS`` , no optimization is made and the usual SVM with parameters specified in ``params`` is executed.
.. index:: CvSVM::get_default_grid
.. _CvSVM::get_default_grid:
CvSVM::get_default_grid
-----------------------
.. ocv:function:: CvParamGrid CvSVM::get_default_grid( int param_id )
Generates a grid for SVM parameters.
Generates a grid for SVM parameters.
.. ocv:function:: CvParamGrid CvSVM::get_default_grid( int param_id )
:param param_id: SVN parameters IDs that must be one of the following:
@@ -214,29 +195,21 @@ CvSVM::get_default_grid
The function generates a grid for the specified parameter of the SVM algorithm. The grid may be passed to the function ``CvSVM::train_auto`` .
.. index:: CvSVM::get_params
.. _CvSVM::get_params:
CvSVM::get_params
-----------------
.. ocv:function:: CvSVMParams CvSVM::get_params() const
Returns the current SVM parameters.
Returns the current SVM parameters.
.. ocv:function:: CvSVMParams CvSVM::get_params() const
This function may be used to get the optimal parameters obtained while automatically training ``CvSVM::train_auto`` .
.. index:: CvSVM::get_support_vector*
.. _CvSVM::get_support_vector*:
CvSVM::get_support_vector*
CvSVM::get_support_vector
--------------------------
Retrieves a number of support vectors and the particular vector.
.. ocv:function:: int CvSVM::get_support_vector_count() const
.. ocv:function:: const float* CvSVM::get_support_vector(int i) const
Retrieves a number of support vectors and the particular vector.
The methods can be used to retrieve a set of support vectors.
@@ -3,8 +3,6 @@ Cascade Classification
.. highlight:: cpp
.. index:: FeatureEvaluator
FeatureEvaluator
----------------
.. ocv:class:: FeatureEvaluator
@@ -30,39 +28,36 @@ Base class for computing feature values in cascade classifiers. ::
};
.. index:: FeatureEvaluator::read
FeatureEvaluator::read
--------------------------
.. ocv:function:: bool FeatureEvaluator::read(const FileNode& node)
Reads parameters of features from the ``FileStorage`` node.
Reads parameters of features from the ``FileStorage`` node.
.. ocv:function:: bool FeatureEvaluator::read(const FileNode& node)
:param node: File node from which the feature parameters are read.
.. index:: FeatureEvaluator::clone
FeatureEvaluator::clone
---------------------------
Returns a full copy of the feature evaluator.
.. ocv:function:: Ptr<FeatureEvaluator> FeatureEvaluator::clone() const
Returns a full copy of the feature evaluator.
.. index:: FeatureEvaluator::getFeatureType
FeatureEvaluator::getFeatureType
------------------------------------
Returns the feature type (``HAAR`` or ``LBP`` for now).
.. ocv:function:: int FeatureEvaluator::getFeatureType() const
Returns the feature type (``HAAR`` or ``LBP`` for now).
.. index:: FeatureEvaluator::setImage
FeatureEvaluator::setImage
------------------------------
.. ocv:function:: bool FeatureEvaluator::setImage(const Mat& img, Size origWinSize)
Assigns an image to feature evaluator.
Assigns an image to feature evaluator.
.. ocv:function:: bool FeatureEvaluator::setImage(const Mat& img, Size origWinSize)
:param img: Matrix of the type ``CV_8UC1`` containing an image where the features are computed.
@@ -70,51 +65,47 @@ FeatureEvaluator::setImage
The method assigns an image, where the features will be computed, to the feature evaluator.
.. index:: FeatureEvaluator::setWindow
FeatureEvaluator::setWindow
-------------------------------
.. ocv:function:: bool FeatureEvaluator::setWindow(Point p)
Assigns a window in the current image where the features will be computed.
Assigns a window in the current image where the features will be computed.
.. ocv:function:: bool FeatureEvaluator::setWindow(Point p)
:param p: Upper left point of the window where the features are computed. Size of the window is equal to the size of training images.
.. index:: FeatureEvaluator::calcOrd
FeatureEvaluator::calcOrd
-----------------------------
.. ocv:function:: double FeatureEvaluator::calcOrd(int featureIdx) const
Computes the value of an ordered (numerical) feature.
Computes the value of an ordered (numerical) feature.
.. ocv:function:: double FeatureEvaluator::calcOrd(int featureIdx) const
:param featureIdx: Index of the feature whose value is computed.
The function returns the computed value of an ordered feature.
.. index:: FeatureEvaluator::calcCat
FeatureEvaluator::calcCat
-----------------------------
.. ocv:function:: int FeatureEvaluator::calcCat(int featureIdx) const
Computes the value of a categorical feature.
Computes the value of a categorical feature.
.. ocv:function:: int FeatureEvaluator::calcCat(int featureIdx) const
:param featureIdx: Index of the feature whose value is computed.
The function returns the computed label of a categorical feature, which is the value from [0,... (number of categories - 1)].
.. index:: FeatureEvaluator::create
FeatureEvaluator::create
----------------------------
.. ocv:function:: static Ptr<FeatureEvaluator> FeatureEvaluator::create(int type)
Constructs the feature evaluator.
Constructs the feature evaluator.
.. ocv:function:: static Ptr<FeatureEvaluator> FeatureEvaluator::create(int type)
:param type: Type of features evaluated by cascade (``HAAR`` or ``LBP`` for now).
.. index:: CascadeClassifier
CascadeClassifier
-----------------
@@ -189,49 +180,49 @@ Cascade classifier class for object detection. ::
};
.. index:: CascadeClassifier::CascadeClassifier
CascadeClassifier::CascadeClassifier
----------------------------------------
.. ocv:function:: CascadeClassifier::CascadeClassifier(const string& filename)
Loads a classifier from a file.
Loads a classifier from a file.
.. ocv:function:: CascadeClassifier::CascadeClassifier(const string& filename)
:param filename: Name of the file from which the classifier is loaded.
.. index:: CascadeClassifier::empty
CascadeClassifier::empty
----------------------------
Checks whether the classifier has been loaded.
.. ocv:function:: bool CascadeClassifier::empty() const
Checks whether the classifier has been loaded.
.. index:: CascadeClassifier::load
CascadeClassifier::load
---------------------------
.. ocv:function:: bool CascadeClassifier::load(const string& filename)
Loads a classifier from a file.
Loads a classifier from a file. The previous content is destroyed.
.. ocv:function:: bool CascadeClassifier::load(const string& filename)
:param filename: Name of the file from which the classifier is loaded. The file may contain an old HAAR classifier trained by the haartraining application or a new cascade classifier trained by the traincascade application.
.. index:: CascadeClassifier::read
CascadeClassifier::read
---------------------------
Reads a classifier from a FileStorage node.
.. ocv:function:: bool CascadeClassifier::read(const FileNode& node)
Reads a classifier from a FileStorage node. The file may contain a new cascade classifier (trained traincascade application) only.
.. note:: The file may contain a new cascade classifier (trained traincascade application) only.
.. index:: CascadeClassifier::detectMultiScale
CascadeClassifier::detectMultiScale
---------------------------------------
.. ocv:function:: void CascadeClassifier::detectMultiScale( const Mat& image, vector<Rect>& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size())
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
.. ocv:function:: void CascadeClassifier::detectMultiScale( const Mat& image, vector<Rect>& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size())
:param image: Matrix of the type ``CV_8U`` containing an image where objects are detected.
@@ -245,25 +236,25 @@ CascadeClassifier::detectMultiScale
:param minSize: Minimum possible object size. Objects smaller than that are ignored.
.. index:: CascadeClassifier::setImage
CascadeClassifier::setImage
-------------------------------
.. ocv:function:: bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>& feval, const Mat& image )
Sets an image for detection that is called by ``detectMultiScale`` at each image level.
Sets an image for detection that is called by ``detectMultiScale`` at each image level.
.. ocv:function:: bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>& feval, const Mat& image )
:param feval: Pointer to the feature evaluator used for computing features.
:param image: Matrix of the type ``CV_8UC1`` containing an image where the features are computed.
.. index:: CascadeClassifier::runAt
CascadeClassifier::runAt
----------------------------
.. ocv:function:: int CascadeClassifier::runAt( Ptr<FeatureEvaluator>& feval, Point pt )
Runs the detector at the specified point. Use ``setImage`` to set the image for the detector to work with.
Runs the detector at the specified point. Use ``setImage`` to set the image for the detector to work with.
.. ocv:function:: int CascadeClassifier::runAt( Ptr<FeatureEvaluator>& feval, Point pt )
:param feval: Feature evaluator used for computing features.
@@ -272,13 +263,13 @@ CascadeClassifier::runAt
The function returns 1 if the cascade classifier detects an object in the given location.
Otherwise, it returns negated index of the stage at which the candidate has been rejected.
.. index:: groupRectangles
groupRectangles
-------------------
.. ocv:function:: void groupRectangles(vector<Rect>& rectList, int groupThreshold, double eps=0.2)
Groups the object candidate rectangles.
Groups the object candidate rectangles.
.. ocv:function:: void groupRectangles(vector<Rect>& rectList, int groupThreshold, double eps=0.2)
:param rectList: Input/output vector of rectangles. Output vector includes retained and grouped rectangles.
@@ -3,13 +3,13 @@ Motion Analysis and Object Tracking
.. highlight:: cpp
.. index:: calcOpticalFlowPyrLK
calcOpticalFlowPyrLK
------------------------
.. ocv:function:: void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err, Size winSize=Size(15,15), int maxLevel=3, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), double derivLambda=0.5, int flags=0 )
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
.. ocv:function:: void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err, Size winSize=Size(15,15), int maxLevel=3, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), double derivLambda=0.5, int flags=0 )
:param prevImg: First 8-bit single-channel or 3-channel input image.
@@ -39,13 +39,13 @@ The function implements a sparse iterative version of the Lucas-Kanade optical f
Bouguet00
.
.. index:: calcOpticalFlowFarneback
calcOpticalFlowFarneback
----------------------------
.. ocv:function:: void calcOpticalFlowFarneback( InputArray prevImg, InputArray nextImg, InputOutputArray flow, double pyrScale, int levels, int winsize, int iterations, int polyN, double polySigma, int flags )
Computes a dense optical flow using the Gunnar Farneback's algorithm.
Computes a dense optical flow using the Gunnar Farneback's algorithm.
.. ocv:function:: void calcOpticalFlowFarneback( InputArray prevImg, InputArray nextImg, InputOutputArray flow, double pyrScale, int levels, int winsize, int iterations, int polyN, double polySigma, int flags )
:param prevImg: First 8-bit single-channel input image.
@@ -78,13 +78,13 @@ The function finds an optical flow for each ``prevImg`` pixel using the alorithm
\texttt{prevImg} (x,y) \sim \texttt{nextImg} ( \texttt{flow} (x,y)[0], \texttt{flow} (x,y)[1])
.. index:: estimateRigidTransform
estimateRigidTransform
--------------------------
.. ocv:function:: Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine )
Computes an optimal affine transformation between two 2D point sets.
Computes an optimal affine transformation between two 2D point sets.
.. ocv:function:: Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine )
:param src: First input 2D point set stored in ``std::vector`` or ``Mat``, or an image stored in ``Mat``.
@@ -121,13 +121,13 @@ In case of point sets, the problem is formulated as follows: you need to find a
:ocv:func:`findHomography`
.. index:: updateMotionHistory
updateMotionHistory
-----------------------
.. ocv:function:: void updateMotionHistory( InputArray silhouette, InputOutputArray mhi, double timestamp, double duration )
Updates the motion history image by a moving silhouette.
Updates the motion history image by a moving silhouette.
.. ocv:function:: void updateMotionHistory( InputArray silhouette, InputOutputArray mhi, double timestamp, double duration )
:param silhouette: Silhouette mask that has non-zero pixels where the motion occurs.
@@ -154,13 +154,13 @@ Bradski00
.
See also the OpenCV sample ``motempl.c`` that demonstrates the use of all the motion template functions.
.. index:: calcMotionGradient
calcMotionGradient
----------------------
.. ocv:function:: void calcMotionGradient( InputArray mhi, OutputArray mask, OutputArray orientation, double delta1, double delta2, int apertureSize=3 )
Calculates a gradient orientation of a motion history image.
Calculates a gradient orientation of a motion history image.
.. ocv:function:: void calcMotionGradient( InputArray mhi, OutputArray mask, OutputArray orientation, double delta1, double delta2, int apertureSize=3 )
:param mhi: Motion history single-channel floating-point image.
@@ -187,13 +187,13 @@ In fact,
:ocv:func:`fastArctan` and
:ocv:func:`phase` are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the ``mask`` is filled to indicate pixels where the computed angle is valid.
.. index:: calcGlobalOrientation
calcGlobalOrientation
-------------------------
.. ocv:function:: double calcGlobalOrientation( InputArray orientation, InputArray mask, InputArray mhi, double timestamp, double duration )
Calculates a global motion orientation in a selected region.
Calculates a global motion orientation in a selected region.
.. ocv:function:: double calcGlobalOrientation( InputArray orientation, InputArray mask, InputArray mhi, double timestamp, double duration )
:param orientation: Motion gradient orientation image calculated by the function :ocv:func:`calcMotionGradient` .
@@ -212,15 +212,14 @@ the weighted orientation histogram, where a recent motion has a larger
weight and the motion occurred in the past has a smaller weight, as recorded in ``mhi`` .
.. index:: segmentMotion
segmentMotion
-------------
Splits a motion history image into a few parts corresponding to separate independent motions (for example, left hand, right hand).
.. ocv:function:: void segmentMotion(InputArray mhi, OutputArray segmask, vector<Rect>& boundingRects, double timestamp, double segThresh)
Splits a motion history image into a few parts corresponding to separate independent motions (for example, left hand, right hand).
:param mhi: Motion history image.
:param segmask: Image where the found mask should be stored, single-channel, 32-bit floating-point.
@@ -235,13 +234,13 @@ segmentMotion
The function finds all of the motion segments and marks them in ``segmask`` with individual values (1,2,...). It also computes a vector with ROIs of motion connected components. After that the motion direction for every component can be calculated with :ocv:func:`calcGlobalOrientation` using the extracted mask of the particular component.
.. index:: CamShift
CamShift
------------
.. ocv:function:: RotatedRect CamShift( InputArray probImage, Rect& window, TermCriteria criteria )
Finds an object center, size, and orientation.
Finds an object center, size, and orientation.
.. ocv:function:: RotatedRect CamShift( InputArray probImage, Rect& window, TermCriteria criteria )
:param probImage: Back projection of the object histogram. See :ocv:func:`calcBackProject` .
@@ -257,13 +256,13 @@ First, it finds an object center using
See the OpenCV sample ``camshiftdemo.c`` that tracks colored objects.
.. index:: meanShift
meanShift
-------------
.. ocv:function:: int meanShift( InputArray probImage, Rect& window, TermCriteria criteria )
Finds an object on a back projection image.
Finds an object on a back projection image.
.. ocv:function:: int meanShift( InputArray probImage, Rect& window, TermCriteria criteria )
:param probImage: Back projection of the object histogram. See :ocv:func:`calcBackProject` for details.
@@ -279,13 +278,11 @@ The function implements the iterative object search algorithm. It takes the inpu
:ocv:func:`contourArea` ), and rendering the remaining contours with
:ocv:func:`drawContours` .
.. index:: KalmanFilter
.. _KalmanFilter:
KalmanFilter
------------
.. c:type:: KalmanFilter
.. ocv:class:: KalmanFilter
Kalman filter class.
@@ -294,15 +291,14 @@ http://en.wikipedia.org/wiki/Kalman_filter
. However, you can modify ``transitionMatrix``, ``controlMatrix``, and ``measurementMatrix`` to get an extended Kalman filter functionality. See the OpenCV sample ``kalman.cpp`` .
.. index:: KalmanFilter::KalmanFilter
KalmanFilter::KalmanFilter
--------------------------
The constructors.
.. ocv:function:: KalmanFilter::KalmanFilter()
Creates an empty object that can be initialized later by the function :ocv:func:`KalmanFilter::init`.
.. ocv:function:: KalmanFilter::KalmanFilter(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F)
The full constructor.
@@ -314,17 +310,14 @@ KalmanFilter::KalmanFilter
:param controlParams: Dimensionality of the control vector.
:param type: Type of the created matrices that should be ``CV_32F`` or ``CV_64F``.
.. index:: KalmanFilter::init
KalmanFilter::init
------------------
Re-initializes Kalman filter. The previous content is destroyed.
.. ocv:function:: void KalmanFilter::init(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F)
Re-initializes Kalman filter. The previous content is destroyed.
:param dynamParams: Dimensionality of the state.
:param measureParams: Dimensionality of the measurement.
@@ -334,28 +327,25 @@ KalmanFilter::init
:param type: Type of the created matrices that should be ``CV_32F`` or ``CV_64F``.
.. index:: KalmanFilter::predict
KalmanFilter::predict
---------------------
Computes a predicted state.
.. ocv:function:: const Mat& KalmanFilter::predict(const Mat& control=Mat())
Computes a predicted state.
:param control: The optional input control
.. index:: KalmanFilter::correct
KalmanFilter::correct
---------------------
Updates the predicted state from the measurement.
.. ocv:function:: const Mat& KalmanFilter::correct(const Mat& measurement)
Updates the predicted state from the measurement.
:param control: The measured system parameters
.. index:: BackgroundSubtractor
BackgroundSubtractor
--------------------
@@ -375,31 +365,30 @@ Base class for background/foreground segmentation. ::
The class is only used to define the common interface for the whole family of background/foreground segmentation algorithms.
.. index:: BackgroundSubtractor::operator()
BackgroundSubtractor::operator()
-------------------------------
Computes a foreground mask.
.. ocv:function:: virtual void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
Computes a foreground mask.
:param image: Next video frame.
:param fgmask: Foreground mask as an 8-bit binary image.
.. index:: BackgroundSubtractor::getBackgroundImage
BackgroundSubtractor::getBackgroundImage
----------------------------------------
Computes a background image.
.. ocv:function:: virtual void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
Computes a background image.
.. index:: BackgroundSubtractorMOG
:param backgroundImage: The output background image.
.. note:: Sometimes the background image can be very blurry, as it contain the average background statistics.
BackgroundSubtractorMOG
-----------------------
@@ -411,17 +400,16 @@ Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
The class implements the algorithm described in P. KadewTraKuPong and R. Bowden, *An improved adaptive background mixture model for real-time tracking with shadow detection*, Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001: http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
.. index:: BackgroundSubtractorMOG::BackgroundSubtractorMOG
BackgroundSubtractorMOG::BackgroundSubtractorMOG
------------------------------------------------
The contructors
.. ocv:function:: BackgroundSubtractorMOG::BackgroundSubtractorMOG()
.. ocv:function:: BackgroundSubtractorMOG::BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma=0)
Description??
:param history: Length of the history.
:param nmixtures: Number of Gaussian mixtures.
@@ -433,53 +421,77 @@ BackgroundSubtractorMOG::BackgroundSubtractorMOG
Default constructor sets all parameters to default values.
.. index:: BackgroundSubtractorMOG::operator()
BackgroundSubtractorMOG::operator()
-----------------------------------
Updates the background model and returns the foreground mask
.. ocv:function:: virtual void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
Updates an operator.??
Parameters are the same as in ``BackgroundSubtractor::operator()``
.. index:: BackgroundSubtractorMOG::initialize
BackgroundSubtractorMOG::initialize
-----------------------------------
.. ocv:function:: virtual void BackgroundSubtractorMOG::initialize(Size frameSize, int frameType)
Re-initiaizes the data.??
.. index:: BackgroundSubtractorMOG2
BackgroundSubtractorMOG2
------------------------
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
.. ocv:class: BackgroundSubtractorMOG2 : public BackgroundSubtractor
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
Here are important members of the class that control the algorithm, which you can set after constructing the class instance:
The class implements the Gaussian mixture model background subtraction described in:
:ocv:member:: nmixtures
Maximum allowed number of mixture comonents. Actual number is determined dynamically per pixel.
:ocv:member:: backgroundRatio
Threshold defining whether the component is significant enough to be included into the background model ( corresponds to ``TB=1-cf`` from the paper??which paper??). ``cf=0.1 => TB=0.9`` is default. For ``alpha=0.001``, it means that the mode should exist for approximately 105 frames before it is considered foreground.
:ocv:member:: varThresholdGen
Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to ``Tg``). If it is not close to any component, a new component is generated. ``3 sigma => Tg=3*3=9`` is default. A smaller ``Tg`` value generates more components. A higher ``Tg`` value may result in a small number of components but they can grow too large.
:ocv:member:: fVarInit
Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.
:ocv:member::
fVarMin Parameter used to further control the variance.
:ocv:member::
fVarMax Parameter used to further control the variance.
:ocv:member:: fCT
Complexity reduction parameter. This parameter defines the number of samples needed to accept to prove the component exists. ``CT=0.05`` is a default value for all the samples. By setting ``CT=0`` you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
:param nShadowDetection
The value for marking shadow pixels in the output foreground mask. Default value is 127.
:param fTau
Shadow threshold. The shadow is detected if the pixel is a darker version of the background. ``Tau`` is a threshold defining how much darker the shadow can be. ``Tau= 0.5`` means that if a pixel is more than twice darker then it is not shadow. See Prati,Mikic,Trivedi,Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.
The class implements the Gaussian mixture model background subtraction described in:
* Z.Zivkovic, *Improved adaptive Gausian mixture model for background subtraction*, International Conference Pattern Recognition, UK, August, 2004, http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf. The code is very fast and performs also shadow detection. Number of Gausssian components is adapted per pixel.
* Z.Zivkovic, F. van der Heijden, *Efficient Adaptive Density Estimapion per Image Pixel for the Task of Background Subtraction*, Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006. The algorithm similar to the standard Stauffer&Grimson algorithm with additional selection of the number of the Gaussian components based on: Z.Zivkovic, F.van der Heijden, Recursive unsupervised learning of finite mixture models, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004.
.. index:: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2
BackgroundSubtractorMOG2::BackgroundSubtractorMOG2
--------------------------------------------------
The constructors.
.. ocv:function:: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2()
.. ocv:function:: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2(int history, float varThreshold, bool bShadowDetection=1)
Description??
:param history: Length of the history.
:param varThreshold: Threshold on the squared Mahalanobis distance to decide whether it is well described by the background model (see Cthr??). This parameter does not affect the background update. A typical value could be 4 sigma, that is, ``varThreshold=4*4=16;`` (see Tb??).
@@ -487,56 +499,21 @@ BackgroundSubtractorMOG2::BackgroundSubtractorMOG2
:param bShadowDetection: Parameter defining whether shadow detection should be enabled (``true`` or ``false``).
The class??why class?? has an important public parameter:
:param nmixtures: Maximum allowed number of mixture comonents. Actual number is determined dynamically per pixel.
There are other less important parameters of the class that you may cautiously change:??check the param desc below. I rephrased many of them??
:param backgroundRatio: Threshold defining whether the component is significant enough to be included into the background model ( corresponds to ``TB=1-cf`` from the paper??which paper??). ``cf=0.1 => TB=0.9`` is default. For ``alpha=0.001``, it means that the mode should exist for approximately 105 frames before it is considered foreground.
:param varThresholdGen: Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to ``Tg``). If it is not close to any component, a new component is generated. ``3 sigma => Tg=3*3=9`` is default. A smaller ``Tg`` value generates more components. A higher ``Tg`` value may result in a small number of components but they can grow too large.
:param fVarInit: Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.
:param fVarMin: Parameter used to further control the variance.
:param fVarMax: Parameter used to further control the variance.
:param fCT: Complexity reduction prior??. This parameter defines the number of samples needed to accept to prove the component exists. ``CT=0.05`` is a default value for all the samples. By setting ``CT=0`` you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
:param nShadowDetection: Shadow detection result. Default value is 127.
:param fTau: Shadow threshold. The shadow is detected if the pixel is a darker version of the background. ``Tau`` is a threshold defining how much darker the shadow can be. ``Tau= 0.5`` means that if a pixel is more than twice darker then it is not shadow. See Prati,Mikic,Trivedi,Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.
.. index:: BackgroundSubtractorMOG2::operator()
BackgroundSubtractorMOG2::operator()
-----------------------------------
Updates the background model and computes the foreground mask
.. ocv:function:: virtual void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
Updates an operator.??
See ``BackgroundSubtractor::operator ()``.
.. index:: BackgroundSubtractorMOG2::initialize
BackgroundSubtractorMOG2::initialize
------------------------------------
.. ocv:function:: virtual void BackgroundSubtractorMOG2::initialize(Size frameSize, int frameType)
Re-initializes the data.??
.. index:: BackgroundSubtractorMOG2::getBackgroundImage
BackgroundSubtractorMOG2::getBackgroundImage
--------------------------------------------
Returns background image
.. ocv:function:: virtual void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage) const
Computes a background image, which is the mean of all background Gaussians.
See :ocv:func:`BackgroundSubtractor::getBackgroundImage`.