@ -53,6 +53,10 @@
# include "opencv2/core/traits.hpp"
# include "opencv2/core/saturate.hpp"
# ifdef CV_CXX11
# include <initializer_list>
# endif
namespace cv
{
@ -77,12 +81,21 @@ If you need a more flexible type, use Mat . The elements of the matrix M are acc
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
Mat and backwards :
@ code
@ code { . cpp }
Matx33f m ( 1 , 2 , 3 ,
4 , 5 , 6 ,
7 , 8 , 9 ) ;
cout < < sum ( Mat ( m * m . t ( ) ) ) < < endl ;
@ endcode
@ endcode
Except of the plain constructor which takes a list of elements , Matx can be initialized from a C - array :
@ code { . cpp }
float values [ ] = { 1 , 2 , 3 } ;
Matx31f m ( values ) ;
@ endcode
In case if C + + 11 features are avaliable , std : : initializer_list can be also used to initizlize Matx :
@ code { . cpp }
Matx31f m = { 1 , 2 , 3 } ;
@ endcode
*/
template < typename _Tp , int m , int n > class Matx
{
@ -125,6 +138,10 @@ public:
_Tp v12 , _Tp v13 , _Tp v14 , _Tp v15 ) ; //!< 1x16, 4x4 or 16x1 matrix
explicit Matx ( const _Tp * vals ) ; //!< initialize from a plain array
# ifdef CV_CXX11
Matx ( std : : initializer_list < _Tp > ) ; //!< initialize from an initializer list
# endif
static Matx all ( _Tp alpha ) ;
static Matx zeros ( ) ;
static Matx ones ( ) ;
@ -327,6 +344,10 @@ public:
Vec ( _Tp v0 , _Tp v1 , _Tp v2 , _Tp v3 , _Tp v4 , _Tp v5 , _Tp v6 , _Tp v7 , _Tp v8 , _Tp v9 , _Tp v10 , _Tp v11 , _Tp v12 , _Tp v13 ) ; //!< 14-element vector constructor
explicit Vec ( const _Tp * values ) ;
# ifdef CV_CXX11
Vec ( std : : initializer_list < _Tp > ) ;
# endif
Vec ( const Vec < _Tp , cn > & v ) ;
static Vec all ( _Tp alpha ) ;
@ -616,6 +637,19 @@ Matx<_Tp, m, n>::Matx(const _Tp* values)
for ( int i = 0 ; i < channels ; i + + ) val [ i ] = values [ i ] ;
}
# ifdef CV_CXX11
template < typename _Tp , int m , int n > inline
Matx < _Tp , m , n > : : Matx ( std : : initializer_list < _Tp > list )
{
CV_DbgAssert ( list . size ( ) = = channels ) ;
int i = 0 ;
for ( const auto & elem : list )
{
val [ i + + ] = elem ;
}
}
# endif
template < typename _Tp , int m , int n > inline
Matx < _Tp , m , n > Matx < _Tp , m , n > : : all ( _Tp alpha )
{
@ -957,6 +991,12 @@ template<typename _Tp, int cn> inline
Vec < _Tp , cn > : : Vec ( const _Tp * values )
: Matx < _Tp , cn , 1 > ( values ) { }
# ifdef CV_CXX11
template < typename _Tp , int cn > inline
Vec < _Tp , cn > : : Vec ( std : : initializer_list < _Tp > list )
: Matx < _Tp , cn , 1 > ( list ) { }
# endif
template < typename _Tp , int cn > inline
Vec < _Tp , cn > : : Vec ( const Vec < _Tp , cn > & m )
: Matx < _Tp , cn , 1 > ( m . val ) { }
@ -1081,7 +1121,7 @@ Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v)
//////////////////////////////// matx comma initializer //////////////////////////////////
//////////////////////////////// vec comma initializer //////////////////////////////////
template < typename _Tp , typename _T2 , int cn > static inline