diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index bc6dd31438..fe7c0a8c48 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -261,8 +261,8 @@ public: int* refcount; //! helper fields used in locateROI and adjustROI - uchar* datastart; - uchar* dataend; + const uchar* datastart; + const uchar* dataend; //! allocator Allocator* allocator; @@ -349,8 +349,8 @@ public: uchar* data; int* refcount; - uchar* datastart; - uchar* dataend; + const uchar* datastart; + const uchar* dataend; AllocType alloc_type; }; diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 945b450303..44501f6de9 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -395,7 +395,7 @@ struct CV_EXPORTS UMatData struct CV_EXPORTS UMatDataAutoLock { - UMatDataAutoLock(UMatData* u); + explicit UMatDataAutoLock(UMatData* u); ~UMatDataAutoLock(); UMatData* u; }; @@ -403,7 +403,7 @@ struct CV_EXPORTS UMatDataAutoLock struct CV_EXPORTS MatSize { - MatSize(int* _p); + explicit MatSize(int* _p); Size operator()() const; const int& operator[](int i) const; int& operator[](int i); @@ -417,7 +417,7 @@ struct CV_EXPORTS MatSize struct CV_EXPORTS MatStep { MatStep(); - MatStep(size_t s); + explicit MatStep(size_t s); const size_t& operator[](int i) const; size_t& operator[](int i); operator size_t() const; @@ -918,9 +918,9 @@ public: uchar* data; //! helper fields used in locateROI and adjustROI - uchar* datastart; - uchar* dataend; - uchar* datalimit; + const uchar* datastart; + const uchar* dataend; + const uchar* datalimit; //! custom allocator MatAllocator* allocator; @@ -1804,9 +1804,9 @@ public: //! copy operator MatConstIterator& operator = (const MatConstIterator& it); //! returns the current matrix element - uchar* operator *() const; + const uchar* operator *() const; //! returns the i-th matrix element, relative to the current - uchar* operator [](ptrdiff_t i) const; + const uchar* operator [](ptrdiff_t i) const; //! shifts the iterator forward by the specified number of elements MatConstIterator& operator += (ptrdiff_t ofs); @@ -1831,9 +1831,9 @@ public: const Mat* m; size_t elemSize; - uchar* ptr; - uchar* sliceStart; - uchar* sliceEnd; + const uchar* ptr; + const uchar* sliceStart; + const uchar* sliceEnd; }; @@ -1917,9 +1917,9 @@ public: //! constructor that sets the iterator to the specified element of the matrix MatIterator_(Mat_<_Tp>* _m, int _row, int _col=0); //! constructor that sets the iterator to the specified element of the matrix - MatIterator_(const Mat_<_Tp>* _m, Point _pt); + MatIterator_(Mat_<_Tp>* _m, Point _pt); //! constructor that sets the iterator to the specified element of the matrix - MatIterator_(const Mat_<_Tp>* _m, const int* _idx); + MatIterator_(Mat_<_Tp>* _m, const int* _idx); //! copy constructor MatIterator_(const MatIterator_& it); //! copy operator diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index dae0e137a8..6923146f94 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -438,7 +438,7 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData) if( !copyData ) { step[0] = step[1] = sizeof(_Tp); - data = datastart = (uchar*)&vec[0]; + datastart = data = (uchar*)&vec[0]; datalimit = dataend = datastart + rows * step[0]; } else @@ -453,7 +453,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) if( !copyData ) { step[0] = step[1] = sizeof(_Tp); - data = datastart = (uchar*)vec.val; + datastart = data = (uchar*)vec.val; datalimit = dataend = datastart + rows * step[0]; } else @@ -470,7 +470,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) { step[0] = cols * sizeof(_Tp); step[1] = sizeof(_Tp); - data = datastart = (uchar*)M.val; + datastart = data = (uchar*)M.val; datalimit = dataend = datastart + rows * step[0]; } else @@ -485,7 +485,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData) if( !copyData ) { step[0] = step[1] = sizeof(_Tp); - data = datastart = (uchar*)&pt.x; + datastart = data = (uchar*)&pt.x; datalimit = dataend = datastart + rows * step[0]; } else @@ -504,7 +504,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData) if( !copyData ) { step[0] = step[1] = sizeof(_Tp); - data = datastart = (uchar*)&pt.x; + datastart = data = (uchar*)&pt.x; datalimit = dataend = datastart + rows * step[0]; } else @@ -642,7 +642,7 @@ inline void Mat::release() if( u && CV_XADD(&u->refcount, -1) == 1 ) deallocate(); u = NULL; - data = datastart = dataend = datalimit = 0; + datastart = dataend = datalimit = data = 0; size.p[0] = 0; } @@ -1044,7 +1044,7 @@ void Mat::push_back(const _Tp& elem) } CV_Assert(DataType<_Tp>::type == type() && cols == 1 /* && dims == 2 (cols == 1 implies dims == 2) */); - uchar* tmp = dataend + step[0]; + const uchar* tmp = dataend + step[0]; if( !isSubmatrix() && isContinuous() && tmp <= datalimit ) { *(_Tp*)(data + (size.p[0]++) * step.p[0]) = elem; @@ -2148,7 +2148,7 @@ MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it ) } inline -uchar* MatConstIterator::operator *() const +const uchar* MatConstIterator::operator *() const { return ptr; } @@ -2281,7 +2281,7 @@ MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs) inline -uchar* MatConstIterator::operator [](ptrdiff_t i) const +const uchar* MatConstIterator::operator [](ptrdiff_t i) const { return *(*this + i); } @@ -2453,12 +2453,12 @@ MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col) {} template inline -MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, Point _pt) +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, Point _pt) : MatConstIterator_<_Tp>(_m, _pt) {} template inline -MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, const int* _idx) +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, const int* _idx) : MatConstIterator_<_Tp>(_m, _idx) {} @@ -2592,7 +2592,7 @@ inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseM template inline const _Tp& SparseMatConstIterator::value() const { - return *(_Tp*)ptr; + return *(const _Tp*)ptr; } inline diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index c1551acb41..c74d87dcba 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -2635,8 +2635,8 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) for( i = 0; i < nonzero_rows; i++ ) { - uchar* sptr = src.data + i*src.step; - uchar* dptr0 = dst.data + i*dst.step; + const uchar* sptr = src.ptr(i); + uchar* dptr0 = dst.ptr(i); uchar* dptr = dptr0; if( tmp_buf ) @@ -2649,7 +2649,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) for( ; i < count; i++ ) { - uchar* dptr0 = dst.data + i*dst.step; + uchar* dptr0 = dst.ptr(i); memset( dptr0, 0, dst_full_len ); } @@ -2661,7 +2661,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) { int a = 0, b = count; uchar *buf0, *buf1, *dbuf0, *dbuf1; - uchar* sptr0 = src.data; + const uchar* sptr0 = src.data; uchar* dptr0 = dst.data; buf0 = ptr; ptr += len*complex_elem_size; @@ -2800,7 +2800,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) int n = dst.cols; if( elem_size == (int)sizeof(float) ) { - float* p0 = (float*)dst.data; + float* p0 = dst.ptr(); size_t dstep = dst.step/sizeof(p0[0]); for( i = 0; i < len; i++ ) { @@ -2816,7 +2816,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) } else { - double* p0 = (double*)dst.data; + double* p0 = dst.ptr(); size_t dstep = dst.step/sizeof(p0[0]); for( i = 0; i < len; i++ ) { diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 8895a56593..45881c3d55 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -955,10 +955,10 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) SVD::compute(src, w, u, vt); SVD::backSubst(w, u, vt, Mat(), _dst); return type == CV_32F ? - (((float*)w.data)[0] >= FLT_EPSILON ? - ((float*)w.data)[n-1]/((float*)w.data)[0] : 0) : - (((double*)w.data)[0] >= DBL_EPSILON ? - ((double*)w.data)[n-1]/((double*)w.data)[0] : 0); + (w.ptr()[0] >= FLT_EPSILON ? + w.ptr()[n-1]/w.ptr()[0] : 0) : + (w.ptr()[0] >= DBL_EPSILON ? + w.ptr()[n-1]/w.ptr()[0] : 0); } CV_Assert( m == n ); @@ -975,10 +975,10 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) transpose(vt, u); SVD::backSubst(w, u, vt, Mat(), _dst); return type == CV_32F ? - (((float*)w.data)[0] >= FLT_EPSILON ? - ((float*)w.data)[n-1]/((float*)w.data)[0] : 0) : - (((double*)w.data)[0] >= DBL_EPSILON ? - ((double*)w.data)[n-1]/((double*)w.data)[0] : 0); + (w.ptr()[0] >= FLT_EPSILON ? + w.ptr()[n-1]/w.ptr()[0] : 0) : + (w.ptr()[0] >= DBL_EPSILON ? + w.ptr()[n-1]/w.ptr()[0] : 0); } CV_Assert( method == DECOMP_LU || method == DECOMP_CHOLESKY ); @@ -988,7 +988,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) if( n <= 3 ) { - uchar* srcdata = src.data; + const uchar* srcdata = src.data; uchar* dstdata = dst.data; size_t srcstep = src.step; size_t dststep = dst.step; @@ -1212,8 +1212,8 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth #define bf(y) ((float*)(bdata + y*src2step))[0] #define bd(y) ((double*)(bdata + y*src2step))[0] - uchar* srcdata = src.data; - uchar* bdata = _src2.data; + const uchar* srcdata = src.data; + const uchar* bdata = _src2.data; uchar* dstdata = dst.data; size_t srcstep = src.step; size_t src2step = _src2.step; @@ -1709,7 +1709,7 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, eigen(src, evals, evects); if( evects0.data != evects.data ) { - uchar* p = evects0.data; + const uchar* p = evects0.data; evects.convertTo(evects0, evects0.type()); CV_Assert( p == evects0.data ); } @@ -1718,7 +1718,7 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, eigen(src, evals); if( evals0.data != evals.data ) { - uchar* p = evals0.data; + const uchar* p = evals0.data; if( evals0.size() == evals.size() ) evals.convertTo(evals0, evals0.type()); else if( evals0.type() == evals.type() ) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 7eff30660c..af0fe2219b 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -346,7 +346,7 @@ static void finalizeHdr(Mat& m) if( d > 2 ) m.rows = m.cols = -1; if(m.u) - m.data = m.datastart = m.u->data; + m.datastart = m.data = m.u->data; if( m.data ) { m.datalimit = m.datastart + m.size[0]*m.step[0]; @@ -510,7 +510,7 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st datalimit(0), allocator(0), u(0), size(&rows) { flags |= CV_MAT_TYPE(_type); - data = datastart = (uchar*)_data; + datastart = data = (uchar*)_data; setSize(*this, _dims, _sizes, _steps, true); finalizeHdr(*this); } @@ -549,7 +549,7 @@ static Mat cvMatNDToMat(const CvMatND* m, bool copyData) if( !m ) return thiz; - thiz.data = thiz.datastart = m->data.ptr; + thiz.datastart = thiz.data = m->data.ptr; thiz.flags |= CV_MAT_TYPE(m->type); int _sizes[CV_MAX_DIM]; size_t _steps[CV_MAX_DIM]; @@ -587,7 +587,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) thiz.dims = 2; thiz.rows = m->rows; thiz.cols = m->cols; - thiz.data = thiz.datastart = m->data.ptr; + thiz.datastart = thiz.data = m->data.ptr; size_t esz = CV_ELEM_SIZE(m->type), minstep = thiz.cols*esz, _step = m->step; if( _step == 0 ) _step = minstep; @@ -597,7 +597,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) } else { - thiz.data = thiz.datastart = thiz.dataend = 0; + thiz.datastart = thiz.dataend = thiz.data = 0; Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(thiz); } @@ -636,7 +636,7 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) m.rows = img->roi->height; m.cols = img->roi->width; esz = CV_ELEM_SIZE(m.flags); - m.data = m.datastart = (uchar*)img->imageData + + m.datastart = m.data = (uchar*)img->imageData + (selectedPlane ? (img->roi->coi - 1)*m.step*img->height : 0) + img->roi->yOffset*m.step[0] + img->roi->xOffset*esz; } @@ -5532,14 +5532,14 @@ double norm( const SparseMat& src, int normType ) { if( normType == NORM_INF ) for( i = 0; i < N; i++, ++it ) - result = std::max(result, std::abs((double)*(const float*)it.ptr)); + result = std::max(result, std::abs((double)it.value())); else if( normType == NORM_L1 ) for( i = 0; i < N; i++, ++it ) - result += std::abs(*(const float*)it.ptr); + result += std::abs(it.value()); else for( i = 0; i < N; i++, ++it ) { - double v = *(const float*)it.ptr; + double v = it.value(); result += v*v; } } @@ -5547,14 +5547,14 @@ double norm( const SparseMat& src, int normType ) { if( normType == NORM_INF ) for( i = 0; i < N; i++, ++it ) - result = std::max(result, std::abs(*(const double*)it.ptr)); + result = std::max(result, std::abs(it.value())); else if( normType == NORM_L1 ) for( i = 0; i < N; i++, ++it ) - result += std::abs(*(const double*)it.ptr); + result += std::abs(it.value()); else for( i = 0; i < N; i++, ++it ) { - double v = *(const double*)it.ptr; + double v = it.value(); result += v*v; } } @@ -5578,7 +5578,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi float minval = FLT_MAX, maxval = -FLT_MAX; for( i = 0; i < N; i++, ++it ) { - float v = *(const float*)it.ptr; + float v = it.value(); if( v < minval ) { minval = v; @@ -5600,7 +5600,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi double minval = DBL_MAX, maxval = -DBL_MAX; for( i = 0; i < N; i++, ++it ) { - double v = *(const double*)it.ptr; + double v = it.value(); if( v < minval ) { minval = v; diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index 7abbde543e..20e8aa5a79 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -782,7 +782,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) int type = src.type(); if( !mask.empty() ) { - typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *); + typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); ippiMaskMeanFuncC1 ippFuncC1 = type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR : type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR : @@ -795,7 +795,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) return Scalar(res); setIppErrorStatus(); } - typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *); + typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); ippiMaskMeanFuncC3 ippFuncC3 = type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR : type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR : @@ -1071,7 +1071,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input int type = src.type(); if( !mask.empty() ) { - typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *, Ipp64f *); + typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *, Ipp64f *); ippiMaskMeanStdDevFuncC1 ippFuncC1 = type == CV_8UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_8u_C1MR : type == CV_16UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_16u_C1MR : @@ -1083,7 +1083,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input return; setIppErrorStatus(); } - typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *, Ipp64f *); + typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *, Ipp64f *); ippiMaskMeanStdDevFuncC3 ippFuncC3 = type == CV_8UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CMR : type == CV_16UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CMR : diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index ab8865d047..a128bcd01d 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -582,7 +582,7 @@ Mat UMat::getMat(int accessFlags) const hdr.flags = flags; hdr.u = u; hdr.datastart = u->data; - hdr.data = hdr.datastart + offset; + hdr.data = u->data + offset; hdr.datalimit = hdr.dataend = u->data + u->size; CV_XADD(&hdr.u->refcount, 1); return hdr; diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index f4690eb170..213dd60413 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -427,7 +427,7 @@ BRISK::smoothedIntensity(const cv::Mat& image, const cv::Mat& integral, const fl if (dx + dy > 2) { // now the calculation: - uchar* ptr = image.data + x_left + imagecols * y_top; + const uchar* ptr = image.data + x_left + imagecols * y_top; // first the corners: ret_val = A * int(*ptr); ptr += dx + 1; @@ -475,7 +475,7 @@ BRISK::smoothedIntensity(const cv::Mat& image, const cv::Mat& integral, const fl } // now the calculation: - uchar* ptr = image.data + x_left + imagecols * y_top; + const uchar* ptr = image.data + x_left + imagecols * y_top; // first row: ret_val = A * int(*ptr); ptr++; @@ -487,7 +487,7 @@ BRISK::smoothedIntensity(const cv::Mat& image, const cv::Mat& integral, const fl ret_val += B * int(*ptr); // middle ones: ptr += imagecols - dx - 1; - uchar* end_j = ptr + dy * imagecols; + const uchar* end_j = ptr + dy * imagecols; for (; ptr < end_j; ptr += imagecols - dx - 1) { ret_val += r_x_1_i * int(*ptr); @@ -607,7 +607,7 @@ BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, s int t2; // the feature orientation - uchar* ptr = descriptors.data; + const uchar* ptr = descriptors.data; for (size_t k = 0; k < ksize; k++) { cv::KeyPoint& kp = keypoints[k]; @@ -1070,7 +1070,7 @@ BriskScaleSpace::isMax2D(const int layer, const int x_layer, const int y_layer) { const cv::Mat& scores = pyramid_[layer].scores(); const int scorescols = scores.cols; - uchar* data = scores.data + y_layer * scorescols + x_layer; + const uchar* data = scores.data + y_layer * scorescols + x_layer; // decision tree: const uchar center = (*data); data--; @@ -2140,7 +2140,7 @@ BriskLayer::value(const cv::Mat& mat, float xf, float yf, float scale_in) const const int r_y = (int)((yf - y) * 1024); const int r_x_1 = (1024 - r_x); const int r_y_1 = (1024 - r_y); - uchar* ptr = image.data + x + y * imagecols; + const uchar* ptr = image.data + x + y * imagecols; // just interpolate: ret_val = (r_x_1 * r_y_1 * int(*ptr)); ptr++; @@ -2186,7 +2186,7 @@ BriskLayer::value(const cv::Mat& mat, float xf, float yf, float scale_in) const const int r_y1_i = (int)(r_y1 * scaling); // now the calculation: - uchar* ptr = image.data + x_left + imagecols * y_top; + const uchar* ptr = image.data + x_left + imagecols * y_top; // first row: ret_val = A * int(*ptr); ptr++; @@ -2198,7 +2198,7 @@ BriskLayer::value(const cv::Mat& mat, float xf, float yf, float scale_in) const ret_val += B * int(*ptr); // middle ones: ptr += imagecols - dx - 1; - uchar* end_j = ptr + dy * imagecols; + const uchar* end_j = ptr + dy * imagecols; for (; ptr < end_j; ptr += imagecols - dx - 1) { ret_val += r_x_1_i * int(*ptr); diff --git a/modules/imgcodecs/src/grfmt_jpeg2000.cpp b/modules/imgcodecs/src/grfmt_jpeg2000.cpp index d711846ce8..83fd55a594 100644 --- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp @@ -154,7 +154,7 @@ bool Jpeg2KDecoder::readData( Mat& img ) { bool result = false; int color = img.channels() > 1; - uchar* data = img.data; + uchar* data = img.ptr(); int step = (int)img.step; jas_stream_t* stream = (jas_stream_t*)m_stream; jas_image_t* image = (jas_image_t*)m_image; @@ -478,7 +478,7 @@ bool Jpeg2KEncoder::writeComponent8u( void *__img, const Mat& _img ) for( int y = 0; y < h; y++ ) { - uchar* data = _img.data + _img.step*y; + const uchar* data = _img.ptr(y); for( int i = 0; i < ncmpts; i++ ) { for( int x = 0; x < w; x++) @@ -502,7 +502,7 @@ bool Jpeg2KEncoder::writeComponent16u( void *__img, const Mat& _img ) for( int y = 0; y < h; y++ ) { - uchar* data = _img.data + _img.step*y; + const uchar* data = _img.ptr(y); for( int i = 0; i < ncmpts; i++ ) { for( int x = 0; x < w; x++) diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index a0927b0f39..6b8cb8c472 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -228,7 +228,7 @@ int CV_MorphologyBaseTest::prepare_test_case( int test_case_idx ) if( shape == CV_SHAPE_CUSTOM ) { eldata.resize(aperture_size.width*aperture_size.height); - uchar* src = test_mat[INPUT][1].data; + const uchar* src = test_mat[INPUT][1].data; int srcstep = (int)test_mat[INPUT][1].step; int i, j, nonzero = 0; diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index b0897483a2..e08020dbed 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -344,7 +344,7 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma int x, y, k; int drows = dst.rows, dcols = dst.cols; int srows = src.rows, scols = src.cols; - uchar* sptr0 = src.data; + const uchar* sptr0 = src.data; int depth = src.depth(), cn = src.channels(); int elem_size = (int)src.elemSize(); int step = (int)(src.step / CV_ELEM_SIZE(depth)); diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index 034d89014b..02016fb3da 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -532,7 +532,7 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d ofs = 3, ksize = 8; Mat _extended_src_row(1, _src.cols + ksize * 2, _src.type()); - uchar* srow = _src.data + dy * _src.step; + const uchar* srow = _src.ptr(dy); memcpy(_extended_src_row.data + elemsize * ksize, srow, _src.step); for (int k = 0; k < ksize; ++k) {