Skip to content

Commit

Permalink
Cleanup the library
Browse files Browse the repository at this point in the history
  • Loading branch information
cv3d committed Sep 22, 2018
1 parent 1a5f1e9 commit 8061468
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 173 deletions.
8 changes: 4 additions & 4 deletions modules/core/include/opencv2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ the sum of a scaled array and another array:
\f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\f]
The function can also be emulated with a matrix expression, for example:
@code{.cpp}
Mat A(3, 3, CV_64F);
Mat A(3, 3, CV_64FC1);
...
A.row(0) = A.row(1)*2 + A.row(2);
@endcode
Expand Down Expand Up @@ -1895,7 +1895,7 @@ The function cv::setIdentity initializes a scaled identity matrix:
The function can also be emulated using the matrix initializers and the
matrix expressions:
@code
Mat A = Mat::eye(4, 3, CV_32F)*5;
Mat A = Mat::eye(4, 3, CV_32FC1)*5;
// A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
@endcode
@param mtx matrix to initialize (not necessarily square).
Expand Down Expand Up @@ -2002,7 +2002,7 @@ ascending or descending order. So you should pass two operation flags to
get desired behaviour. Instead of reordering the elements themselves, it
stores the indices of sorted elements in the output array. For example:
@code
Mat A = Mat::eye(3,3,CV_32F), B;
Mat A = Mat::eye(3,3,CV_32FC1), B;
sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
// B will probably contain
// (because of equal elements in A some permutations are possible):
Expand Down Expand Up @@ -3127,7 +3127,7 @@ and groups the input samples around the clusters. As an output, \f$\texttt{label
opencv_source_code/samples/python/kmeans.py
@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
Examples of this array can be:
- Mat points(count, 2, CV_32F);
- Mat points(count, 2, CV_32FC1);
- Mat points(count, 1, CV_32FC2);
- Mat points(1, count, CV_32FC2);
- std::vector\<cv::Point2f\> points(sampleCount);
Expand Down
6 changes: 3 additions & 3 deletions modules/core/include/opencv2/core/core_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ Below are the two samples from the cvReshape description rewritten using cvResha
gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0);
...
int size[] = { 2, 2, 2 };
CvMatND* mat = cvCreateMatND(3, size, CV_32F);
CvMatND* mat = cvCreateMatND(3, size, CV_32FC1);
CvMat row_header, *row;
row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0);
@endcode
Expand Down Expand Up @@ -853,7 +853,7 @@ The following example code creates one image buffer and two image headers, the f
@endcode
And the next example converts a 3x3 matrix to a single 1x9 vector:
@code
CvMat* mat = cvCreateMat(3, 3, CV_32F);
CvMat* mat = cvCreateMat(3, 3, CV_32FC1);
CvMat row_header, *row;
row = cvReshape(mat, &row_header, 0, 1);
@endcode
Expand Down Expand Up @@ -2132,7 +2132,7 @@ Below is the code that creates the YAML file shown in the CvFileStorage descript
int main( int argc, char** argv )
{
CvMat* mat = cvCreateMat( 3, 3, CV_32F );
CvMat* mat = cvCreateMat( 3, 3, CV_32FC1);
CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE );
cvSetIdentity( mat );
Expand Down
26 changes: 13 additions & 13 deletions modules/core/include/opencv2/core/mat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ it, according to the assertion statement inside) :
// get Mat headers for input arrays. This is O(1) operation,
// unless _src and/or _m are matrix expressions.
Mat src = _src.getMat(), m = _m.getMat();
CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) );
CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32FC1 && m.size() == Size(3, 2) );
// [re]create the output array so that it has the proper size and type.
// In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize.
Expand Down Expand Up @@ -732,7 +732,7 @@ or type of the current array are different from the specified ones.
@code
// create a 100x100x100 8-bit array
int sz[] = {100, 100, 100};
Mat bigCube(3, sz, CV_8U, Scalar::all(0));
Mat bigCube(3, sz, CV_8UC1, Scalar::all(0));
@endcode
It passes the number of dimensions =1 to the Mat constructor but the created array will be
2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0
Expand Down Expand Up @@ -765,7 +765,7 @@ actually modify a part of the array using this feature, for example:
Due to the additional datastart and dataend members, it is possible to compute a relative
sub-array position in the main *container* array using locateROI():
@code
Mat A = Mat::eye(10, 10, CV_32S);
Mat A = Mat::eye(10, 10, CV_32SC1);
// extracts A columns, 1 (inclusive) to 3 (exclusive).
Mat B = A(Range::all(), Range(1, 3));
// extracts B rows, 5 (inclusive) to 9 (exclusive).
Expand All @@ -792,7 +792,7 @@ sub-matrices.
-# Quickly initialize small matrices and/or get a super-fast element access.
@code
double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}};
Mat M = Mat(3, 3, CV_64F, m).inv();
Mat M = Mat(3, 3, CV_64FC1, m).inv();
@endcode
.
Partial yet very common cases of this *user-allocated data* case are conversions from CvMat and
Expand All @@ -803,7 +803,7 @@ sub-matrices.
- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example:
@code
// create a double-precision identity matrix and add it to M.
M += Mat::eye(M.rows, M.cols, CV_64F);
M += Mat::eye(M.rows, M.cols, CV_64FC1);
@endcode
- Use a comma-separated initializer:
Expand Down Expand Up @@ -1602,7 +1602,7 @@ class CV_EXPORTS Mat
array as a function parameter, part of a matrix expression, or as a matrix initializer:
@code
Mat A;
A = Mat::zeros(3, 3, CV_32F);
A = Mat::zeros(3, 3, CV_32FC1);
@endcode
In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix.
Otherwise, the existing matrix A is filled with zeros.
Expand Down Expand Up @@ -1648,7 +1648,7 @@ class CV_EXPORTS Mat
The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using
this method you can initialize an array with an arbitrary value, using the following Matlab idiom:
@code
Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.
Mat A = Mat::ones(100, 100, CV_8UC1)*3; // make 100x100 matrix filled with 3.
@endcode
The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it
just remembers the scale factor (3 in this case) and use it when actually invoking the matrix
Expand Down Expand Up @@ -1698,7 +1698,7 @@ class CV_EXPORTS Mat
Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently:
@code
// make a 4x4 diagonal matrix with 0.1's on the diagonal.
Mat A = Mat::eye(4, 4, CV_32F)*0.1;
Mat A = Mat::eye(4, 4, CV_32FC1)*0.1;
@endcode
@note In case of multi-channels type, identity matrix will be initialized only for the first channel,
the others will be set to 0's
Expand Down Expand Up @@ -2267,7 +2267,7 @@ class CV_EXPORTS Mat
The example below initializes a Hilbert matrix:
@code
Mat H(100, 100, CV_64F);
Mat H(100, 100, CV_64FC1);
for(int i = 0; i < H.rows; i++)
for(int j = 0; j < H.cols; j++)
H.at<double>(i,j)=1./(i+j+1);
Expand Down Expand Up @@ -2516,7 +2516,7 @@ extra data fields. Nor this class nor Mat has any virtual methods. Thus, referen
these two classes can be freely but carefully converted one to another. For example:
@code{.cpp}
// create a 100x100 8-bit matrix
Mat M(100,100,CV_8U);
Mat M(100,100,CV_8UC1);
// this will be compiled fine. no any data conversion will be done.
Mat_<float>& M1 = (Mat_<float>&)M;
// the program is likely to crash at the statement below
Expand Down Expand Up @@ -3244,7 +3244,7 @@ Elements can be accessed using the following methods:
@code
const int dims = 5;
int size[5] = {10, 10, 10, 10, 10};
SparseMat sparse_mat(dims, size, CV_32F);
SparseMat sparse_mat(dims, size, CV_32FC1);
for(int i = 0; i < 1000; i++)
{
int idx[dims];
Expand Down Expand Up @@ -3908,7 +3908,7 @@ class MatIterator_ : public MatConstIterator_<_Tp>
\code
SparseMatConstIterator it = m.begin(), it_end = m.end();
double s = 0;
CV_Assert( m.type() == CV_32F );
CV_Assert( m.type() == CV_32FC1 );
for( ; it != it_end; ++it )
s += it.value<float>();
\endcode
Expand Down Expand Up @@ -4071,7 +4071,7 @@ The example below illustrates how you can compute a normalized and threshold 3D
const int histSize[] = {N, N, N};
// make sure that the histogram has a proper size and type
hist.create(3, histSize, CV_32F);
hist.create(3, histSize, CV_32FC1);
// and clear it
hist = Scalar(0);
Expand Down
26 changes: 13 additions & 13 deletions modules/core/src/arithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,

if( haveMask )
{
int mtype = _mask.type();
CV_Assert( (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1));
ElemType mtype = _mask.type();
CV_Assert((mtype == CV_8UC1 || mtype == CV_8SC1) && _mask.sameSize(*psrc1));
copymask = getCopyMaskFunc(esz);
reallocate = !_dst.sameSize(*psrc1) || _dst.type() != type1;
}
Expand Down Expand Up @@ -672,7 +672,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
"(where arrays have the same size and the same number of channels), "
"nor 'array op scalar', nor 'scalar op array'" );
haveScalar = true;
CV_Assert(type2 == CV_64F && (sz2.height == 1 || sz2.height == 4));
CV_Assert(type2 == CV_64FC1 && (sz2.height == 1 || sz2.height == 4));

if (!muldiv)
{
Expand Down Expand Up @@ -1160,7 +1160,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
else
return dst.setTo(Scalar::all(op == CMP_NE ? 255 : 0)), true;
}
convertAndUnrollScalar(Mat(1, 1, CV_32S, &ival), depth1, (uchar *)buf, kercn);
convertAndUnrollScalar(Mat(1, 1, CV_32SC1, &ival), depth1, (uchar *)buf, kercn);
}

ocl::KernelArg scalararg = ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, esz);
Expand Down Expand Up @@ -1303,7 +1303,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
return;
}
}
convertAndUnrollScalar(Mat(1, 1, CV_32S, &ival), depth1, buf, blocksize);
convertAndUnrollScalar(Mat(1, 1, CV_32SC1, &ival), depth1, buf, blocksize);
}

for( size_t i = 0; i < it.nplanes; i++, ++it )
Expand Down Expand Up @@ -1678,8 +1678,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
if( ilbuf[k] > iubuf[k] || ilbuf[k] > maxval || iubuf[k] < minval )
ilbuf[k] = minval+1, iubuf[k] = minval;
}
lscalar = Mat(cn, 1, CV_32S, ilbuf);
uscalar = Mat(cn, 1, CV_32S, iubuf);
lscalar = Mat(cn, 1, CV_32SC1, ilbuf);
uscalar = Mat(cn, 1, CV_32SC1, iubuf);
}

lscalar.convertTo(lscalar, sdepth);
Expand Down Expand Up @@ -1794,8 +1794,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
if( ilbuf[k] > iubuf[k] || ilbuf[k] > maxval || iubuf[k] < minval )
ilbuf[k] = minval+1, iubuf[k] = minval;
}
lb = Mat(cn, 1, CV_32S, ilbuf);
ub = Mat(cn, 1, CV_32S, iubuf);
lb = Mat(cn, 1, CV_32SC1, ilbuf);
ub = Mat(cn, 1, CV_32SC1, iubuf);
}

convertAndUnrollScalar( lb, src.type(), lbuf, blocksize );
Expand Down Expand Up @@ -2016,7 +2016,7 @@ cvInRange( const void* srcarr1, const void* srcarr2,
const void* srcarr3, void* dstarr )
{
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 );

cv::inRange( src1, cv::cvarrToMat(srcarr2), cv::cvarrToMat(srcarr3), dst );
}
Expand All @@ -2026,7 +2026,7 @@ CV_IMPL void
cvInRangeS( const void* srcarr1, CvScalar lowerb, CvScalar upperb, void* dstarr )
{
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 );

cv::inRange( src1, (const cv::Scalar&)lowerb, (const cv::Scalar&)upperb, dst );
}
Expand All @@ -2036,7 +2036,7 @@ CV_IMPL void
cvCmp( const void* srcarr1, const void* srcarr2, void* dstarr, int cmp_op )
{
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 );

cv::compare( src1, cv::cvarrToMat(srcarr2), dst, cmp_op );
}
Expand All @@ -2046,7 +2046,7 @@ CV_IMPL void
cvCmpS( const void* srcarr1, double value, void* dstarr, int cmp_op )
{
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 );

cv::compare( src1, value, dst, cmp_op );
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/batch_distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
ElemType type = src1.type();
CV_Assert( type == src2.type() && src1.cols == src2.cols &&
(type == CV_32F || type == CV_8U));
(type == CV_32FC1 || type == CV_8UC1));
CV_Assert( _nidx.needed() == (K > 0) );

if( ddepth == CV_DEPTH_AUTO )
Expand All @@ -287,7 +287,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
Mat dist = _dist.getMat(), nidx;
if( _nidx.needed() )
{
_nidx.create(dist.size(), CV_32S);
_nidx.create(dist.size(), CV_32SC1);
nidx = _nidx.getMat();
}

Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/conjugate_gradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace cv


if(x_mat.rows>1){
Mat(ndim, 1, CV_64F, proxy_x.ptr<double>()).copyTo(x);
Mat(ndim, 1, CV_64FC1, proxy_x.ptr<double>()).copyTo(x);
}
return _Function->calc(proxy_x.ptr<double>());
}
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/directx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,8 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
D3D10_TEXTURE2D_DESC desc = { 0 };
pD3D10Texture2D->GetDesc(&desc);

int textureType = getTypeFromDXGI_FORMAT(desc.Format);
CV_Assert(textureType >= 0);
ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format);
CV_Assert(textureType >= CV_8UC1);

using namespace cv::ocl;
Context& ctx = Context::getDefault();
Expand Down Expand Up @@ -1232,8 +1232,8 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: Can't get D3D surface description");
}

int surfaceType = getTypeFromD3DFORMAT(desc.Format);
CV_Assert(surfaceType >= 0);
ElemType surfaceType = getTypeFromD3DFORMAT(desc.Format);
CV_Assert(surfaceType >= CV_8UC1);

using namespace cv::ocl;
Context& ctx = Context::getDefault();
Expand Down
14 changes: 7 additions & 7 deletions modules/core/src/downhill_simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver

if( !x.empty() )
{
Mat simplex_0m(x.rows, x.cols, CV_64F, simplex.ptr<double>());
simplex_0m.convertTo(x, x.type());
Mat simplex_0m(x.rows, x.cols, CV_64FC1, simplex.ptr<double>());
simplex_0m.convertTo(x, x.depth());
}
else
{
Expand Down Expand Up @@ -238,12 +238,12 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver
CV_Assert( _Function->getDims() == ndim );
Mat x = x0;
if( x0.empty() )
x = Mat::zeros(1, ndim, CV_64F);
x = Mat::zeros(1, ndim, CV_64FC1);
CV_Assert( (x.cols == 1 && x.rows == ndim) || (x.cols == ndim && x.rows == 1) );
CV_Assert( x.type() == CV_32F || x.type() == CV_64F );
CV_Assert(x.type() == CV_32FC1 || x.type() == CV_64FC1);

simplex.create(ndim + 1, ndim, CV_64F);
Mat simplex_0m(x.rows, x.cols, CV_64F, simplex.ptr<double>());
simplex.create(ndim + 1, ndim, CV_64FC1);
Mat simplex_0m(x.rows, x.cols, CV_64FC1, simplex.ptr<double>());

x.convertTo(simplex_0m, CV_64F);
double* simplex_0 = simplex.ptr<double>();
Expand Down Expand Up @@ -272,7 +272,7 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver
double innerDownhillSimplex( Mat& p, double MinRange, double MinError, int& fcount, int nmax )
{
int i, j, ndim = p.cols;
Mat coord_sum(1, ndim, CV_64F), buf(1, ndim, CV_64F), y(1, ndim+1, CV_64F);
Mat coord_sum(1, ndim, CV_64FC1), buf(1, ndim, CV_64FC1), y(1, ndim + 1, CV_64FC1);
double* y_ = y.ptr<double>();

fcount = ndim+1;
Expand Down
Loading

0 comments on commit 8061468

Please sign in to comment.