mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +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:
@@ -154,7 +154,7 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe
|
||||
deltas[i*2+1] = (int)(images[j].step/esz1 - imsize.width*deltas[i*2]);
|
||||
}
|
||||
|
||||
if( mask.data )
|
||||
if( !mask.empty() )
|
||||
{
|
||||
CV_Assert( mask.size() == imsize && mask.channels() == 1 );
|
||||
isContinuous = isContinuous && mask.isContinuous();
|
||||
@@ -753,7 +753,7 @@ calcHist_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
T** ptrs = (T**)&_ptrs[0];
|
||||
const int* deltas = &_deltas[0];
|
||||
uchar* H = hist.data;
|
||||
uchar* H = hist.ptr();
|
||||
int i, x;
|
||||
const uchar* mask = _ptrs[dims];
|
||||
int mstep = _deltas[dims*2 + 1];
|
||||
@@ -988,7 +988,7 @@ calcHist_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
uchar** ptrs = &_ptrs[0];
|
||||
const int* deltas = &_deltas[0];
|
||||
uchar* H = hist.data;
|
||||
uchar* H = hist.ptr();
|
||||
int x;
|
||||
const uchar* mask = _ptrs[dims];
|
||||
int mstep = _deltas[dims*2 + 1];
|
||||
@@ -1192,8 +1192,8 @@ public:
|
||||
Mat phist(hist->size(), hist->type(), Scalar::all(0));
|
||||
|
||||
IppStatus status = ippiHistogramEven_8u_C1R(
|
||||
src->data + src->step * range.start, (int)src->step, ippiSize(src->cols, range.end - range.start),
|
||||
(Ipp32s *)phist.data, (Ipp32s *)*levels, histSize, low, high);
|
||||
src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
|
||||
phist.ptr<Ipp32s>(), (Ipp32s *)*levels, histSize, low, high);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
@@ -1227,7 +1227,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
|
||||
|
||||
CV_Assert(dims > 0 && histSize);
|
||||
|
||||
uchar* histdata = _hist.getMat().data;
|
||||
const uchar* const histdata = _hist.getMat().ptr();
|
||||
_hist.create(dims, histSize, CV_32F);
|
||||
Mat hist = _hist.getMat(), ihist = hist;
|
||||
ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK)|CV_32S;
|
||||
@@ -1269,7 +1269,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
|
||||
std::vector<double> uniranges;
|
||||
Size imsize;
|
||||
|
||||
CV_Assert( !mask.data || mask.type() == CV_8UC1 );
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
|
||||
histPrepareImages( images, nimages, channels, mask, dims, hist.size, ranges,
|
||||
uniform, ptrs, deltas, imsize, uniranges );
|
||||
const double* _uniranges = uniform ? &uniranges[0] : 0;
|
||||
@@ -1442,7 +1442,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
|
||||
std::vector<double> uniranges;
|
||||
Size imsize;
|
||||
|
||||
CV_Assert( !mask.data || mask.type() == CV_8UC1 );
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
|
||||
histPrepareImages( images, nimages, channels, mask, dims, hist.hdr->size, ranges,
|
||||
uniform, ptrs, deltas, imsize, uniranges );
|
||||
const double* _uniranges = uniform ? &uniranges[0] : 0;
|
||||
@@ -1586,7 +1586,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
T** ptrs = (T**)&_ptrs[0];
|
||||
const int* deltas = &_deltas[0];
|
||||
uchar* H = hist.data;
|
||||
const uchar* H = hist.ptr();
|
||||
int i, x;
|
||||
BT* bproj = (BT*)_ptrs[dims];
|
||||
int bpstep = _deltas[dims*2 + 1];
|
||||
@@ -1614,7 +1614,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
for( x = 0; x < imsize.width; x++, p0 += d0 )
|
||||
{
|
||||
int idx = cvFloor(*p0*a + b);
|
||||
bproj[x] = (unsigned)idx < (unsigned)sz ? saturate_cast<BT>(((float*)H)[idx]*scale) : 0;
|
||||
bproj[x] = (unsigned)idx < (unsigned)sz ? saturate_cast<BT>(((const float*)H)[idx]*scale) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1637,7 +1637,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
int idx1 = cvFloor(*p1*a1 + b1);
|
||||
bproj[x] = (unsigned)idx0 < (unsigned)sz0 &&
|
||||
(unsigned)idx1 < (unsigned)sz1 ?
|
||||
saturate_cast<BT>(((float*)(H + hstep0*idx0))[idx1]*scale) : 0;
|
||||
saturate_cast<BT>(((const float*)(H + hstep0*idx0))[idx1]*scale) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1665,7 +1665,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
bproj[x] = (unsigned)idx0 < (unsigned)sz0 &&
|
||||
(unsigned)idx1 < (unsigned)sz1 &&
|
||||
(unsigned)idx2 < (unsigned)sz2 ?
|
||||
saturate_cast<BT>(((float*)(H + hstep0*idx0 + hstep1*idx1))[idx2]*scale) : 0;
|
||||
saturate_cast<BT>(((const float*)(H + hstep0*idx0 + hstep1*idx1))[idx2]*scale) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1675,7 +1675,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
for( x = 0; x < imsize.width; x++ )
|
||||
{
|
||||
uchar* Hptr = H;
|
||||
const uchar* Hptr = H;
|
||||
for( i = 0; i < dims; i++ )
|
||||
{
|
||||
int idx = cvFloor(*ptrs[i]*uniranges[i*2] + uniranges[i*2+1]);
|
||||
@@ -1686,7 +1686,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
}
|
||||
|
||||
if( i == dims )
|
||||
bproj[x] = saturate_cast<BT>(*(float*)Hptr*scale);
|
||||
bproj[x] = saturate_cast<BT>(*(const float*)Hptr*scale);
|
||||
else
|
||||
{
|
||||
bproj[x] = 0;
|
||||
@@ -1710,7 +1710,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
for( x = 0; x < imsize.width; x++ )
|
||||
{
|
||||
uchar* Hptr = H;
|
||||
const uchar* Hptr = H;
|
||||
for( i = 0; i < dims; i++ )
|
||||
{
|
||||
float v = (float)*ptrs[i];
|
||||
@@ -1728,7 +1728,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
}
|
||||
|
||||
if( i == dims )
|
||||
bproj[x] = saturate_cast<BT>(*(float*)Hptr*scale);
|
||||
bproj[x] = saturate_cast<BT>(*(const float*)Hptr*scale);
|
||||
else
|
||||
{
|
||||
bproj[x] = 0;
|
||||
@@ -1751,7 +1751,7 @@ calcBackProj_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
uchar** ptrs = &_ptrs[0];
|
||||
const int* deltas = &_deltas[0];
|
||||
uchar* H = hist.data;
|
||||
const uchar* H = hist.ptr();
|
||||
int i, x;
|
||||
uchar* bproj = _ptrs[dims];
|
||||
int bpstep = _deltas[dims*2 + 1];
|
||||
@@ -1813,7 +1813,7 @@ calcBackProj_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
for( x = 0; x < imsize.width; x++, p0 += d0, p1 += d1 )
|
||||
{
|
||||
size_t idx = tab[*p0] + tab[*p1 + 256];
|
||||
bproj[x] = idx < OUT_OF_RANGE ? saturate_cast<uchar>(*(float*)(H + idx)*scale) : 0;
|
||||
bproj[x] = idx < OUT_OF_RANGE ? saturate_cast<uchar>(*(const float*)(H + idx)*scale) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1831,7 +1831,7 @@ calcBackProj_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
for( x = 0; x < imsize.width; x++, p0 += d0, p1 += d1, p2 += d2 )
|
||||
{
|
||||
size_t idx = tab[*p0] + tab[*p1 + 256] + tab[*p2 + 512];
|
||||
bproj[x] = idx < OUT_OF_RANGE ? saturate_cast<uchar>(*(float*)(H + idx)*scale) : 0;
|
||||
bproj[x] = idx < OUT_OF_RANGE ? saturate_cast<uchar>(*(const float*)(H + idx)*scale) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1841,7 +1841,7 @@ calcBackProj_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
{
|
||||
for( x = 0; x < imsize.width; x++ )
|
||||
{
|
||||
uchar* Hptr = H;
|
||||
const uchar* Hptr = H;
|
||||
for( i = 0; i < dims; i++ )
|
||||
{
|
||||
size_t idx = tab[*ptrs[i] + i*256];
|
||||
@@ -1852,7 +1852,7 @@ calcBackProj_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
|
||||
}
|
||||
|
||||
if( i == dims )
|
||||
bproj[x] = saturate_cast<uchar>(*(float*)Hptr*scale);
|
||||
bproj[x] = saturate_cast<uchar>(*(const float*)Hptr*scale);
|
||||
else
|
||||
{
|
||||
bproj[x] = 0;
|
||||
@@ -1879,7 +1879,7 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
|
||||
Size imsize;
|
||||
int dims = hist.dims == 2 && hist.size[1] == 1 ? 1 : hist.dims;
|
||||
|
||||
CV_Assert( dims > 0 && hist.data );
|
||||
CV_Assert( dims > 0 && !hist.empty() );
|
||||
_backProject.create( images[0].size(), images[0].depth() );
|
||||
Mat backProject = _backProject.getMat();
|
||||
histPrepareImages( images, nimages, channels, backProject, dims, hist.size, ranges,
|
||||
@@ -2233,7 +2233,7 @@ void cv::calcBackProject( InputArrayOfArrays images, const std::vector<int>& cha
|
||||
int hsz[CV_CN_MAX+1];
|
||||
memcpy(hsz, &H0.size[0], H0.dims*sizeof(hsz[0]));
|
||||
hsz[H0.dims] = hcn;
|
||||
H = Mat(H0.dims+1, hsz, H0.depth(), H0.data);
|
||||
H = Mat(H0.dims+1, hsz, H0.depth(), H0.ptr());
|
||||
}
|
||||
else
|
||||
H = H0;
|
||||
@@ -2281,8 +2281,8 @@ double cv::compareHist( InputArray _H1, InputArray _H2, int method )
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
const float* h1 = (const float*)it.planes[0].data;
|
||||
const float* h2 = (const float*)it.planes[1].data;
|
||||
const float* h1 = it.planes[0].ptr<float>();
|
||||
const float* h2 = it.planes[1].ptr<float>();
|
||||
len = it.planes[0].rows*it.planes[0].cols*H1.channels();
|
||||
|
||||
if( (method == CV_COMP_CHISQR) || (method == CV_COMP_CHISQR_ALT))
|
||||
|
||||
Reference in New Issue
Block a user