enable Matx as Mat elements (bug #1705).
This commit is contained in:
@@ -1107,6 +1107,18 @@ public:
|
|||||||
type = CV_MAKETYPE(depth, channels) };
|
type = CV_MAKETYPE(depth, channels) };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename _Tp, int m, int n> class DataType<Matx<_Tp, m, n> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Matx<_Tp, m, n> value_type;
|
||||||
|
typedef Matx<typename DataType<_Tp>::work_type, m, n> work_type;
|
||||||
|
typedef _Tp channel_type;
|
||||||
|
typedef value_type vec_type;
|
||||||
|
enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = m*n,
|
||||||
|
fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt,
|
||||||
|
type = CV_MAKETYPE(depth, channels) };
|
||||||
|
};
|
||||||
|
|
||||||
template<typename _Tp, int cn> class DataType<Vec<_Tp, cn> >
|
template<typename _Tp, int cn> class DataType<Vec<_Tp, cn> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -69,6 +69,7 @@ protected:
|
|||||||
|
|
||||||
bool SomeMatFunctions();
|
bool SomeMatFunctions();
|
||||||
bool TestMat();
|
bool TestMat();
|
||||||
|
template<typename _Tp> void TestType(Size sz, _Tp value=_Tp(1.f));
|
||||||
bool TestTemplateMat();
|
bool TestTemplateMat();
|
||||||
bool TestMatND();
|
bool TestMatND();
|
||||||
bool TestSparseMat();
|
bool TestSparseMat();
|
||||||
@@ -106,6 +107,19 @@ CV_OperationsTest::~CV_OperationsTest() {}
|
|||||||
#define MSVC_OLD 0
|
#define MSVC_OLD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename _Tp> void CV_OperationsTest::TestType(Size sz, _Tp value)
|
||||||
|
{
|
||||||
|
cv::Mat_<_Tp> m(sz);
|
||||||
|
CV_Assert(m.cols == sz.width && m.rows == sz.height && m.depth() == DataType<_Tp>::depth &&
|
||||||
|
m.channels() == DataType<_Tp>::channels &&
|
||||||
|
m.elemSize() == sizeof(_Tp) && m.step == m.elemSize()*m.cols);
|
||||||
|
for( int y = 0; y < sz.height; y++ )
|
||||||
|
for( int x = 0; x < sz.width; x++ )
|
||||||
|
m(y, x) = value;
|
||||||
|
|
||||||
|
CV_Assert( sum(m.reshape(1,1))[0] == (double)sz.width*sz.height );
|
||||||
|
}
|
||||||
|
|
||||||
bool CV_OperationsTest::TestMat()
|
bool CV_OperationsTest::TestMat()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -779,6 +793,16 @@ bool CV_OperationsTest::TestTemplateMat()
|
|||||||
badarg_catched = true;
|
badarg_catched = true;
|
||||||
}
|
}
|
||||||
CV_Assert( badarg_catched );
|
CV_Assert( badarg_catched );
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <opencv2/core/core.hpp>
|
||||||
|
|
||||||
|
Size size(2, 5);
|
||||||
|
TestType<float>(size);
|
||||||
|
TestType<cv::Vec3f>(size);
|
||||||
|
TestType<cv::Matx31f>(size);
|
||||||
|
TestType<cv::Matx41f>(size);
|
||||||
|
TestType<cv::Matx32f>(size);
|
||||||
}
|
}
|
||||||
catch (const test_excep& e)
|
catch (const test_excep& e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user