fix issue 3891

This commit is contained in:
Alexander Alekhin 2015-06-16 17:56:00 +03:00
parent 424c2bddb3
commit 9394486147
2 changed files with 13 additions and 1 deletions

View File

@ -1586,7 +1586,13 @@ template<typename _Tp> template<int n> inline
Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const
{
CV_Assert(n % DataType<_Tp>::channels == 0);
#if defined _MSC_VER
const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround)
return pMat->operator Vec<typename DataType<_Tp>::channel_type, n>();
#else
return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>();
#endif
}
template<typename _Tp> template<int m, int n> inline
@ -1594,8 +1600,14 @@ Mat_<_Tp>::operator Matx<typename DataType<_Tp>::channel_type, m, n>() const
{
CV_Assert(n % DataType<_Tp>::channels == 0);
#if defined _MSC_VER
const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround)
Matx<typename DataType<_Tp>::channel_type, m, n> res = pMat->operator Matx<typename DataType<_Tp>::channel_type, m, n>();
return res;
#else
Matx<typename DataType<_Tp>::channel_type, m, n> res = this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>();
return res;
#endif
}
template<typename _Tp> inline

View File

@ -1214,7 +1214,7 @@ TEST(Core_Matx, fromMat_)
{
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
Matx22d b(a);
ASSERT_EQ( norm(a, b, NORM_INF), 0.);
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
}
TEST(Core_InputArray, empty)