diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 3779b83f82..2b648718c2 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -1586,7 +1586,13 @@ template template inline Mat_<_Tp>::operator Vec::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::channel_type, n>(); +#else return this->Mat::operator Vec::channel_type, n>(); +#endif } template template inline @@ -1594,8 +1600,14 @@ Mat_<_Tp>::operator Matx::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::channel_type, m, n> res = pMat->operator Matx::channel_type, m, n>(); + return res; +#else Matx::channel_type, m, n> res = this->Mat::operator Matx::channel_type, m, n>(); return res; +#endif } template inline diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 897ac40a43..19992433b2 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1214,7 +1214,7 @@ TEST(Core_Matx, fromMat_) { Mat_ a = (Mat_(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)