CV_EXPORTS void error( const Exception& exc );
-typedef void (*BinaryFunc)(const uchar* src1, size_t step1,
- const uchar* src2, size_t step2,
- uchar* dst, size_t step, Size sz,
- void*);
-
-CV_EXPORTS BinaryFunc getConvertFunc(int sdepth, int ddepth);
-CV_EXPORTS BinaryFunc getConvertScaleFunc(int sdepth, int ddepth);
-CV_EXPORTS BinaryFunc getCopyMaskFunc(size_t esz);
-
//! swaps two matrices
CV_EXPORTS void swap(Mat& a, Mat& b);
double alpha = 1, double beta = 0);
//! transforms array of numbers using a lookup table: dst(i)=lut(src(i))
-CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst,
- int interpolation = 0);
+CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
//! computes sum of array elements
CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src);
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
const int* fromTo, size_t npairs);
-CV_EXPORTS void mixChannels(const std::vector<Mat>& src, std::vector<Mat>& dst,
- const int* fromTo, size_t npairs); //TODO: use arrays
+CV_EXPORTS void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
+ const int* fromTo, size_t npairs);
-CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
- const std::vector<int>& fromTo); //TODO: InputOutputArrayOfArrays
+CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
+ const std::vector<int>& fromTo);
//! extracts a single channel from src (coi is 0-based index)
CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
//! computes per-element maximum of two arrays (dst = max(src1, src2))
CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst);
-//TODO: can we drop these versions?
+// the following overloads are needed to avoid conflicts with
+// const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
//! computes per-element minimum of two arrays (dst = min(src1, src2))
CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst);
-//! computes per-element minimum of array and scalar (dst = min(src1, src2))
-CV_EXPORTS void min(const Mat& src1, double src2, Mat& dst);
//! computes per-element maximum of two arrays (dst = max(src1, src2))
CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst);
-//! computes per-element maximum of array and scalar (dst = max(src1, src2))
-CV_EXPORTS void max(const Mat& src1, double src2, Mat& dst);
//! computes square root of each matrix element (dst = src**0.5)
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst);
//! finds real and complex roots of a polynomial
CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters = 300);
-//! finds eigenvalues of a symmetric matrix
-CV_EXPORTS bool eigen(InputArray src, OutputArray eigenvalues, int lowindex = -1,
- int highindex = -1);
-
//! finds eigenvalues and eigenvectors of a symmetric matrix
-CV_EXPORTS bool eigen(InputArray src, OutputArray eigenvalues,
- OutputArray eigenvectors,
- int lowindex = -1, int highindex = -1);
-
-CV_EXPORTS_W bool eigen(InputArray src, bool computeEigenvectors,
- OutputArray eigenvalues, OutputArray eigenvectors);
+CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues,
+ OutputArray eigenvectors = noArray());
enum
{
//! computes covariation matrix of a set of samples
CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean,
- int flags, int ctype = CV_64F); //TODO: output arrays or drop
+ int flags, int ctype = CV_64F); //TODO: InputArrayOfArrays
//! computes covariation matrix of a set of samples
-CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, //TODO: InputArrayOfArrays
+CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar,
OutputArray mean, int flags, int ctype = CV_64F);
CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
//! computes Mahalanobis distance between two vectors: sqrt((v1-v2)'*icovar*(v1-v2)), where icovar is the inverse covariation matrix
CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar);
-//! a synonym for Mahalanobis
-CV_EXPORTS double Mahalonobis(InputArray v1, InputArray v2, InputArray icovar); //TODO: check if we can drop it or move to legacy
-
//! performs forward or inverse 1D or 2D Discrete Fourier Transformation
CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0);
CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev);
//! shuffles the input array elements
-CV_EXPORTS void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0);
-
-CV_EXPORTS_AS(randShuffle) void randShuffle_(InputOutputArray dst, double iterFactor = 1.);
+CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0);
enum { FILLED = -1,
LINE_4 = 4,
double fontScale, int thickness,
CV_OUT int* baseLine);
-typedef void (*ConvertData)(const void* from, void* to, int cn);
-typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alpha, double beta);
-
-//! returns the function for converting pixels from one data type to another
-CV_EXPORTS ConvertData getConvertElem(int fromType, int toType);
-
-//! returns the function for converting pixels from one data type to another with the optional scaling
-CV_EXPORTS ConvertScaleData getConvertScaleElem(int fromType, int toType);
-
-
-
/*!
Principal Component Analysis
binary_op(src1, src2, _dst, noArray(), minTab, false );
}
-void cv::max(const Mat& src1, double src2, Mat& dst)
-{
- OutputArray _dst(dst);
- binary_op(src1, src2, _dst, noArray(), maxTab, false );
-}
-
-void cv::min(const Mat& src1, double src2, Mat& dst)
-{
- OutputArray _dst(dst);
- binary_op(src1, src2, _dst, noArray(), minTab, false );
-}
/****************************************************************************************\
* add/subtract *
}
-void cv::mixChannels(const std::vector<Mat>& src, std::vector<Mat>& dst,
+void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
const int* fromTo, size_t npairs)
{
- mixChannels(!src.empty() ? &src[0] : 0, src.size(),
- !dst.empty() ? &dst[0] : 0, dst.size(), fromTo, npairs);
+ if(npairs == 0)
+ return;
+ bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
+ src.kind() != _InputArray::STD_VECTOR_VECTOR;
+ bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
+ dst.kind() != _InputArray::STD_VECTOR_VECTOR;
+ int i;
+ int nsrc = src_is_mat ? 1 : (int)src.total();
+ int ndst = dst_is_mat ? 1 : (int)dst.total();
+
+ CV_Assert(nsrc > 0 && ndst > 0);
+ cv::AutoBuffer<Mat> _buf(nsrc + ndst);
+ Mat* buf = _buf;
+ for( i = 0; i < nsrc; i++ )
+ buf[i] = src.getMat(src_is_mat ? -1 : i);
+ for( i = 0; i < ndst; i++ )
+ buf[nsrc + i] = dst.getMat(dst_is_mat ? -1 : i);
+ mixChannels(&buf[0], nsrc, &buf[nsrc], ndst, fromTo, npairs);
}
-void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
+void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
const std::vector<int>& fromTo)
{
if(fromTo.empty())
return cvtTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
}
-BinaryFunc getConvertScaleFunc(int sdepth, int ddepth)
+static BinaryFunc getConvertScaleFunc(int sdepth, int ddepth)
{
return cvtScaleTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
}
}
-void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst, int interpolation )
+void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
{
Mat src = _src.getMat(), lut = _lut.getMat();
- CV_Assert( interpolation == 0 );
int cn = src.channels();
int lutcn = lut.channels();
/////////////////// finding eigenvalues and eigenvectors of a symmetric matrix ///////////////
-bool cv::eigen( InputArray _src, bool computeEvects, OutputArray _evals, OutputArray _evects )
+bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
{
Mat src = _src.getMat();
int type = src.type();
CV_Assert (type == CV_32F || type == CV_64F);
Mat v;
- if( computeEvects )
+ if( _evects.needed() )
{
_evects.create(n, n, type);
v = _evects.getMat();
return ok;
}
-bool cv::eigen( InputArray src, OutputArray evals, int, int )
-{
- return eigen(src, false, evals, noArray());
-}
-
-bool cv::eigen( InputArray src, OutputArray evals, OutputArray evects, int, int)
-{
- return eigen(src, true, evals, evects);
-}
-
namespace cv
{
CV_IMPL void
cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double,
- int lowindex, int highindex)
+ int, int )
{
cv::Mat src = cv::cvarrToMat(srcarr), evals0 = cv::cvarrToMat(evalsarr), evals = evals0;
if( evectsarr )
{
cv::Mat evects0 = cv::cvarrToMat(evectsarr), evects = evects0;
- eigen(src, evals, evects, lowindex, highindex);
+ eigen(src, evals, evects);
if( evects0.data != evects.data )
{
uchar* p = evects0.data;
}
}
else
- eigen(src, evals, lowindex, highindex);
+ eigen(src, evals);
if( evals0.data != evals.data )
{
uchar* p = evals0.data;
return std::sqrt(result);
}
-double cv::Mahalonobis( InputArray _v1, InputArray _v2, InputArray _icovar )
-{
- return Mahalanobis(_v1, _v2, _icovar);
-}
-
/****************************************************************************************\
* MulTransposed *
\****************************************************************************************/
to[i] = saturate_cast<T2>(from[i]*alpha + beta);
}
-ConvertData getConvertElem(int fromType, int toType)
+typedef void (*ConvertData)(const void* from, void* to, int cn);
+typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alpha, double beta);
+
+static ConvertData getConvertElem(int fromType, int toType)
{
static ConvertData tab[][8] =
{{ convertData_<uchar, uchar>, convertData_<uchar, schar>,
return func;
}
-ConvertScaleData getConvertScaleElem(int fromType, int toType)
+static ConvertScaleData getConvertScaleElem(int fromType, int toType)
{
static ConvertScaleData tab[][8] =
{{ convertScaleData_<uchar, uchar>, convertScaleData_<uchar, schar>,
namespace cv
{
+typedef void (*BinaryFunc)(const uchar* src1, size_t step1,
+ const uchar* src2, size_t step2,
+ uchar* dst, size_t step, Size sz,
+ void*);
+
+BinaryFunc getConvertFunc(int sdepth, int ddepth);
+BinaryFunc getCopyMaskFunc(size_t esz);
+
/* default memory block for sparse array elements */
#define CV_SPARSE_MAT_BLOCK (1<<12)
func( dst, rng, iterFactor );
}
-void cv::randShuffle_( InputOutputArray _dst, double iterFactor )
-{
- randShuffle(_dst, iterFactor);
-}
-
CV_IMPL void
cvRandArr( CvRNG* _rng, CvArr* arr, int disttype, CvScalar param1, CvScalar param2 )
{
cv::Mat eigen_values, eigen_vectors;
- cv::eigen(src, true, eigen_values, eigen_vectors);
+ cv::eigen(src, eigen_values, eigen_vectors);
if (!check_pair_count(src, eigen_values, eigen_vectors)) return false;
if (!test_pairs(src)) return false;
- cv::eigen(src, true, eigen_values_1, eigen_vectors);
- cv::eigen(src, false, eigen_values_2, eigen_vectors);
+ cv::eigen(src, eigen_values_1, eigen_vectors);
+ cv::eigen(src, eigen_values_2);
if (!check_pair_count(src, eigen_values_2)) return false;
Mat eigenVals = new Mat();
Mat eigenVecs = new Mat();
- Core.eigen(src, true, eigenVals, eigenVecs);
+ Core.eigen(src, eigenVals, eigenVecs);
Mat expectedEigenVals = new Mat(3, 1, CvType.CV_32FC1) {
{
assertMatEqual(gray255, dst);
}
- public void testLUTMatMatMatInt() {
- Mat lut = new Mat(1, 256, CvType.CV_8UC1);
- // TODO: ban this overload
- try
- {
- Core.LUT(grayRnd, lut, dst, 1);
- fail("Last parameter for LUT was not supported");
- } catch (CvException e) {
- // expected
- }
- }
-
public void testMagnitude() {
Mat x = new Mat(1, 4, CvType.CV_32F);
Mat y = new Mat(1, 4, CvType.CV_32F);
return
for a in fi.args:
if a.ctype not in type_dict:
+ if not a.defval and a.ctype.endswith("*"):
+ a.defval = 0
+ if a.defval:
+ a.ctype = ''
+ continue
msg = "// Unknown type '%s' (%s), skipping the function\n\n" % (a.ctype, a.out or "I")
self.skipped_func_list.append(c_decl + "\n" + msg)
j_code.write( " "*4 + msg )
import hdr_parser, sys, re, os, cStringIO
from string import Template
+ignored_arg_types = ["RNG*"]
+
gen_template_check_self = Template(""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type))
return failmsgp("Incorrect type of self (must be '${name}' or its derivative)");
$cname* _self_ = ${amp}((pyopencv_${name}_t*)self)->v;
argno += 1
if a.name in self.array_counters:
continue
+ if a.tp in ignored_arg_types:
+ continue
if a.returnarg:
outlist.append((a.name, argno))
if (not a.inputarg) and a.isbig():
# form the function/method call,
# for the list of type mappings
for a in v.args:
+ if a.tp in ignored_arg_types:
+ defval = a.defval
+ if not defval and a.tp.endswith("*"):
+ defval = 0
+ assert defval
+ if not code_fcall.endswith("("):
+ code_fcall += ", "
+ code_fcall += defval
+ all_cargs.append([[None, ""], ""])
+ continue
tp1 = tp = a.tp
amp = ""
defval0 = ""
tau = _tau;
detectShadows = _detectShadows;
shadowVal = _shadowVal;
-
- cvtfunc = src->depth() != CV_32F ? getConvertFunc(src->depth(), CV_32F) : 0;
}
void operator()(const Range& range) const
for( int y = y0; y < y1; y++ )
{
const float* data = buf;
- if( cvtfunc )
- cvtfunc( src->ptr(y), src->step, 0, 0, (uchar*)data, 0, Size(ncols*nchannels, 1), 0);
+ if( src->depth() != CV_32F )
+ src->row(y).convertTo(Mat(1, ncols, CV_32FC(nchannels), (void*)data), CV_32F);
else
data = src->ptr<float>(y);
bool detectShadows;
uchar shadowVal;
-
- BinaryFunc cvtfunc;
};
void BackgroundSubtractorMOG2Impl::apply(InputArray _image, OutputArray _fgmask, double learningRate)