some fixes due to the changed policy in DataType & DataDepth handling

This commit is contained in:
Vadim Pisarevsky 2010-10-20 17:43:46 +00:00
parent 7d0feef775
commit be016a75df
6 changed files with 85 additions and 57 deletions

View File

@ -384,7 +384,7 @@ public:
The class is specialized for each fundamental numerical data type supported by OpenCV.
It provides DataDepth<T>::value constant.
*/
template<typename _Tp> class CV_EXPORTS DataDepth { public: enum { value = -1, fmt=(int)'\0' }; };
template<typename _Tp> class CV_EXPORTS DataDepth {};
template<> class DataDepth<bool> { public: enum { value = CV_8U, fmt=(int)'u' }; };
template<> class DataDepth<uchar> { public: enum { value = CV_8U, fmt=(int)'u' }; };
@ -393,6 +393,8 @@ template<> class DataDepth<char> { public: enum { value = CV_8S, fmt=(int)'c' };
template<> class DataDepth<ushort> { public: enum { value = CV_16U, fmt=(int)'w' }; };
template<> class DataDepth<short> { public: enum { value = CV_16S, fmt=(int)'s' }; };
template<> class DataDepth<int> { public: enum { value = CV_32S, fmt=(int)'i' }; };
// this is temporary solution to support 32-bit unsigned integers
template<> class DataDepth<unsigned> { public: enum { value = CV_32S, fmt=(int)'i' }; };
template<> class DataDepth<float> { public: enum { value = CV_32F, fmt=(int)'f' }; };
template<> class DataDepth<double> { public: enum { value = CV_64F, fmt=(int)'d' }; };
template<typename _Tp> 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<channel_type>::value, channels = 1,
fmt=DataDepth<channel_type>::fmt,
type = CV_MAKETYPE(depth, channels) };
};
template<> class DataType<bool>
@ -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<int n> explicit Mat_(const Vec<_Tp, n>& vec, bool copyData=true);
template<int m, int n> 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<int n> explicit Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData=true);
template<int m, int n> explicit Mat_(const Matx<typename DataType<_Tp>::channel_type, m, n>& mtx, bool copyData=true);
explicit Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
explicit Mat_(const Point3_<typename DataType<_Tp>::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<int n> operator Vec<_Tp, n>() const;
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
//! conversion to Matx
template<int m, int n> operator Matx<_Tp, m, n>() const;
template<int m, int n> operator Matx<typename DataType<_Tp>::channel_type, m, n>() const;
};
typedef Mat_<uchar> Mat1b;

View File

@ -793,18 +793,38 @@ template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi)
: Mat(m, roi) {}
template<typename _Tp> template<int n> inline
Mat_<_Tp>::Mat_(const Vec<_Tp, n>& vec, bool copyData)
: Mat(vec, copyData) {}
Mat_<_Tp>::Mat_(const Vec<typename DataType<_Tp>::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<typename _Tp> template<int m, int n> inline
Mat_<_Tp>::Mat_(const Matx<_Tp,m,n>& M, bool copyData)
: Mat(M, copyData) {}
Mat_<_Tp>::Mat_(const Matx<typename DataType<_Tp>::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<typename _Tp> inline Mat_<_Tp>::Mat_(const Point_<_Tp>& pt, bool copyData)
: Mat(pt, copyData) {}
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point_<typename DataType<_Tp>::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<typename _Tp> inline Mat_<_Tp>::Mat_(const Point3_<_Tp>& pt, bool copyData)
: Mat(pt, copyData) {}
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point3_<typename DataType<_Tp>::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<typename _Tp> inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer)
: Mat(commaInitializer) {}
@ -994,14 +1014,16 @@ template<typename _Tp> inline Mat_<_Tp>::operator vector<_Tp>() const
return this->Mat::operator vector<_Tp>();
}
template<typename _Tp> template<int n> inline Mat_<_Tp>::operator Vec<_Tp, n>() const
template<typename _Tp> template<int n> inline Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const
{
return this->Mat::operator Vec<_Tp, n>();
CV_Assert(n % DataType<_Tp>::channels == 0);
return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>();
}
template<typename _Tp> template<int m, int n> inline Mat_<_Tp>::operator Matx<_Tp, m, n>() const
template<typename _Tp> template<int m, int n> inline Mat_<_Tp>::operator Matx<typename DataType<_Tp>::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<typename DataType<_Tp>::channel_type, m, n>();
}
template<typename T1, typename T2, typename Op> inline void

View File

@ -130,15 +130,15 @@ CopyMaskFunc g_copyMaskFuncTab[] =
0,
copyMask_<Vec<ushort,3> >, // 6
0,
copyMask_<int64>, // 8
copyMask_<Vec<int,2> >, // 8
0, 0, 0,
copyMask_<Vec<int,3> >, // 12
0, 0, 0,
copyMask_<Vec<int64,2> >, // 16
copyMask_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
copyMask_<Vec<int64,3> >, // 24
copyMask_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
copyMask_<Vec<int64,4> > // 32
copyMask_<Vec<int,8> > // 32
};
static SetMaskFunc setMaskFuncTab[] =
@ -151,15 +151,15 @@ static SetMaskFunc setMaskFuncTab[] =
0,
setMask_<Vec<ushort,3> >, // 6
0,
setMask_<int64>, // 8
setMask_<Vec<int,2> >, // 8
0, 0, 0,
setMask_<Vec<int,3> >, // 12
0, 0, 0,
setMask_<Vec<int64,2> >, // 16
setMask_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
setMask_<Vec<int64,3> >, // 24
setMask_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
setMask_<Vec<int64,4> > // 32
setMask_<Vec<int,8> > // 32
};
@ -424,15 +424,15 @@ void flip( const Mat& src, Mat& dst, int flip_mode )
0,
flipHoriz_<Vec<ushort,3> >, // 6
0,
flipHoriz_<int64>, // 8
flipHoriz_<Vec<int,2> >, // 8
0, 0, 0,
flipHoriz_<Vec<int,3> >, // 12
0, 0, 0,
flipHoriz_<Vec<int64,2> >, // 16
flipHoriz_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
flipHoriz_<Vec<int64,3> >, // 24
flipHoriz_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
flipHoriz_<Vec<int64,4> > // 32
flipHoriz_<Vec<int,8> > // 32
};
CV_Assert( src.dims <= 2 );

View File

@ -859,15 +859,15 @@ void transpose( const Mat& src, Mat& dst )
0,
transposeI_<Vec<ushort,3> >, // 6
0,
transposeI_<int64>, // 8
transposeI_<Vec<int,2> >, // 8
0, 0, 0,
transposeI_<Vec<int,3> >, // 12
0, 0, 0,
transposeI_<Vec<int64,2> >, // 16
transposeI_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
transposeI_<Vec<int64,3> >, // 24
transposeI_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
transposeI_<Vec<int64,4> > // 32
transposeI_<Vec<int,8> > // 32
};
TransposeFunc tab[] =
@ -880,15 +880,15 @@ void transpose( const Mat& src, Mat& dst )
0,
transpose_<Vec<ushort,3> >, // 6
0,
transpose_<int64>, // 8
transpose_<Vec<int,2> >, // 8
0, 0, 0,
transpose_<Vec<int,3> >, // 12
0, 0, 0,
transpose_<Vec<int64,2> >, // 16
transpose_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
transpose_<Vec<int64,3> >, // 24
transpose_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
transpose_<Vec<int64,4> > // 32
transpose_<Vec<int,8> > // 32
};
size_t esz = src.elemSize();

View File

@ -699,15 +699,15 @@ void randShuffle( Mat& dst, double iterFactor, RNG* _rng )
0,
randShuffle_<Vec<ushort,3> >, // 6
0,
randShuffle_<int64>, // 8
randShuffle_<Vec<int,2> >, // 8
0, 0, 0,
randShuffle_<Vec<int,3> >, // 12
0, 0, 0,
randShuffle_<Vec<int64,2> >, // 16
randShuffle_<Vec<int,4> >, // 16
0, 0, 0, 0, 0, 0, 0,
randShuffle_<Vec<int64,3> >, // 24
randShuffle_<Vec<int,6> >, // 24
0, 0, 0, 0, 0, 0, 0,
randShuffle_<Vec<int64,4> > // 32
randShuffle_<Vec<int,8> > // 32
};
RNG& rng = _rng ? *_rng : theRNG();

View File

@ -135,25 +135,25 @@ Scalar sum( const Mat& m )
sum_<float, double>,
sum_<double, double>, 0,
sumBlock_<Vec<uchar, 2>, Vec<unsigned, 2>, Vec<double, 2>, 1<<24>,
sumBlock_<Vec<uchar, 2>, Vec<int, 2>, Vec<double, 2>, 1<<23>,
sumBlock_<Vec<schar, 2>, Vec<int, 2>, Vec<double, 2>, 1<<24>,
sumBlock_<Vec<ushort, 2>, Vec<unsigned, 2>, Vec<double, 2>, 1<<16>,
sumBlock_<Vec<ushort, 2>, Vec<int, 2>, Vec<double, 2>, 1<<15>,
sumBlock_<Vec<short, 2>, Vec<int, 2>, Vec<double, 2>, 1<<16>,
sum_<Vec<int, 2>, Vec<double, 2> >,
sum_<Vec<float, 2>, Vec<double, 2> >,
sum_<Vec<double, 2>, Vec<double, 2> >, 0,
sumBlock_<Vec<uchar, 3>, Vec<unsigned, 3>, Vec<double, 3>, 1<<24>,
sumBlock_<Vec<uchar, 3>, Vec<int, 3>, Vec<double, 3>, 1<<23>,
sumBlock_<Vec<schar, 3>, Vec<int, 3>, Vec<double, 3>, 1<<24>,
sumBlock_<Vec<ushort, 3>, Vec<unsigned, 3>, Vec<double, 3>, 1<<16>,
sumBlock_<Vec<ushort, 3>, Vec<int, 3>, Vec<double, 3>, 1<<15>,
sumBlock_<Vec<short, 3>, Vec<int, 3>, Vec<double, 3>, 1<<16>,
sum_<Vec<int, 3>, Vec<double, 3> >,
sum_<Vec<float, 3>, Vec<double, 3> >,
sum_<Vec<double, 3>, Vec<double, 3> >, 0,
sumBlock_<Vec<uchar, 4>, Vec<unsigned, 4>, Vec<double, 4>, 1<<24>,
sumBlock_<Vec<uchar, 4>, Vec<int, 4>, Vec<double, 4>, 1<<23>,
sumBlock_<Vec<schar, 4>, Vec<int, 4>, Vec<double, 4>, 1<<24>,
sumBlock_<Vec<ushort, 4>, Vec<unsigned, 4>, Vec<double, 4>, 1<<16>,
sumBlock_<Vec<ushort, 4>, Vec<int, 4>, Vec<double, 4>, 1<<15>,
sumBlock_<Vec<short, 4>, Vec<int, 4>, Vec<double, 4>, 1<<16>,
sum_<Vec<int, 4>, Vec<double, 4> >,
sum_<Vec<float, 4>, Vec<double, 4> >,
@ -304,29 +304,29 @@ Scalar mean( const Mat& m, const Mat& mask )
{
static MeanMaskFunc tab[]=
{
meanBlock_<uchar, unsigned, double, 1<<24>, 0,
meanBlock_<ushort, unsigned, double, 1<<16>,
meanBlock_<uchar, int, double, 1<<23>, 0,
meanBlock_<ushort, int, double, 1<<15>,
meanBlock_<short, int, double, 1<<16>,
mean_<int, double>,
mean_<float, double>,
mean_<double, double>, 0,
meanBlock_<Vec<uchar, 2>, Vec<unsigned, 2>, Vec<double, 2>, 1<<24>, 0,
meanBlock_<Vec<ushort, 2>, Vec<unsigned, 2>, Vec<double, 2>, 1<<16>,
meanBlock_<Vec<uchar, 2>, Vec<int, 2>, Vec<double, 2>, 1<<23>, 0,
meanBlock_<Vec<ushort, 2>, Vec<int, 2>, Vec<double, 2>, 1<<15>,
meanBlock_<Vec<short, 2>, Vec<int, 2>, Vec<double, 2>, 1<<16>,
mean_<Vec<int, 2>, Vec<double, 2> >,
mean_<Vec<float, 2>, Vec<double, 2> >,
mean_<Vec<double, 2>, Vec<double, 2> >, 0,
meanBlock_<Vec<uchar, 3>, Vec<unsigned, 3>, Vec<double, 3>, 1<<24>, 0,
meanBlock_<Vec<ushort, 3>, Vec<unsigned, 3>, Vec<double, 3>, 1<<16>,
meanBlock_<Vec<uchar, 3>, Vec<int, 3>, Vec<double, 3>, 1<<23>, 0,
meanBlock_<Vec<ushort, 3>, Vec<int, 3>, Vec<double, 3>, 1<<15>,
meanBlock_<Vec<short, 3>, Vec<int, 3>, Vec<double, 3>, 1<<16>,
mean_<Vec<int, 3>, Vec<double, 3> >,
mean_<Vec<float, 3>, Vec<double, 3> >,
mean_<Vec<double, 3>, Vec<double, 3> >, 0,
meanBlock_<Vec<uchar, 4>, Vec<unsigned, 4>, Vec<double, 4>, 1<<24>, 0,
meanBlock_<Vec<ushort, 4>, Vec<unsigned, 4>, Vec<double, 4>, 1<<16>,
meanBlock_<Vec<uchar, 4>, Vec<int, 4>, Vec<double, 4>, 1<<23>, 0,
meanBlock_<Vec<ushort, 4>, Vec<int, 4>, Vec<double, 4>, 1<<15>,
meanBlock_<Vec<short, 4>, Vec<int, 4>, Vec<double, 4>, 1<<16>,
mean_<Vec<int, 4>, Vec<double, 4> >,
mean_<Vec<float, 4>, Vec<double, 4> >,