mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 00:19:46 +01:00
Transfer IPP polarToCart to HAL.
This commit is contained in:
parent
09a85e97aa
commit
78662ac085
1
3rdparty/ipphal/CMakeLists.txt
vendored
1
3rdparty/ipphal/CMakeLists.txt
vendored
|
|
@ -11,6 +11,7 @@ add_library(ipphal STATIC
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/src/mean_ipp.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/minmax_ipp.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/norm_ipp.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/cart_polar_ipp.cpp"
|
||||
)
|
||||
|
||||
if(HAVE_IPP_ICV)
|
||||
|
|
|
|||
8
3rdparty/ipphal/include/ipp_hal_core.hpp
vendored
8
3rdparty/ipphal/include/ipp_hal_core.hpp
vendored
|
|
@ -34,4 +34,12 @@ int ipp_hal_normDiff(const uchar* src1, size_t src1_step, const uchar* src2, siz
|
|||
|
||||
#endif
|
||||
|
||||
int ipp_hal_polarToCart32f(const float* mag, const float* angle, float* x, float* y, int len, bool angleInDegrees);
|
||||
int ipp_hal_polarToCart64f(const double* mag, const double* angle, double* x, double* y, int len, bool angleInDegrees);
|
||||
|
||||
#undef cv_hal_polarToCart32f
|
||||
#define cv_hal_polarToCart32f ipp_hal_polarToCart32f
|
||||
#undef cv_hal_polarToCart64f
|
||||
#define cv_hal_polarToCart64f ipp_hal_polarToCart64f
|
||||
|
||||
#endif
|
||||
|
|
|
|||
28
3rdparty/ipphal/src/cart_polar_ipp.cpp
vendored
Normal file
28
3rdparty/ipphal/src/cart_polar_ipp.cpp
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "ipp_hal_core.hpp"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/core/base.hpp>
|
||||
|
||||
int ipp_hal_polarToCart32f(const float* mag, const float* angle, float* x, float* y, int len, bool angleInDegrees)
|
||||
{
|
||||
const bool isInPlace = (x == mag) || (x == angle) || (y == mag) || (y == angle);
|
||||
if (isInPlace || angleInDegrees)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_32f, mag, angle, x, y, len) < 0)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return CV_HAL_ERROR_OK;
|
||||
}
|
||||
|
||||
int ipp_hal_polarToCart64f(const double* mag, const double* angle, double* x, double* y, int len, bool angleInDegrees)
|
||||
{
|
||||
const bool isInPlace = (x == mag) || (x == angle) || (y == mag) || (y == angle);
|
||||
if (isInPlace || angleInDegrees)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_64f, mag, angle, x, y, len) < 0)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return CV_HAL_ERROR_OK;
|
||||
}
|
||||
|
|
@ -378,65 +378,6 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle,
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_polarToCart(Mat &mag, Mat &angle, Mat &x, Mat &y)
|
||||
{
|
||||
CV_INSTRUMENT_REGION_IPP();
|
||||
|
||||
int depth = angle.depth();
|
||||
if(depth != CV_32F && depth != CV_64F)
|
||||
return false;
|
||||
|
||||
if(angle.dims <= 2)
|
||||
{
|
||||
int len = (int)(angle.cols*angle.channels());
|
||||
|
||||
if(depth == CV_32F)
|
||||
{
|
||||
for (int h = 0; h < angle.rows; h++)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_32f, (const float*)mag.ptr(h), (const float*)angle.ptr(h), (float*)x.ptr(h), (float*)y.ptr(h), len) < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int h = 0; h < angle.rows; h++)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_64f, (const double*)mag.ptr(h), (const double*)angle.ptr(h), (double*)x.ptr(h), (double*)y.ptr(h), len) < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&mag, &angle, &x, &y, NULL};
|
||||
uchar *ptrs[4] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int len = (int)(it.size*angle.channels());
|
||||
|
||||
if(depth == CV_32F)
|
||||
{
|
||||
for (size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_32f, (const float*)ptrs[0], (const float*)ptrs[1], (float*)ptrs[2], (float*)ptrs[3], len) < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_64f, (const double*)ptrs[0], (const double*)ptrs[1], (double*)ptrs[2], (double*)ptrs[3], len) < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void polarToCart( InputArray src1, InputArray src2,
|
||||
OutputArray dst1, OutputArray dst2, bool angleInDegrees )
|
||||
{
|
||||
|
|
@ -444,14 +385,6 @@ void polarToCart( InputArray src1, InputArray src2,
|
|||
|
||||
CV_Assert(dst1.getObj() != dst2.getObj());
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
const bool isInPlace =
|
||||
(src1.getObj() == dst1.getObj()) ||
|
||||
(src1.getObj() == dst2.getObj()) ||
|
||||
(src2.getObj() == dst1.getObj()) ||
|
||||
(src2.getObj() == dst2.getObj());
|
||||
#endif
|
||||
|
||||
int type = src2.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
CV_Assert((depth == CV_32F || depth == CV_64F) && (src1.empty() || src1.type() == type));
|
||||
|
||||
|
|
@ -464,8 +397,6 @@ void polarToCart( InputArray src1, InputArray src2,
|
|||
dst2.create( Angle.dims, Angle.size, type );
|
||||
Mat X = dst1.getMat(), Y = dst2.getMat();
|
||||
|
||||
CV_IPP_RUN(!angleInDegrees && !isInPlace, ipp_polarToCart(Mag, Angle, X, Y));
|
||||
|
||||
const Mat* arrays[] = {&Mag, &Angle, &X, &Y, 0};
|
||||
uchar* ptrs[4] = {};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user