1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Several type of formal refactoring:

1. someMatrix.data -> someMatrix.prt()
2. someMatrix.data + someMatrix.step * lineIndex -> someMatrix.ptr( lineIndex )
3. (SomeType*) someMatrix.data -> someMatrix.ptr<SomeType>()
4. someMatrix.data -> !someMatrix.empty() ( or !someMatrix.data -> someMatrix.empty() ) in logical expressions
This commit is contained in:
Adil Ibragimov
2014-08-13 15:08:27 +04:00
parent 30111a786a
commit 8a4a1bb018
134 changed files with 988 additions and 986 deletions
+4 -4
View File
@@ -840,9 +840,9 @@ void BackgroundSubtractorMOG2Impl::apply(InputArray _image, OutputArray _fgmask,
parallel_for_(Range(0, image.rows),
MOG2Invoker(image, fgmask,
(GMM*)bgmodel.data,
(float*)(bgmodel.data + sizeof(GMM)*nmixtures*image.rows*image.cols),
bgmodelUsedModes.data, nmixtures, (float)learningRate,
bgmodel.ptr<GMM>(),
(float*)(bgmodel.ptr() + sizeof(GMM)*nmixtures*image.rows*image.cols),
bgmodelUsedModes.ptr(), nmixtures, (float)learningRate,
(float)varThreshold,
backgroundRatio, varThresholdGen,
fVarInit, fVarMin, fVarMax, float(-learningRate*fCT), fTau,
@@ -864,7 +864,7 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage(OutputArray backgroundImag
CV_Assert(nchannels == 1 || nchannels == 3);
Mat meanBackground(frameSize, CV_MAKETYPE(CV_8U, nchannels), Scalar::all(0));
int firstGaussianIdx = 0;
const GMM* gmm = (GMM*)bgmodel.data;
const GMM* gmm = bgmodel.ptr<GMM>();
const float* mean = reinterpret_cast<const float*>(gmm + frameSize.width*frameSize.height*nmixtures);
std::vector<float> meanVal(nchannels, 0.f);
for(int row=0; row<meanBackground.rows; row++)
+1 -1
View File
@@ -84,7 +84,7 @@ const Mat& KalmanFilter::predict(const Mat& control)
// update the state: x'(k) = A*x(k)
statePre = transitionMatrix*statePost;
if( control.data )
if( !control.empty() )
// x'(k) = x'(k) + B*u(k)
statePre += controlMatrix*control;
+14 -14
View File
@@ -311,11 +311,11 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
int x, y;
for( y = 0; y < winSize.height; y++ )
{
const uchar* src = (const uchar*)I.data + (y + iprevPt.y)*stepI + iprevPt.x*cn;
const deriv_type* dsrc = (const deriv_type*)derivI.data + (y + iprevPt.y)*dstep + iprevPt.x*cn2;
const uchar* src = I.ptr() + (y + iprevPt.y)*stepI + iprevPt.x*cn;
const deriv_type* dsrc = derivI.ptr<deriv_type>() + (y + iprevPt.y)*dstep + iprevPt.x*cn2;
deriv_type* Iptr = (deriv_type*)(IWinBuf.data + y*IWinBuf.step);
deriv_type* dIptr = (deriv_type*)(derivIWinBuf.data + y*derivIWinBuf.step);
deriv_type* Iptr = IWinBuf.ptr<deriv_type>(y);
deriv_type* dIptr = derivIWinBuf.ptr<deriv_type>(y);
x = 0;
@@ -541,9 +541,9 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
for( y = 0; y < winSize.height; y++ )
{
const uchar* Jptr = (const uchar*)J.data + (y + inextPt.y)*stepJ + inextPt.x*cn;
const deriv_type* Iptr = (const deriv_type*)(IWinBuf.data + y*IWinBuf.step);
const deriv_type* dIptr = (const deriv_type*)(derivIWinBuf.data + y*derivIWinBuf.step);
const uchar* Jptr = J.ptr() + (y + inextPt.y)*stepJ + inextPt.x*cn;
const deriv_type* Iptr = IWinBuf.ptr<deriv_type>(y);
const deriv_type* dIptr = derivIWinBuf.ptr<deriv_type>(y);
x = 0;
@@ -725,8 +725,8 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
for( y = 0; y < winSize.height; y++ )
{
const uchar* Jptr = (const uchar*)J.data + (y + inextPoint.y)*stepJ + inextPoint.x*cn;
const deriv_type* Iptr = (const deriv_type*)(IWinBuf.data + y*IWinBuf.step);
const uchar* Jptr = J.ptr() + (y + inextPoint.y)*stepJ + inextPoint.x*cn;
const deriv_type* Iptr = IWinBuf.ptr<deriv_type>(y);
for( x = 0; x < winSize.width*cn; x++ )
{
@@ -1120,13 +1120,13 @@ void cv::calcOpticalFlowPyrLK( InputArray _prevImg, InputArray _nextImg,
Mat nextPtsMat = _nextPts.getMat();
CV_Assert( nextPtsMat.checkVector(2, CV_32F, true) == npoints );
const Point2f* prevPts = (const Point2f*)prevPtsMat.data;
Point2f* nextPts = (Point2f*)nextPtsMat.data;
const Point2f* prevPts = prevPtsMat.ptr<Point2f>();
Point2f* nextPts = nextPtsMat.ptr<Point2f>();
_status.create((int)npoints, 1, CV_8U, -1, true);
Mat statusMat = _status.getMat(), errMat;
CV_Assert( statusMat.isContinuous() );
uchar* status = statusMat.data;
uchar* status = statusMat.ptr();
float* err = 0;
for( i = 0; i < npoints; i++ )
@@ -1137,7 +1137,7 @@ void cv::calcOpticalFlowPyrLK( InputArray _prevImg, InputArray _nextImg,
_err.create((int)npoints, 1, CV_32F, -1, true);
errMat = _err.getMat();
CV_Assert( errMat.isContinuous() );
err = (float*)errMat.data;
err = errMat.ptr<float>();
}
std::vector<Mat> prevPyr, nextPyr;
@@ -1230,7 +1230,7 @@ void cv::calcOpticalFlowPyrLK( InputArray _prevImg, InputArray _nextImg,
{
Size imgSize = prevPyr[level * lvlStep1].size();
Mat _derivI( imgSize.height + winSize.height*2,
imgSize.width + winSize.width*2, derivIBuf.type(), derivIBuf.data );
imgSize.width + winSize.width*2, derivIBuf.type(), derivIBuf.ptr() );
derivI = _derivI(Rect(winSize.width, winSize.height, imgSize.width, imgSize.height));
calcSharrDeriv(prevPyr[level * lvlStep1], derivI);
copyMakeBorder(derivI, _derivI, winSize.height, winSize.height, winSize.width, winSize.width, BORDER_CONSTANT|BORDER_ISOLATED);
+17 -17
View File
@@ -134,8 +134,8 @@ FarnebackPolyExp( const Mat& src, Mat& dst, int n, double sigma )
for( y = 0; y < height; y++ )
{
float g0 = g[0], g1, g2;
float *srow0 = (float*)(src.data + src.step*y), *srow1 = 0;
float *drow = (float*)(dst.data + dst.step*y);
const float *srow0 = src.ptr<float>(y), *srow1 = 0;
float *drow = dst.ptr<float>(y);
// vertical part of convolution
for( x = 0; x < width; x++ )
@@ -147,8 +147,8 @@ FarnebackPolyExp( const Mat& src, Mat& dst, int n, double sigma )
for( k = 1; k <= n; k++ )
{
g0 = g[k]; g1 = xg[k]; g2 = xxg[k];
srow0 = (float*)(src.data + src.step*std::max(y-k,0));
srow1 = (float*)(src.data + src.step*std::min(y+k,height-1));
srow0 = src.ptr<float>(std::max(y-k,0));
srow1 = src.ptr<float>(std::min(y+k,height-1));
for( x = 0; x < width; x++ )
{
@@ -220,16 +220,16 @@ FarnebackUpdateMatrices( const Mat& _R0, const Mat& _R1, const Mat& _flow, Mat&
static const float border[BORDER] = {0.14f, 0.14f, 0.4472f, 0.4472f, 0.4472f};
int x, y, width = _flow.cols, height = _flow.rows;
const float* R1 = (float*)_R1.data;
const float* R1 = _R1.ptr<float>();
size_t step1 = _R1.step/sizeof(R1[0]);
matM.create(height, width, CV_32FC(5));
for( y = _y0; y < _y1; y++ )
{
const float* flow = (float*)(_flow.data + y*_flow.step);
const float* R0 = (float*)(_R0.data + y*_R0.step);
float* M = (float*)(matM.data + y*matM.step);
const float* flow = _flow.ptr<float>(y);
const float* R0 = _R0.ptr<float>(y);
float* M = matM.ptr<float>(y);
for( x = 0; x < width; x++ )
{
@@ -325,13 +325,13 @@ FarnebackUpdateFlow_Blur( const Mat& _R0, const Mat& _R1,
double* vsum = _vsum + (m+1)*5;
// init vsum
const float* srow0 = (const float*)matM.data;
const float* srow0 = matM.ptr<float>();
for( x = 0; x < width*5; x++ )
vsum[x] = srow0[x]*(m+2);
for( y = 1; y < m; y++ )
{
srow0 = (float*)(matM.data + matM.step*std::min(y,height-1));
srow0 = matM.ptr<float>(std::min(y,height-1));
for( x = 0; x < width*5; x++ )
vsum[x] += srow0[x];
}
@@ -340,10 +340,10 @@ FarnebackUpdateFlow_Blur( const Mat& _R0, const Mat& _R1,
for( y = 0; y < height; y++ )
{
double g11, g12, g22, h1, h2;
float* flow = (float*)(_flow.data + _flow.step*y);
float* flow = _flow.ptr<float>(y);
srow0 = (const float*)(matM.data + matM.step*std::max(y-m-1,0));
const float* srow1 = (const float*)(matM.data + matM.step*std::min(y+m,height-1));
srow0 = matM.ptr<float>(std::max(y-m-1,0));
const float* srow1 = matM.ptr<float>(std::min(y+m,height-1));
// vertical blur
for( x = 0; x < width*5; x++ )
@@ -447,13 +447,13 @@ FarnebackUpdateFlow_GaussianBlur( const Mat& _R0, const Mat& _R1,
for( y = 0; y < height; y++ )
{
double g11, g12, g22, h1, h2;
float* flow = (float*)(_flow.data + _flow.step*y);
float* flow = _flow.ptr<float>(y);
// vertical blur
for( i = 0; i <= m; i++ )
{
srow[m-i] = (const float*)(matM.data + matM.step*std::max(y-i,0));
srow[m+i] = (const float*)(matM.data + matM.step*std::min(y+i,height-1));
srow[m-i] = matM.ptr<float>(std::max(y-i,0));
srow[m+i] = matM.ptr<float>(std::min(y+i,height-1));
}
x = 0;
@@ -1122,7 +1122,7 @@ void cv::calcOpticalFlowFarneback( InputArray _prev0, InputArray _next0,
else
flow = flow0;
if( !prevFlow.data )
if( prevFlow.empty() )
{
if( flags & OPTFLOW_USE_INITIAL_FLOW )
{