:param image:Destination image. It must be an 8-bit color image.
:param patternSize:Number of inner corners per a chessboard row and column. ``(patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(rows,columns) )``
:param patternSize:Number of inner corners per a chessboard row and column ``(patternSize = cv::Size(points_per_row,points_per_column))``
:param corners:Array of detected corners. This should be an output from ``findChessboardCorners`` wrapped in ``cv::Mat()`` .
:param corners:Array of detected corners, the output of ``findChessboardCorners``.
:param patternWasFound:Parameter indicating whether the complete board was found or not. The return value :ref:`FindChessboardCorners` may be passed here.
:param patternWasFound:Parameter indicating whether the complete board was found or not. The return value of :cpp:func:`findChessboardCorners` should be passed here.
The function draws individual chessboard corners detected either as red circles if the board was not found, or as colored corners connected with lines if the board was found.
Template "trait" class for other OpenCV primitive data types ::
template<typename _Tp> class DataType
{
// value_type is always a synonym to _Tp.
typedef _Tp value_type;
// intermediate type used for operations on _Tp.
// it is int for uchar, signed char, unsigned short, signed short, and int,
// float for float, double for double, ...
typedef <...> work_type;
// in the case of multi-channel data, it is the data type of each channel
typedef <...> channel_type;
enum
{
// CV_8U ... CV_64F
depth = DataDepth<channel_type>::value,
// 1 ...
channels = <...>,
// '1u', '4i', '3f', '2d' etc.
fmt=<...>,
// CV_8UC3, CV_32FC2 ...
type = CV_MAKETYPE(depth, channels)
};
};
The template class ``DataType`` is a descriptive class for OpenCV primitive data types and other types that comply with the following definition. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C(<number_of_channels>)``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
- Template "trait" class for other OpenCV primitive data types. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C(<number_of_channels>)``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
:ref:`Vec`. Multiple instances of such a type can be stored in a ``std::vector``, ``Mat``, ``Mat_``, ``SparseMat``, ``SparseMat_``, or any other container that is able to store ``Vec`` instances.
The ``DataType`` class is basically used to provide a description of such primitive data types without adding any fields or methods to the corresponding classes (and it is actually impossible to add anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not ``DataType`` itself that is used but its specialized versions, such as: ::
@ -75,44 +45,12 @@ The main purpose of this class is to convert compilation-time type information t
So, such traits are used to tell OpenCV which data type you are working with, even if such a type is not native to OpenCV. For example, the matrix ``B`` intialization above is compiled because OpenCV defines the proper specialized template class ``DataType<complex<_Tp> >`` . This mechanism is also useful (and used in OpenCV this way) for generic algorithms implementations.
// computes dot-product using double-precision arithmetics
double ddot(const Point_& pt) const;
// returns true if the point is inside the rectangle "r".
bool inside(const Rect_<_Tp>& r) const;
_Tp x, y;
};
The class represents a 2D point specified by its coordinates
Template class for 2D points, specified by its coordinates
:math:`x` and
:math:`y` .
An instance of the class is interchangeable with C structures, ``CvPoint`` and ``CvPoint2D32f`` . There is also a cast operator to convert point coordinates to the specified type. The conversion from floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion uses this
The class represents a 3D point specified by its coordinates
Template class for 3D points, specified by its coordinates
:math:`x`,
:math:`y` and
:math:`z` .
@ -186,40 +97,12 @@ The following ``Point3_<>`` aliases are available: ::
typedef Point3_<float> Point3f;
typedef Point3_<double> Point3d;
..index:: Size\_
Size\_
------
..cpp:class:: Size_
Template class for specfying an image or rectangle size ::
template<typename _Tp> class Size_
{
public:
typedef _Tp value_type;
Size_();
Size_(_Tp _width, _Tp _height);
Size_(const Size_& sz);
Size_(const CvSize& sz);
Size_(const CvSize2D32f& sz);
Size_(const Point_<_Tp>& pt);
Size_& operator = (const Size_& sz);
_Tp area() const;
operator Size_<int>() const;
operator Size_<float>() const;
operator Size_<double>() const;
operator CvSize() const;
operator CvSize2D32f() const;
_Tp width, height;
};
The class ``Size_`` is similar to ``Point_`` except that the two members are called ``width`` and ``height`` instead of ``x`` and ``y`` . The structure can be converted to and from the old OpenCV structures
Template class for specfying size of an image or rectangle. The class includes two members are called ``width`` and ``height``. The structure can be converted to and from the old OpenCV structures
``CvSize`` and ``CvSize2D32f`` . The same set of arithmetic and comparison operations as for ``Point_`` is available.
OpenCV defines the following ``Size_<>`` aliases: ::
@ -228,56 +111,15 @@ OpenCV defines the following ``Size_<>`` aliases: ::
The rectangle is described with the following parameters:
Template class for 2D rectangles, described by the following parameters::
* Coordinates of the top-left corner. This is a default interpretation of ``Rect_::x`` and ``Rect_::y`` in OpenCV. Though, in your algorithms you may count ``x`` and ``y`` from the bottom-left corner.
* Rectangle width and height.
* Coordinates of the top-left corner. This is a default interpretation of ``Rect_::x`` and ``Rect_::y`` in OpenCV. Though, in your algorithms you may count ``x`` and ``y`` from the bottom-left corner.
* Rectangle width and height.
OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. For example, the method ``Rect_::contains`` returns ``true`` if
@ -328,100 +170,30 @@ For your convenience, the ``Rect_<>`` alias is available: ::
Template class for small matrices, whose type and size are known at compilation time.: ::
template<typename _Tp, int m, int n> class Matx {...};
typedef Matx<float, 1, 2> Matx12f;
typedef Matx<double, 1, 2> Matx12d;
...
@ -439,10 +211,8 @@ Template class for small matrices ::
...
typedef Matx<float, 6, 6> Matx66f;
typedef Matx<double, 6, 6> Matx66d;
The class represents small matrices whose type and size are known at compilation time. If you need a more flexible type, use
:cpp:class:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
If you need a more flexible type, use :cpp:class:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
:ref:`MatrixExpressions` ) are available. To do an operation on ``Matx`` that is not implemented, you can easily convert the matrix to
:cpp:class:`Mat` and backwards. ::
@ -451,27 +221,16 @@ The class represents small matrices whose type and size are known at compilation
7, 8, 9);
cout << sum(Mat(m*m.t())) << endl;
..index:: Vec
.._Vec:
Vec
---
..cpp:class:: Vec
Template class for short numerical vectors ::
template<typename T, int cn> class Vec : public Matx<T, cn, 1>
Template class for short numerical vectors, a partial case of :cpp:class:`Matx`: ::
template<typename _Tp, int n> class Vec : public Matx<_Tp, n, 1> {...};
typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;
@ -493,79 +252,51 @@ Template class for short numerical vectors ::
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;
It is possible to convert ``Vec<T,2>`` to/from ``Point_``, ``Vec<T,3>`` to/from ``Point3_`` , and ``Vec<T,4>`` to ``CvScalar`` or :ref:`Scalar`. The elements of ``Vec`` are accessed using ``operator[]``.
``Vec`` is a partial case of ``Matx`` . It is possible to convert ``Vec<T,2>`` to/from ``Point_``, ``Vec<T,3>`` to/from ``Point3_`` , and ``Vec<T,4>`` to ``CvScalar`` or :ref:`Scalar`. The elements of ``Vec`` are accessed using ``operator[]``. All the expected vector operations are implemented too:
*
:math:`\texttt{v1} = \texttt{v2} \pm \texttt{v3}`, :math:`\texttt{v1} = \texttt{v2} * \alpha`, :math:`\texttt{v1} = \alpha * \texttt{v2}` in addition to the corresponding augmenting operations. Note that these operations apply
template<typename T2> void convertTo(T2* buf, int channels, int unroll_to=0) const;
};
Template class for a 4-element vector, derived from Vec ::
template<typename _Tp> class Scalar_ : public Vec<_Tp, 4> { ... };
typedef Scalar_<double> Scalar;
The template class ``Scalar_`` and its double-precision instantiation ``Scalar`` represent a 4-element vector. Being derived from ``Vec<_Tp, 4>`` , they can be used as typical 4-element vectors. In addition, they can be converted to/from ``CvScalar`` . The type ``Scalar`` is widely used in OpenCV for passing pixel values. It is a drop-in replacement for
``CvScalar`` that was used for the same purpose in the earlier versions of OpenCV.
..index:: Range
.._Range:
Being derived from ``Vec<_Tp, 4>`` , ``Scalar_`` and ``Scalar`` can be used just as typical 4-element vectors. In addition, they can be converted to/from ``CvScalar`` . The type ``Scalar`` is widely used in OpenCV for passing pixel values.
Range
-----
..cpp:class:: Range
Template class specifying a continuous subsequence (slice) of a sequence ::
Template class specifying a continuous subsequence (slice) of a sequence. ::
class Range
{
public:
Range();
Range(int _start, int _end);
Range(const CvSlice& slice);
int size() const;
bool empty() const;
static Range all();
operator CvSlice() const;
...
int start, end;
};
The class is used to specify a row or a column span in a matrix (
:ref:`Mat` ) and for many other purposes. ``Range(a,b)`` is basically the same as ``a:b`` in Matlab or ``a..b`` in Python. As in Python, ``start`` is an inclusive left boundary of the range and ``end`` is an exclusive right boundary of the range. Such a half-opened interval is usually denoted as
:cpp:class:`Mat` ) and for many other purposes. ``Range(a,b)`` is basically the same as ``a:b`` in Matlab or ``a..b`` in Python. As in Python, ``start`` is an inclusive left boundary of the range and ``end`` is an exclusive right boundary of the range. Such a half-opened interval is usually denoted as
:math:`[start,end)` .
The static method ``Range::all()`` returns a special variable that means "the whole sequence" or "the whole range", just like " ``:`` " in Matlab or " ``...`` " in Python. All the methods and functions in OpenCV that take ``Range`` support this special ``Range::all()`` value. But, of course, in case of your own custom processing, you will probably have to check and handle it explicitly: ::
@ -581,10 +312,6 @@ The static method ``Range::all()`` returns a special variable that means "the wh
}
..index:: Ptr
.._Ptr:
Ptr
---
@ -1870,10 +1597,6 @@ Mat::type
The method returns a matrix element type. This is an id, compatible with the ``CvMat`` type system, like ``CV_16SC3`` or 16-bit signed 3-channel array, and so on.
..index:: Mat::depth
.._Mat::depth:
Mat::depth
--------------
..cpp:function:: int Mat::depth() const
@ -1896,10 +1619,6 @@ The method returns the matrix element depth id (the type of each individual chan
:cpp:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
..index:: Mat::size
Mat::size
-------------
..cpp:function:: Size Mat::size() const
@ -1931,10 +1644,6 @@ Mat::size
The method returns a matrix size: ``Size(cols, rows)`` .
..index:: Mat::empty
.._Mat::empty:
Mat::empty
--------------
..cpp:function:: bool Mat::empty() const
@ -1943,10 +1652,6 @@ Mat::empty
The method returns ``true`` if ``Mat::total()`` is 0 or if ``Mat::data`` is NULL. Because of ``pop_back()`` and ``resize()`` methods ``M.total() == 0`` does not imply that ``M.data == NULL`` .
..index:: Mat::ptr
.._Mat::ptr:
Mat::ptr
------------
..cpp:function:: uchar* Mat::ptr(int i=0)
@ -1964,10 +1669,6 @@ Mat::ptr
The methods return ``uchar*`` or typed pointer to the specified matrix row. See the sample in
:cpp:func:`Mat::isContinuous` () to know how to use these methods.