mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
fix#9570: implement mat ptr for generic types
The original template based mat ptr for indexing is not implemented, add the similar implementation as uchar type, but cast to user-defined type from the uchar pointer.
This commit is contained in:
@@ -1058,6 +1058,34 @@ const uchar* Mat::ptr(const int* idx) const
|
||||
return p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp* Mat::ptr(const int* idx)
|
||||
{
|
||||
int i, d = dims;
|
||||
uchar* p = data;
|
||||
CV_DbgAssert( d >= 1 && p );
|
||||
for( i = 0; i < d; i++ )
|
||||
{
|
||||
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
||||
p += idx[i] * step.p[i];
|
||||
}
|
||||
return (_Tp*)p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
const _Tp* Mat::ptr(const int* idx) const
|
||||
{
|
||||
int i, d = dims;
|
||||
uchar* p = data;
|
||||
CV_DbgAssert( d >= 1 && p );
|
||||
for( i = 0; i < d; i++ )
|
||||
{
|
||||
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
||||
p += idx[i] * step.p[i];
|
||||
}
|
||||
return (const _Tp*)p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp& Mat::at(int i0, int i1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user