From 207218e9208cebecfaaf7d9ed3bdd2dae338491a Mon Sep 17 00:00:00 2001 From: hailong-wang Date: Tue, 14 Mar 2017 13:02:59 +0800 Subject: [PATCH] Fix the bug of Mat_<>::opeartor [] `template inline const _Tp* Mat_<_Tp>::operator [](int y) const` does not support 3d matrix since it checks rows. This operator[] shall check size.p[0] instead. --- modules/core/include/opencv2/core/mat.inl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 4a32de1..b3b7110 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -1634,14 +1634,14 @@ Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector& ranges) const template inline _Tp* Mat_<_Tp>::operator [](int y) { - CV_DbgAssert( 0 <= y && y < rows ); + CV_DbgAssert( 0 <= y && y < size.p[0] ); return (_Tp*)(data + y*step.p[0]); } template inline const _Tp* Mat_<_Tp>::operator [](int y) const { - CV_DbgAssert( 0 <= y && y < rows ); + CV_DbgAssert( 0 <= y && y < size.p[0] ); return (const _Tp*)(data + y*step.p[0]); } -- 2.7.4