cv::warpPerspective and cv::warpAffine

This commit is contained in:
Ilya Lavrenov 2014-04-03 23:39:01 +04:00
parent 5600bc54f4
commit f1b38c4198
2 changed files with 200 additions and 155 deletions

View File

@ -177,12 +177,16 @@ macro(ipp_set_variables _LATEST_VERSION)
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/intel64) if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
message(SEND_ERROR "Intel compiler EM64T libraries not found") message(SEND_ERROR "Intel compiler EM64T libraries not found")
endif() endif()
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/intel64) if(NOT APPLE)
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
endif()
else() else()
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/ia32) if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
message(SEND_ERROR "Intel compiler IA32 libraries not found") message(SEND_ERROR "Intel compiler IA32 libraries not found")
endif() endif()
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/ia32) if (NOT APLLE)
set(INTEL_COMPILER_LIBRARY_DIR ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
endif()
endif() endif()
list(APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}irc${CMAKE_SHARED_LIBRARY_SUFFIX}) list(APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}irc${CMAKE_SHARED_LIBRARY_SUFFIX})
list(APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}imf${CMAKE_SHARED_LIBRARY_SUFFIX}) list(APPEND IPP_LIBRARIES ${INTEL_COMPILER_LIBRARY_DIR}/${IPP_LIB_PREFIX}imf${CMAKE_SHARED_LIBRARY_SUFFIX})

View File

@ -63,7 +63,7 @@ namespace cv
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
typedef IppStatus (CV_STDCALL* ippiSetFunc)(const void*, void *, int, IppiSize); typedef IppStatus (CV_STDCALL* ippiSetFunc)(const void*, void *, int, IppiSize);
typedef IppStatus (CV_STDCALL* ippiWarpPerspectiveBackFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [3][3], int); typedef IppStatus (CV_STDCALL* ippiWarpPerspectiveFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [3][3], int);
typedef IppStatus (CV_STDCALL* ippiWarpAffineBackFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [2][3], int); typedef IppStatus (CV_STDCALL* ippiWarpAffineBackFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [2][3], int);
template <int channels, typename Type> template <int channels, typename Type>
@ -75,7 +75,7 @@ namespace cv
return func(values, dataPointer, step, size) >= 0; return func(values, dataPointer, step, size) >= 0;
} }
bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, int depth) static bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, int depth)
{ {
if( channels == 1 ) if( channels == 1 )
{ {
@ -3892,11 +3892,11 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
namespace cv namespace cv
{ {
class warpAffineInvoker : class WarpAffineInvoker :
public ParallelLoopBody public ParallelLoopBody
{ {
public: public:
warpAffineInvoker(const Mat &_src, Mat &_dst, int _interpolation, int _borderType, WarpAffineInvoker(const Mat &_src, Mat &_dst, int _interpolation, int _borderType,
const Scalar &_borderValue, int *_adelta, int *_bdelta, double *_M) : const Scalar &_borderValue, int *_adelta, int *_bdelta, double *_M) :
ParallelLoopBody(), src(_src), dst(_dst), interpolation(_interpolation), ParallelLoopBody(), src(_src), dst(_dst), interpolation(_interpolation),
borderType(_borderType), borderValue(_borderValue), adelta(_adelta), bdelta(_bdelta), borderType(_borderType), borderValue(_borderValue), adelta(_adelta), bdelta(_bdelta),
@ -4013,48 +4013,57 @@ private:
double *M; double *M;
}; };
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) /*
class IPPwarpAffineInvoker : #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 IPP_VERSION_MINOR >= 1
public ParallelLoopBody class IPPWarpAffineInvoker :
public ParallelLoopBody
{ {
public: public:
IPPwarpAffineInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[2][3], int &_interpolation, int &_borderType, const Scalar &_borderValue, ippiWarpAffineBackFunc _func, bool *_ok) : IPPWarpAffineInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[2][3], int &_interpolation, int _borderType,
ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok) const Scalar &_borderValue, ippiWarpAffineBackFunc _func, bool *_ok) :
{ ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs),
*ok = true; borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok)
} {
*ok = true;
}
virtual void operator() (const Range& range) const virtual void operator() (const Range& range) const
{ {
IppiSize srcsize = { src.cols, src.rows }; IppiSize srcsize = { src.cols, src.rows };
IppiRect srcroi = { 0, 0, src.cols, src.rows }; IppiRect srcroi = { 0, 0, src.cols, src.rows };
IppiRect dstroi = { 0, range.start, dst.cols, range.end - range.start }; IppiRect dstroi = { 0, range.start, dst.cols, range.end - range.start };
int cnn = src.channels(); int cnn = src.channels();
if( borderType == BORDER_CONSTANT ) if( borderType == BORDER_CONSTANT )
{ {
IppiSize setSize = { dst.cols, range.end - range.start }; IppiSize setSize = { dst.cols, range.end - range.start };
void *dataPointer = dst.data + dst.step[0] * range.start; void *dataPointer = dst.data + dst.step[0] * range.start;
if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) ) if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) )
{ {
*ok = false; *ok = false;
return; return;
} }
} }
if( func( src.data, srcsize, (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, coeffs, mode ) < 0) ////Aug 2013: problem in IPP 7.1, 8.0 : sometimes function return ippStsCoeffErr
*ok = false; ////Aug 2013: problem in IPP 7.1, 8.0 : sometimes function return ippStsCoeffErr
} IppStatus status = func( src.data, srcsize, (int)src.step[0], srcroi, dst.data,
(int)dst.step[0], dstroi, coeffs, mode );
printf("%d\n", status);
if( status != ippStsNoErr)
*ok = false;
}
private: private:
Mat &src; Mat &src;
Mat &dst; Mat &dst;
double (&coeffs)[2][3]; int mode;
int mode; double (&coeffs)[2][3];
int borderType; int borderType;
Scalar borderValue; Scalar borderValue;
ippiWarpAffineBackFunc func; ippiWarpAffineBackFunc func;
bool *ok; bool *ok;
const IPPwarpAffineInvoker& operator= (const IPPwarpAffineInvoker&); const IPPWarpAffineInvoker& operator= (const IPPWarpAffineInvoker&);
}; };
#endif #endif
*/
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
@ -4204,16 +4213,19 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
int* adelta = &_abdelta[0], *bdelta = adelta + dst.cols; int* adelta = &_abdelta[0], *bdelta = adelta + dst.cols;
const int AB_BITS = MAX(10, (int)INTER_BITS); const int AB_BITS = MAX(10, (int)INTER_BITS);
const int AB_SCALE = 1 << AB_BITS; const int AB_SCALE = 1 << AB_BITS;
/*
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) /*
int depth = src.depth(); #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 IPP_VERSION_MINOR >= 1
int channels = src.channels(); int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) && if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) &&
( channels == 1 || channels == 3 || channels == 4 ) && ( cn == 1 || cn == 3 || cn == 4 ) &&
( borderType == cv::BORDER_TRANSPARENT || ( borderType == cv::BORDER_CONSTANT ) ) ) ( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT) )
{ {
int type = src.type(); ippiWarpAffineBackFunc ippFunc = 0;
ippiWarpAffineBackFunc ippFunc = if ((flags & WARP_INVERSE_MAP) != 0)
{
ippFunc =
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C1R : type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C1R :
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C3R : type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C3R :
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C4R : type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C4R :
@ -4224,31 +4236,43 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C3R : type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C3R :
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C4R : type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C4R :
0; 0;
int mode =
flags == INTER_LINEAR ? IPPI_INTER_LINEAR :
flags == INTER_NEAREST ? IPPI_INTER_NN :
flags == INTER_CUBIC ? IPPI_INTER_CUBIC :
0;
if( mode && ippFunc )
{
double coeffs[2][3];
for( int i = 0; i < 2; i++ )
{
for( int j = 0; j < 3; j++ )
{
coeffs[i][j] = matM.at<double>(i, j);
}
}
bool ok;
Range range(0, dst.rows);
IPPwarpAffineInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
} }
else
{
ippFunc =
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C1R :
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C3R :
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C4R :
type == CV_16UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C1R :
type == CV_16UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C3R :
type == CV_16UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C4R :
type == CV_32FC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C1R :
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C3R :
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C4R :
0;
}
int mode =
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC :
0;
CV_Assert(mode && ippFunc);
double coeffs[2][3];
for( int i = 0; i < 2; i++ )
for( int j = 0; j < 3; j++ )
coeffs[i][j] = matM.at<double>(i, j);
bool ok;
Range range(0, dst.rows);
IPPWarpAffineInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
} }
#endif #endif
*/ */
for( x = 0; x < dst.cols; x++ ) for( x = 0; x < dst.cols; x++ )
{ {
adelta[x] = saturate_cast<int>(M[0]*x*AB_SCALE); adelta[x] = saturate_cast<int>(M[0]*x*AB_SCALE);
@ -4256,7 +4280,7 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
} }
Range range(0, dst.rows); Range range(0, dst.rows);
warpAffineInvoker invoker(src, dst, interpolation, borderType, WarpAffineInvoker invoker(src, dst, interpolation, borderType,
borderValue, adelta, bdelta, M); borderValue, adelta, bdelta, M);
parallel_for_(range, invoker, dst.total()/(double)(1<<16)); parallel_for_(range, invoker, dst.total()/(double)(1<<16));
} }
@ -4265,12 +4289,12 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
namespace cv namespace cv
{ {
class warpPerspectiveInvoker : class WarpPerspectiveInvoker :
public ParallelLoopBody public ParallelLoopBody
{ {
public: public:
warpPerspectiveInvoker(const Mat &_src, Mat &_dst, double *_M, int _interpolation, WarpPerspectiveInvoker(const Mat &_src, Mat &_dst, double *_M, int _interpolation,
int _borderType, const Scalar &_borderValue) : int _borderType, const Scalar &_borderValue) :
ParallelLoopBody(), src(_src), dst(_dst), M(_M), interpolation(_interpolation), ParallelLoopBody(), src(_src), dst(_dst), M(_M), interpolation(_interpolation),
borderType(_borderType), borderValue(_borderValue) borderType(_borderType), borderValue(_borderValue)
@ -4356,50 +4380,57 @@ private:
Scalar borderValue; Scalar borderValue;
}; };
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) /*
class IPPwarpPerspectiveInvoker : #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 && IPP_VERSION_MINOR >= 1
public ParallelLoopBody class IPPWarpPerspectiveInvoker :
public ParallelLoopBody
{ {
public: public:
IPPwarpPerspectiveInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[3][3], int &_interpolation, int &_borderType, const Scalar &_borderValue, ippiWarpPerspectiveBackFunc _func, bool *_ok) : IPPWarpPerspectiveInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[3][3], int &_interpolation,
ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok) int &_borderType, const Scalar &_borderValue, ippiWarpPerspectiveFunc _func, bool *_ok) :
{ ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs),
*ok = true; borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok)
} {
*ok = true;
}
virtual void operator() (const Range& range) const virtual void operator() (const Range& range) const
{ {
IppiSize srcsize = {src.cols, src.rows}; IppiSize srcsize = {src.cols, src.rows};
IppiRect srcroi = {0, 0, src.cols, src.rows}; IppiRect srcroi = {0, 0, src.cols, src.rows};
IppiRect dstroi = {0, range.start, dst.cols, range.end - range.start}; IppiRect dstroi = {0, range.start, dst.cols, range.end - range.start};
int cnn = src.channels(); int cnn = src.channels();
if( borderType == BORDER_CONSTANT ) if( borderType == BORDER_CONSTANT )
{ {
IppiSize setSize = {dst.cols, range.end - range.start}; IppiSize setSize = {dst.cols, range.end - range.start};
void *dataPointer = dst.data + dst.step[0] * range.start; void *dataPointer = dst.data + dst.step[0] * range.start;
if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) ) if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) )
{ {
*ok = false; *ok = false;
return; return;
} }
} }
if( func(src.data, srcsize, (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, coeffs, mode) < 0)
*ok = false; IppStatus status = func(src.data, srcsize, (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, coeffs, mode);
} printf("%d\n", status);
if (status != ippStsNoErr)
*ok = false;
}
private: private:
Mat &src; Mat &src;
Mat &dst; Mat &dst;
double (&coeffs)[3][3]; int mode;
int mode; double (&coeffs)[3][3];
int borderType; int borderType;
const Scalar borderValue; const Scalar borderValue;
ippiWarpPerspectiveBackFunc func; ippiWarpPerspectiveFunc func;
bool *ok; bool *ok;
const IPPwarpPerspectiveInvoker& operator= (const IPPwarpPerspectiveInvoker&);
const IPPWarpPerspectiveInvoker& operator= (const IPPWarpPerspectiveInvoker&);
}; };
#endif #endif
*/
} }
void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0, void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
@ -4432,55 +4463,65 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
return; return;
#endif #endif
if( !(flags & WARP_INVERSE_MAP) ) /*
invert(matM, matM); #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 && IPP_VERSION_MINOR >= 1
/* int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) if( (depth == CV_8U || depth == CV_16U || depth == CV_32F) &&
int depth = src.depth(); (cn == 1 || cn == 3 || cn == 4) &&
int channels = src.channels(); ( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT ) &&
if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) && (interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC))
( channels == 1 || channels == 3 || channels == 4 ) &&
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT ) )
{ {
int type = src.type(); ippiWarpPerspectiveFunc ippFunc = 0;
ippiWarpPerspectiveBackFunc ippFunc = if ((flags & WARP_INVERSE_MAP) != 0)
type == CV_8UC1 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_8u_C1R :
type == CV_8UC3 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_8u_C3R :
type == CV_8UC4 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_8u_C4R :
type == CV_16UC1 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_16u_C1R :
type == CV_16UC3 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_16u_C3R :
type == CV_16UC4 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_16u_C4R :
type == CV_32FC1 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_32f_C1R :
type == CV_32FC3 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_32f_C3R :
type == CV_32FC4 ? (ippiWarpPerspectiveBackFunc)ippiWarpPerspectiveBack_32f_C4R :
0;
int mode =
flags == INTER_LINEAR ? IPPI_INTER_LINEAR :
flags == INTER_NEAREST ? IPPI_INTER_NN :
flags == INTER_CUBIC ? IPPI_INTER_CUBIC :
0;
if( mode && ippFunc )
{ {
double coeffs[3][3]; ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C1R :
for( int i = 0; i < 3; i++ ) type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C3R :
{ type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C4R :
for( int j = 0; j < 3; j++ ) type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C1R :
{ type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C3R :
coeffs[i][j] = matM.at<double>(i, j); type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C4R :
} type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C1R :
} type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C3R :
bool ok; type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C4R : 0;
Range range(0, dst.rows);
IPPwarpPerspectiveInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
} }
else
{
ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C1R :
type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C3R :
type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C4R :
type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C1R :
type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C3R :
type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C4R :
type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C1R :
type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C3R :
type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C4R : 0;
}
int mode =
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC : 0;
CV_Assert(mode && ippFunc);
double coeffs[3][3];
for( int i = 0; i < 3; i++ )
for( int j = 0; j < 3; j++ )
coeffs[i][j] = matM.at<double>(i, j);
bool ok;
Range range(0, dst.rows);
IPPWarpPerspectiveInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
} }
#endif #endif
*/ */
if( !(flags & WARP_INVERSE_MAP) )
invert(matM, matM);
Range range(0, dst.rows); Range range(0, dst.rows);
warpPerspectiveInvoker invoker(src, dst, M, interpolation, borderType, borderValue); WarpPerspectiveInvoker invoker(src, dst, M, interpolation, borderType, borderValue);
parallel_for_(range, invoker, dst.total()/(double)(1<<16)); parallel_for_(range, invoker, dst.total()/(double)(1<<16));
} }