fix issue 3891

pull/4122/head
Alexander Alekhin 10 years ago
parent 424c2bddb3
commit 9394486147
  1. 12
      modules/core/include/opencv2/core/mat.inl.hpp
  2. 2
      modules/core/test/test_mat.cpp

@ -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

@ -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)

Loading…
Cancel
Save