a big patch; use special proxy types (Input/OutputArray, Input/OutputArrayOfArrays) for passing in vectors, matrices etc.
This commit is contained in:
@@ -111,16 +111,16 @@ void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
|
||||
namespace cv
|
||||
{
|
||||
|
||||
static void getScharrKernels( Mat& kx, Mat& ky, int dx, int dy, bool normalize, int ktype )
|
||||
static void getScharrKernels( OutputArray _kx, OutputArray _ky,
|
||||
int dx, int dy, bool normalize, int ktype )
|
||||
{
|
||||
const int ksize = 3;
|
||||
|
||||
CV_Assert( ktype == CV_32F || ktype == CV_64F );
|
||||
|
||||
if( kx.cols != ksize || kx.rows != 1 || kx.type() != ktype )
|
||||
kx.create( ksize, 1, ktype );
|
||||
if( ky.cols != ksize || ky.rows != 1 || ky.type() != ktype )
|
||||
ky.create( ksize, 1, ktype );
|
||||
_kx.create(ksize, 1, ktype, -1, true);
|
||||
_ky.create(ksize, 1, ktype, -1, true);
|
||||
Mat kx = _kx.getMat();
|
||||
Mat ky = _ky.getMat();
|
||||
|
||||
CV_Assert( dx >= 0 && dy >= 0 && dx+dy == 1 );
|
||||
|
||||
@@ -142,7 +142,8 @@ static void getScharrKernels( Mat& kx, Mat& ky, int dx, int dy, bool normalize,
|
||||
}
|
||||
|
||||
|
||||
static void getSobelKernels( Mat& kx, Mat& ky, int dx, int dy, int _ksize, bool normalize, int ktype )
|
||||
static void getSobelKernels( OutputArray _kx, OutputArray _ky,
|
||||
int dx, int dy, int _ksize, bool normalize, int ktype )
|
||||
{
|
||||
int i, j, ksizeX = _ksize, ksizeY = _ksize;
|
||||
if( ksizeX == 1 && dx > 0 )
|
||||
@@ -152,10 +153,10 @@ static void getSobelKernels( Mat& kx, Mat& ky, int dx, int dy, int _ksize, bool
|
||||
|
||||
CV_Assert( ktype == CV_32F || ktype == CV_64F );
|
||||
|
||||
if( kx.cols != ksizeX || kx.rows != 1 || kx.type() != ktype )
|
||||
kx.create( ksizeX, 1, ktype );
|
||||
if( ky.cols != ksizeY || ky.rows != 1 || ky.type() != ktype )
|
||||
ky.create( ksizeY, 1, ktype );
|
||||
_kx.create(ksizeX, 1, ktype, -1, true);
|
||||
_ky.create(ksizeY, 1, ktype, -1, true);
|
||||
Mat kx = _kx.getMat();
|
||||
Mat ky = _ky.getMat();
|
||||
|
||||
if( _ksize % 2 == 0 || _ksize > 31 )
|
||||
CV_Error( CV_StsOutOfRange, "The kernel size must be odd and not larger than 31" );
|
||||
@@ -218,9 +219,10 @@ static void getSobelKernels( Mat& kx, Mat& ky, int dx, int dy, int _ksize, bool
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void getDerivKernels( Mat& kx, Mat& ky, int dx, int dy,
|
||||
int ksize, bool normalize, int ktype )
|
||||
void cv::getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy,
|
||||
int ksize, bool normalize, int ktype )
|
||||
{
|
||||
if( ksize <= 0 )
|
||||
getScharrKernels( kx, ky, dx, dy, normalize, ktype );
|
||||
@@ -229,8 +231,8 @@ void getDerivKernels( Mat& kx, Mat& ky, int dx, int dy,
|
||||
}
|
||||
|
||||
|
||||
Ptr<FilterEngine> createDerivFilter(int srcType, int dstType,
|
||||
int dx, int dy, int ksize, int borderType )
|
||||
cv::Ptr<cv::FilterEngine> cv::createDerivFilter(int srcType, int dstType,
|
||||
int dx, int dy, int ksize, int borderType )
|
||||
{
|
||||
Mat kx, ky;
|
||||
getDerivKernels( kx, ky, dx, dy, ksize, false, CV_32F );
|
||||
@@ -238,9 +240,11 @@ Ptr<FilterEngine> createDerivFilter(int srcType, int dstType,
|
||||
kx, ky, Point(-1,-1), 0, borderType );
|
||||
}
|
||||
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy, double scale)
|
||||
{
|
||||
int bufSize = 0;
|
||||
@@ -344,9 +348,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
|
||||
if(ksize == 3 || ksize == 5)
|
||||
{
|
||||
if( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
|
||||
dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
ddepth = src.depth();
|
||||
|
||||
if(src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
|
||||
{
|
||||
@@ -462,21 +464,25 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
|
||||
return IPPDerivScharr(src, dst, ddepth, dx, dy, scale);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void Sobel( const Mat& src, Mat& dst, int ddepth, int dx, int dy,
|
||||
int ksize, double scale, double delta, int borderType )
|
||||
void cv::Sobel( const InputArray& _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
int ksize, double scale, double delta, int borderType )
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
if(dx < 3 && dy < 3 && src.channels() == 1 && borderType == 1)
|
||||
{
|
||||
if(IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale) == true)
|
||||
return;
|
||||
}
|
||||
if(dx < 3 && dy < 3 && src.channels() == 1 && borderType == 1)
|
||||
{
|
||||
if(IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, src.depth()));
|
||||
|
||||
@@ -495,15 +501,19 @@ void Sobel( const Mat& src, Mat& dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
|
||||
|
||||
void Scharr( const Mat& src, Mat& dst, int ddepth, int dx, int dy,
|
||||
double scale, double delta, int borderType )
|
||||
void cv::Scharr( const InputArray& _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
double scale, double delta, int borderType )
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
if(dx < 2 && dy < 2 && src.channels() == 1 && borderType == 1)
|
||||
{
|
||||
if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale) == true)
|
||||
return;
|
||||
}
|
||||
if(dx < 2 && dy < 2 && src.channels() == 1 && borderType == 1)
|
||||
{
|
||||
if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, src.depth()));
|
||||
|
||||
@@ -522,9 +532,13 @@ void Scharr( const Mat& src, Mat& dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
|
||||
|
||||
void Laplacian( const Mat& src, Mat& dst, int ddepth, int ksize,
|
||||
double scale, double delta, int borderType )
|
||||
void cv::Laplacian( const InputArray& _src, OutputArray _dst, int ddepth, int ksize,
|
||||
double scale, double delta, int borderType )
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
if( ksize == 1 || ksize == 3 )
|
||||
{
|
||||
float K[2][9] =
|
||||
@@ -548,7 +562,6 @@ void Laplacian( const Mat& src, Mat& dst, int ddepth, int ksize,
|
||||
if( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
int dtype = CV_MAKETYPE(ddepth, src.channels());
|
||||
dst.create( src.size(), dtype );
|
||||
|
||||
int dy0 = std::min(std::max((int)(STRIPE_SIZE/(getElemSize(src.type())*src.cols)), 1), src.rows);
|
||||
Ptr<FilterEngine> fx = createSeparableLinearFilter(src.type(),
|
||||
@@ -578,8 +591,6 @@ void Laplacian( const Mat& src, Mat& dst, int ddepth, int ksize,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CV_IMPL void
|
||||
|
Reference in New Issue
Block a user