diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 4043212d381460e3abaf8cb28b05cebb3144f878..4a9a0f158122488ef0272f86b87eec0696e174d8 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -384,7 +384,7 @@ public: The class is specialized for each fundamental numerical data type supported by OpenCV. It provides DataDepth::value constant. */ -template class CV_EXPORTS DataDepth { public: enum { value = -1, fmt=(int)'\0' }; }; +template class CV_EXPORTS DataDepth {}; template<> class DataDepth { public: enum { value = CV_8U, fmt=(int)'u' }; }; template<> class DataDepth { public: enum { value = CV_8U, fmt=(int)'u' }; }; @@ -393,6 +393,8 @@ template<> class DataDepth { public: enum { value = CV_8S, fmt=(int)'c' }; template<> class DataDepth { public: enum { value = CV_16U, fmt=(int)'w' }; }; template<> class DataDepth { public: enum { value = CV_16S, fmt=(int)'s' }; }; template<> class DataDepth { public: enum { value = CV_32S, fmt=(int)'i' }; }; +// this is temporary solution to support 32-bit unsigned integers +template<> class DataDepth { public: enum { value = CV_32S, fmt=(int)'i' }; }; template<> class DataDepth { public: enum { value = CV_32F, fmt=(int)'f' }; }; template<> class DataDepth { public: enum { value = CV_64F, fmt=(int)'d' }; }; template class DataDepth<_Tp*> { public: enum { value = CV_USRTYPE1, fmt=(int)'r' }; }; @@ -969,6 +971,10 @@ public: typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; + + enum { depth = DataDepth::value, channels = 1, + fmt=DataDepth::fmt, + type = CV_MAKETYPE(depth, channels) }; }; template<> class DataType @@ -2445,10 +2451,10 @@ public: Mat_(const Mat_& m, const Range* ranges); //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column explicit Mat_(const vector<_Tp>& vec, bool copyData=false); - template explicit Mat_(const Vec<_Tp, n>& vec, bool copyData=true); - template explicit Mat_(const Matx<_Tp, m, n>& mtx, bool copyData=true); - explicit Mat_(const Point_<_Tp>& pt, bool copyData=true); - explicit Mat_(const Point3_<_Tp>& pt, bool copyData=true); + template explicit Mat_(const Vec::channel_type, n>& vec, bool copyData=true); + template explicit Mat_(const Matx::channel_type, m, n>& mtx, bool copyData=true); + explicit Mat_(const Point_::channel_type>& pt, bool copyData=true); + explicit Mat_(const Point3_::channel_type>& pt, bool copyData=true); explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); Mat_& operator = (const Mat& m); @@ -2540,9 +2546,9 @@ public: //! conversion to vector. operator vector<_Tp>() const; //! conversion to Vec - template operator Vec<_Tp, n>() const; + template operator Vec::channel_type, n>() const; //! conversion to Matx - template operator Matx<_Tp, m, n>() const; + template operator Matx::channel_type, m, n>() const; }; typedef Mat_ Mat1b; diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index a6bcbb5164cd579f0e85e2d1e95b2105dec11921..617f14892faed9c7c02869a1b63c23b3573f2ec3 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -793,18 +793,38 @@ template inline Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi) : Mat(m, roi) {} template template inline - Mat_<_Tp>::Mat_(const Vec<_Tp, n>& vec, bool copyData) - : Mat(vec, copyData) {} + Mat_<_Tp>::Mat_(const Vec::channel_type, n>& vec, bool copyData) + : Mat(n/DataType<_Tp>::channels, 1, DataType<_Tp>::type, &vec) +{ + CV_Assert(n%DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} template template inline - Mat_<_Tp>::Mat_(const Matx<_Tp,m,n>& M, bool copyData) - : Mat(M, copyData) {} + Mat_<_Tp>::Mat_(const Matx::channel_type,m,n>& M, bool copyData) + : Mat(m, n/DataType<_Tp>::channels, DataType<_Tp>::type, &M) +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} -template inline Mat_<_Tp>::Mat_(const Point_<_Tp>& pt, bool copyData) - : Mat(pt, copyData) {} +template inline Mat_<_Tp>::Mat_(const Point_::channel_type>& pt, bool copyData) + : Mat(2/DataType<_Tp>::channels, 1, DataType<_Tp>::type, &pt) +{ + CV_Assert(2 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} -template inline Mat_<_Tp>::Mat_(const Point3_<_Tp>& pt, bool copyData) - : Mat(pt, copyData) {} +template inline Mat_<_Tp>::Mat_(const Point3_::channel_type>& pt, bool copyData) + : Mat(3/DataType<_Tp>::channels, 1, DataType<_Tp>::type, &pt) +{ + CV_Assert(3 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} template inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) : Mat(commaInitializer) {} @@ -994,14 +1014,16 @@ template inline Mat_<_Tp>::operator vector<_Tp>() const return this->Mat::operator vector<_Tp>(); } -template template inline Mat_<_Tp>::operator Vec<_Tp, n>() const +template template inline Mat_<_Tp>::operator Vec::channel_type, n>() const { - return this->Mat::operator Vec<_Tp, n>(); + CV_Assert(n % DataType<_Tp>::channels == 0); + return this->Mat::operator Vec::channel_type, n>(); } -template template inline Mat_<_Tp>::operator Matx<_Tp, m, n>() const +template template inline Mat_<_Tp>::operator Matx::channel_type, m, n>() const { - return this->Mat::operator Matx<_Tp, m, n>(); + CV_Assert(n % DataType<_Tp>::channels == 0); + return this->Mat::operator Matx::channel_type, m, n>(); } template inline void diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 8a54e9230e700941d37b9b7bd46dfc8f56b85ede..45eec758d72da29062761f4fc0bbe121f9661913 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -130,15 +130,15 @@ CopyMaskFunc g_copyMaskFuncTab[] = 0, copyMask_ >, // 6 0, - copyMask_, // 8 + copyMask_ >, // 8 0, 0, 0, copyMask_ >, // 12 0, 0, 0, - copyMask_ >, // 16 + copyMask_ >, // 16 0, 0, 0, 0, 0, 0, 0, - copyMask_ >, // 24 + copyMask_ >, // 24 0, 0, 0, 0, 0, 0, 0, - copyMask_ > // 32 + copyMask_ > // 32 }; static SetMaskFunc setMaskFuncTab[] = @@ -151,15 +151,15 @@ static SetMaskFunc setMaskFuncTab[] = 0, setMask_ >, // 6 0, - setMask_, // 8 + setMask_ >, // 8 0, 0, 0, setMask_ >, // 12 0, 0, 0, - setMask_ >, // 16 + setMask_ >, // 16 0, 0, 0, 0, 0, 0, 0, - setMask_ >, // 24 + setMask_ >, // 24 0, 0, 0, 0, 0, 0, 0, - setMask_ > // 32 + setMask_ > // 32 }; @@ -424,15 +424,15 @@ void flip( const Mat& src, Mat& dst, int flip_mode ) 0, flipHoriz_ >, // 6 0, - flipHoriz_, // 8 + flipHoriz_ >, // 8 0, 0, 0, flipHoriz_ >, // 12 0, 0, 0, - flipHoriz_ >, // 16 + flipHoriz_ >, // 16 0, 0, 0, 0, 0, 0, 0, - flipHoriz_ >, // 24 + flipHoriz_ >, // 24 0, 0, 0, 0, 0, 0, 0, - flipHoriz_ > // 32 + flipHoriz_ > // 32 }; CV_Assert( src.dims <= 2 ); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 63048ba2b7584ffa5a11a3b9dd96273bc4ec5c55..1dcb5a54f55141fd8a226149b311cad31bc1b7bf 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -859,15 +859,15 @@ void transpose( const Mat& src, Mat& dst ) 0, transposeI_ >, // 6 0, - transposeI_, // 8 + transposeI_ >, // 8 0, 0, 0, transposeI_ >, // 12 0, 0, 0, - transposeI_ >, // 16 + transposeI_ >, // 16 0, 0, 0, 0, 0, 0, 0, - transposeI_ >, // 24 + transposeI_ >, // 24 0, 0, 0, 0, 0, 0, 0, - transposeI_ > // 32 + transposeI_ > // 32 }; TransposeFunc tab[] = @@ -880,15 +880,15 @@ void transpose( const Mat& src, Mat& dst ) 0, transpose_ >, // 6 0, - transpose_, // 8 + transpose_ >, // 8 0, 0, 0, transpose_ >, // 12 0, 0, 0, - transpose_ >, // 16 + transpose_ >, // 16 0, 0, 0, 0, 0, 0, 0, - transpose_ >, // 24 + transpose_ >, // 24 0, 0, 0, 0, 0, 0, 0, - transpose_ > // 32 + transpose_ > // 32 }; size_t esz = src.elemSize(); diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 3088097489502698a84a1718921520778f7f87dc..7feaf114756589f34a11aafb6e953e531145ae1e 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -699,15 +699,15 @@ void randShuffle( Mat& dst, double iterFactor, RNG* _rng ) 0, randShuffle_ >, // 6 0, - randShuffle_, // 8 + randShuffle_ >, // 8 0, 0, 0, randShuffle_ >, // 12 0, 0, 0, - randShuffle_ >, // 16 + randShuffle_ >, // 16 0, 0, 0, 0, 0, 0, 0, - randShuffle_ >, // 24 + randShuffle_ >, // 24 0, 0, 0, 0, 0, 0, 0, - randShuffle_ > // 32 + randShuffle_ > // 32 }; RNG& rng = _rng ? *_rng : theRNG(); diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index e4ce8348dbdff2f1761d8039ade5dad09356fdfa..20abd384f071966ff812a7a45cb528fa87bc8af7 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -135,25 +135,25 @@ Scalar sum( const Mat& m ) sum_, sum_, 0, - sumBlock_, Vec, Vec, 1<<24>, + sumBlock_, Vec, Vec, 1<<23>, sumBlock_, Vec, Vec, 1<<24>, - sumBlock_, Vec, Vec, 1<<16>, + sumBlock_, Vec, Vec, 1<<15>, sumBlock_, Vec, Vec, 1<<16>, sum_, Vec >, sum_, Vec >, sum_, Vec >, 0, - sumBlock_, Vec, Vec, 1<<24>, + sumBlock_, Vec, Vec, 1<<23>, sumBlock_, Vec, Vec, 1<<24>, - sumBlock_, Vec, Vec, 1<<16>, + sumBlock_, Vec, Vec, 1<<15>, sumBlock_, Vec, Vec, 1<<16>, sum_, Vec >, sum_, Vec >, sum_, Vec >, 0, - sumBlock_, Vec, Vec, 1<<24>, + sumBlock_, Vec, Vec, 1<<23>, sumBlock_, Vec, Vec, 1<<24>, - sumBlock_, Vec, Vec, 1<<16>, + sumBlock_, Vec, Vec, 1<<15>, sumBlock_, Vec, Vec, 1<<16>, sum_, Vec >, sum_, Vec >, @@ -304,29 +304,29 @@ Scalar mean( const Mat& m, const Mat& mask ) { static MeanMaskFunc tab[]= { - meanBlock_, 0, - meanBlock_, + meanBlock_, 0, + meanBlock_, meanBlock_, mean_, mean_, mean_, 0, - meanBlock_, Vec, Vec, 1<<24>, 0, - meanBlock_, Vec, Vec, 1<<16>, + meanBlock_, Vec, Vec, 1<<23>, 0, + meanBlock_, Vec, Vec, 1<<15>, meanBlock_, Vec, Vec, 1<<16>, mean_, Vec >, mean_, Vec >, mean_, Vec >, 0, - meanBlock_, Vec, Vec, 1<<24>, 0, - meanBlock_, Vec, Vec, 1<<16>, + meanBlock_, Vec, Vec, 1<<23>, 0, + meanBlock_, Vec, Vec, 1<<15>, meanBlock_, Vec, Vec, 1<<16>, mean_, Vec >, mean_, Vec >, mean_, Vec >, 0, - meanBlock_, Vec, Vec, 1<<24>, 0, - meanBlock_, Vec, Vec, 1<<16>, + meanBlock_, Vec, Vec, 1<<23>, 0, + meanBlock_, Vec, Vec, 1<<15>, meanBlock_, Vec, Vec, 1<<16>, mean_, Vec >, mean_, Vec >,