Commit 41246333 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

added magnitudeSqr and rectStdDev to gpu module.

added supports of CV_32SC2 source to gpu scalar arithm and float source to gpu::histRange.
minor fix of gpu tests.
parent f4075e01
...@@ -351,25 +351,25 @@ namespace cv ...@@ -351,25 +351,25 @@ namespace cv
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c); CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c);
//! adds scalar to a matrix (c = a + s) //! adds scalar to a matrix (c = a + s)
//! supports only CV_32FC1 type //! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c); CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c);
//! subtracts one matrix from another (c = a - b) //! subtracts one matrix from another (c = a - b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c); CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c);
//! subtracts scalar from a matrix (c = a - s) //! subtracts scalar from a matrix (c = a - s)
//! supports only CV_32FC1 type //! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c); CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c);
//! computes element-wise product of the two arrays (c = a * b) //! computes element-wise product of the two arrays (c = a * b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c); CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c);
//! multiplies matrix to a scalar (c = a * s) //! multiplies matrix to a scalar (c = a * s)
//! supports only CV_32FC1 type //! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c); CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c);
//! computes element-wise quotient of the two arrays (c = a / b) //! computes element-wise quotient of the two arrays (c = a / b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c); CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c);
//! computes element-wise quotient of matrix and scalar (c = a / s) //! computes element-wise quotient of matrix and scalar (c = a / s)
//! supports only CV_32FC1 type //! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c); CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c);
//! transposes the matrix //! transposes the matrix
...@@ -452,13 +452,20 @@ namespace cv ...@@ -452,13 +452,20 @@ namespace cv
//! supports only CV_32FC1 type //! supports only CV_32FC1 type
CV_EXPORTS void log(const GpuMat& a, GpuMat& b); CV_EXPORTS void log(const GpuMat& a, GpuMat& b);
//! computes magnitude (magnitude(i)) of each (x(i), y(i)) vector //! computes magnitude of each (x(i), y(i)) vector
//! supports only CV_32FC1 type //! supports only CV_32FC1 type
CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude); CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
//! computes magnitude (magnitude(i)) of complex (x(i).re, x(i).im) vector //! computes magnitude of complex (x(i).re, x(i).im) vector
//! supports only CV_32FC2 type //! supports only CV_32FC2 type
CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude); CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude);
//! computes squared magnitude of each (x(i), y(i)) vector
//! supports only CV_32FC1 type
CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
//! computes squared magnitude of complex (x(i).re, x(i).im) vector
//! supports only CV_32FC2 type
CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude);
////////////////////////////// Image processing ////////////////////////////// ////////////////////////////// Image processing //////////////////////////////
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation. //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
...@@ -529,6 +536,11 @@ namespace cv ...@@ -529,6 +536,11 @@ namespace cv
//! supports only CV_32FC1 source type //! supports only CV_32FC1 source type
CV_EXPORTS void integral(GpuMat& src, GpuMat& sum, GpuMat& sqsum); CV_EXPORTS void integral(GpuMat& src, GpuMat& sum, GpuMat& sqsum);
//! computes the standard deviation of integral images
//! supports only CV_32SC1 source type and CV_32FC1 sqr type
//! output will have CV_32FC1 type
CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect);
//! applies Canny edge detector and produces the edge map //! applies Canny edge detector and produces the edge map
//! supprots only CV_8UC1 source type //! supprots only CV_8UC1 source type
//! disabled until fix crash //! disabled until fix crash
...@@ -718,14 +730,14 @@ namespace cv ...@@ -718,14 +730,14 @@ namespace cv
//! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type. //! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]); CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]);
//! Calculates histogram with bins determined by levels array. //! Calculates histogram with bins determined by levels array.
//! levels must have one row and CV_32SC1 type. //! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
//! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types. //! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
//! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type. //! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels); CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels);
//! Calculates histogram with bins determined by levels array. //! Calculates histogram with bins determined by levels array.
//! All levels must have one row and CV_32SC1 type. //! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
//! All channels of source are processed separately. //! All channels of source are processed separately.
//! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types. //! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
//! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type. //! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]); CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);
......
...@@ -71,6 +71,8 @@ void cv::gpu::exp(const GpuMat&, GpuMat&) { throw_nogpu(); } ...@@ -71,6 +71,8 @@ void cv::gpu::exp(const GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::log(const GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::log(const GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::magnitude(const GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::magnitude(const GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::magnitudeSqr(const GpuMat&, GpuMat&) { throw_nogpu(); }
#else /* !defined (HAVE_CUDA) */ #else /* !defined (HAVE_CUDA) */
...@@ -127,22 +129,49 @@ namespace ...@@ -127,22 +129,49 @@ namespace
} }
} }
typedef NppStatus (*npp_arithm_scalar_32f_t)(const Npp32f *pSrc, int nSrcStep, Npp32f nValue, Npp32f *pDst, template<int SCN> struct NppArithmScalarFunc;
int nDstStep, NppiSize oSizeROI); template<> struct NppArithmScalarFunc<1>
{
typedef NppStatus (*func_ptr)(const Npp32f *pSrc, int nSrcStep, Npp32f nValue, Npp32f *pDst,
int nDstStep, NppiSize oSizeROI);
};
template<> struct NppArithmScalarFunc<2>
{
typedef NppStatus (*func_ptr)(const Npp32fc *pSrc, int nSrcStep, Npp32fc nValue, Npp32fc *pDst,
int nDstStep, NppiSize oSizeROI);
};
void nppArithmCaller(const GpuMat& src1, const Scalar& sc, GpuMat& dst, template<int SCN, typename NppArithmScalarFunc<SCN>::func_ptr func> struct NppArithmScalar;
npp_arithm_scalar_32f_t npp_func) template<typename NppArithmScalarFunc<1>::func_ptr func> struct NppArithmScalar<1, func>
{ {
CV_Assert(src1.type() == CV_32FC1); static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{
dst.create(src.size(), src.type());
dst.create(src1.size(), src1.type()); NppiSize sz;
sz.width = src.cols;
sz.height = src.rows;
NppiSize sz; nppSafeCall( func(src.ptr<Npp32f>(), src.step, (Npp32f)sc[0], dst.ptr<Npp32f>(), dst.step, sz) );
sz.width = src1.cols; }
sz.height = src1.rows; };
template<typename NppArithmScalarFunc<2>::func_ptr func> struct NppArithmScalar<2, func>
{
static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{
dst.create(src.size(), src.type());
nppSafeCall( npp_func(src1.ptr<Npp32f>(), src1.step, (Npp32f)sc[0], dst.ptr<Npp32f>(), dst.step, sz) ); NppiSize sz;
} sz.width = src.cols;
sz.height = src.rows;
Npp32fc nValue;
nValue.re = (Npp32f)sc[0];
nValue.im = (Npp32f)sc[1];
nppSafeCall( func(src.ptr<Npp32fc>(), src.step, nValue, dst.ptr<Npp32fc>(), dst.step, sz) );
}
};
} }
void cv::gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst) void cv::gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
...@@ -167,22 +196,42 @@ void cv::gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst) ...@@ -167,22 +196,42 @@ void cv::gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
void cv::gpu::add(const GpuMat& src, const Scalar& sc, GpuMat& dst) void cv::gpu::add(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{ {
nppArithmCaller(src, sc, dst, nppiAddC_32f_C1R); typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);
static const caller_t callers[] = {NppArithmScalar<1, nppiAddC_32f_C1R>::calc, NppArithmScalar<2, nppiAddC_32fc_C1R>::calc};
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);
callers[src.channels()](src, sc, dst);
} }
void cv::gpu::subtract(const GpuMat& src, const Scalar& sc, GpuMat& dst) void cv::gpu::subtract(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{ {
nppArithmCaller(src, sc, dst, nppiSubC_32f_C1R); typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);
static const caller_t callers[] = {NppArithmScalar<1, nppiSubC_32f_C1R>::calc, NppArithmScalar<2, nppiSubC_32fc_C1R>::calc};
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);
callers[src.channels()](src, sc, dst);
} }
void cv::gpu::multiply(const GpuMat& src, const Scalar& sc, GpuMat& dst) void cv::gpu::multiply(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{ {
nppArithmCaller(src, sc, dst, nppiMulC_32f_C1R); typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);
static const caller_t callers[] = {NppArithmScalar<1, nppiMulC_32f_C1R>::calc, NppArithmScalar<2, nppiMulC_32fc_C1R>::calc};
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);
callers[src.channels()](src, sc, dst);
} }
void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst) void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst)
{ {
nppArithmCaller(src, sc, dst, nppiDivC_32f_C1R); typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);
static const caller_t callers[] = {NppArithmScalar<1, nppiDivC_32f_C1R>::calc, NppArithmScalar<2, nppiDivC_32fc_C1R>::calc};
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);
callers[src.channels()](src, sc, dst);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -589,4 +638,29 @@ void cv::gpu::magnitude(const GpuMat& src1, const GpuMat& src2, GpuMat& dst) ...@@ -589,4 +638,29 @@ void cv::gpu::magnitude(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
cv::gpu::magnitude(src, dst); cv::gpu::magnitude(src, dst);
} }
void cv::gpu::magnitudeSqr(const GpuMat& src, GpuMat& dst)
{
CV_Assert(src.type() == CV_32FC2);
dst.create(src.size(), CV_32FC1);
NppiSize sz;
sz.width = src.cols;
sz.height = src.rows;
nppSafeCall( nppiMagnitudeSqr_32fc32f_C1R(src.ptr<Npp32fc>(), src.step, dst.ptr<Npp32f>(), dst.step, sz) );
}
void cv::gpu::magnitudeSqr(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
{
CV_DbgAssert(src1.type() == src2.type() && src1.size() == src2.size());
CV_Assert(src1.type() == CV_32FC1);
GpuMat src(src1.size(), CV_32FC2);
GpuMat srcs[] = {src1, src2};
cv::gpu::merge(srcs, 2, src);
cv::gpu::magnitudeSqr(src, dst);
}
#endif /* !defined (HAVE_CUDA) */ #endif /* !defined (HAVE_CUDA) */
\ No newline at end of file
...@@ -63,6 +63,7 @@ void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_ ...@@ -63,6 +63,7 @@ void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_
void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_nogpu(); } void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_nogpu(); }
void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int) { throw_nogpu(); } void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int) { throw_nogpu(); }
void cv::gpu::integral(GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); } void cv::gpu::integral(GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }
void cv::gpu::rectStdDev(const GpuMat&, const GpuMat&, GpuMat&, const Rect&) { throw_nogpu(); }
void cv::gpu::Canny(const GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); } void cv::gpu::Canny(const GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); }
void cv::gpu::evenLevels(GpuMat&, int, int, int) { throw_nogpu(); } void cv::gpu::evenLevels(GpuMat&, int, int, int) { throw_nogpu(); }
void cv::gpu::histEven(const GpuMat&, GpuMat&, int, int, int) { throw_nogpu(); } void cv::gpu::histEven(const GpuMat&, GpuMat&, int, int, int) { throw_nogpu(); }
...@@ -970,6 +971,26 @@ void cv::gpu::integral(GpuMat& src, GpuMat& sum, GpuMat& sqsum) ...@@ -970,6 +971,26 @@ void cv::gpu::integral(GpuMat& src, GpuMat& sum, GpuMat& sqsum)
sum.step, sqsum.ptr<Npp32f>(), sqsum.step, sz, 0, 0.0f, h) ); sum.step, sqsum.ptr<Npp32f>(), sqsum.step, sz, 0, 0.0f, h) );
} }
void cv::gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect)
{
CV_Assert(src.type() == CV_32SC1 && sqr.type() == CV_32FC1);
dst.create(src.size(), CV_32FC1);
NppiSize sz;
sz.width = src.cols;
sz.height = src.rows;
NppiRect nppRect;
nppRect.height = rect.height;
nppRect.width = rect.width;
nppRect.x = rect.x;
nppRect.y = rect.y;
nppSafeCall( nppiRectStdDev_32s32f_C1R(src.ptr<Npp32s>(), src.step, sqr.ptr<Npp32f>(), sqr.step,
dst.ptr<Npp32f>(), dst.step, sz, nppRect) );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Canny // Canny
...@@ -1009,6 +1030,7 @@ namespace ...@@ -1009,6 +1030,7 @@ namespace
template<> struct NPPTypeTraits<CV_8U> { typedef Npp8u npp_type; }; template<> struct NPPTypeTraits<CV_8U> { typedef Npp8u npp_type; };
template<> struct NPPTypeTraits<CV_16U> { typedef Npp16u npp_type; }; template<> struct NPPTypeTraits<CV_16U> { typedef Npp16u npp_type; };
template<> struct NPPTypeTraits<CV_16S> { typedef Npp16s npp_type; }; template<> struct NPPTypeTraits<CV_16S> { typedef Npp16s npp_type; };
template<> struct NPPTypeTraits<CV_32F> { typedef Npp32f npp_type; };
typedef NppStatus (*get_buf_size_c1_t)(NppiSize oSizeROI, int nLevels, int* hpBufferSize); typedef NppStatus (*get_buf_size_c1_t)(NppiSize oSizeROI, int nLevels, int* hpBufferSize);
typedef NppStatus (*get_buf_size_c4_t)(NppiSize oSizeROI, int nLevels[], int* hpBufferSize); typedef NppStatus (*get_buf_size_c4_t)(NppiSize oSizeROI, int nLevels[], int* hpBufferSize);
...@@ -1082,26 +1104,50 @@ namespace ...@@ -1082,26 +1104,50 @@ namespace
template<int SDEPTH> struct NppHistogramRangeFuncC1 template<int SDEPTH> struct NppHistogramRangeFuncC1
{ {
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t; typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
typedef Npp32s level_t;
enum {LEVEL_TYPE_CODE=CV_32SC1};
typedef NppStatus (*func_ptr)(const src_t* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist, typedef NppStatus (*func_ptr)(const src_t* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist,
const Npp32s* pLevels, int nLevels, Npp8u* pBuffer); const Npp32s* pLevels, int nLevels, Npp8u* pBuffer);
}; };
template<> struct NppHistogramRangeFuncC1<CV_32F>
{
typedef Npp32f src_t;
typedef Npp32f level_t;
enum {LEVEL_TYPE_CODE=CV_32FC1};
typedef NppStatus (*func_ptr)(const Npp32f* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist,
const Npp32f* pLevels, int nLevels, Npp8u* pBuffer);
};
template<int SDEPTH> struct NppHistogramRangeFuncC4 template<int SDEPTH> struct NppHistogramRangeFuncC4
{ {
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t; typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
typedef Npp32s level_t;
enum {LEVEL_TYPE_CODE=CV_32SC1};
typedef NppStatus (*func_ptr)(const src_t* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist[4], typedef NppStatus (*func_ptr)(const src_t* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist[4],
const Npp32s* pLevels[4], int nLevels[4], Npp8u* pBuffer); const Npp32s* pLevels[4], int nLevels[4], Npp8u* pBuffer);
}; };
template<> struct NppHistogramRangeFuncC4<CV_32F>
{
typedef Npp32f src_t;
typedef Npp32f level_t;
enum {LEVEL_TYPE_CODE=CV_32FC1};
typedef NppStatus (*func_ptr)(const Npp32f* pSrc, int nSrcStep, NppiSize oSizeROI, Npp32s* pHist[4],
const Npp32f* pLevels[4], int nLevels[4], Npp8u* pBuffer);
};
template<int SDEPTH, typename NppHistogramRangeFuncC1<SDEPTH>::func_ptr func, get_buf_size_c1_t get_buf_size> template<int SDEPTH, typename NppHistogramRangeFuncC1<SDEPTH>::func_ptr func, get_buf_size_c1_t get_buf_size>
struct NppHistogramRangeC1 struct NppHistogramRangeC1
{ {
typedef typename NppHistogramRangeFuncC1<SDEPTH>::src_t src_t; typedef typename NppHistogramRangeFuncC1<SDEPTH>::src_t src_t;
typedef typename NppHistogramRangeFuncC1<SDEPTH>::level_t level_t;
enum {LEVEL_TYPE_CODE=NppHistogramRangeFuncC1<SDEPTH>::LEVEL_TYPE_CODE};
static void hist(const GpuMat& src, GpuMat& hist, const GpuMat& levels) static void hist(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
{ {
CV_Assert(levels.type() == CV_32SC1 && levels.rows == 1); CV_Assert(levels.type() == LEVEL_TYPE_CODE && levels.rows == 1);
hist.create(1, levels.cols - 1, CV_32S); hist.create(1, levels.cols - 1, CV_32S);
...@@ -1114,20 +1160,22 @@ namespace ...@@ -1114,20 +1160,22 @@ namespace
get_buf_size(sz, levels.cols, &buf_size); get_buf_size(sz, levels.cols, &buf_size);
buffer.create(1, buf_size, CV_8U); buffer.create(1, buf_size, CV_8U);
nppSafeCall( func(src.ptr<src_t>(), src.step, sz, hist.ptr<Npp32s>(), levels.ptr<Npp32s>(), levels.cols, buffer.ptr<Npp8u>()) ); nppSafeCall( func(src.ptr<src_t>(), src.step, sz, hist.ptr<Npp32s>(), levels.ptr<level_t>(), levels.cols, buffer.ptr<Npp8u>()) );
} }
}; };
template<int SDEPTH, typename NppHistogramRangeFuncC4<SDEPTH>::func_ptr func, get_buf_size_c4_t get_buf_size> template<int SDEPTH, typename NppHistogramRangeFuncC4<SDEPTH>::func_ptr func, get_buf_size_c4_t get_buf_size>
struct NppHistogramRangeC4 struct NppHistogramRangeC4
{ {
typedef typename NppHistogramRangeFuncC4<SDEPTH>::src_t src_t; typedef typename NppHistogramRangeFuncC4<SDEPTH>::src_t src_t;
typedef typename NppHistogramRangeFuncC1<SDEPTH>::level_t level_t;
enum {LEVEL_TYPE_CODE=NppHistogramRangeFuncC1<SDEPTH>::LEVEL_TYPE_CODE};
static void hist(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]) static void hist(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])
{ {
CV_Assert(levels[0].type() == CV_32SC1 && levels[0].rows == 1); CV_Assert(levels[0].type() == LEVEL_TYPE_CODE && levels[0].rows == 1);
CV_Assert(levels[1].type() == CV_32SC1 && levels[1].rows == 1); CV_Assert(levels[1].type() == LEVEL_TYPE_CODE && levels[1].rows == 1);
CV_Assert(levels[2].type() == CV_32SC1 && levels[2].rows == 1); CV_Assert(levels[2].type() == LEVEL_TYPE_CODE && levels[2].rows == 1);
CV_Assert(levels[3].type() == CV_32SC1 && levels[3].rows == 1); CV_Assert(levels[3].type() == LEVEL_TYPE_CODE && levels[3].rows == 1);
hist[0].create(1, levels[0].cols - 1, CV_32S); hist[0].create(1, levels[0].cols - 1, CV_32S);
hist[1].create(1, levels[1].cols - 1, CV_32S); hist[1].create(1, levels[1].cols - 1, CV_32S);
...@@ -1136,7 +1184,7 @@ namespace ...@@ -1136,7 +1184,7 @@ namespace
Npp32s* pHist[] = {hist[0].ptr<Npp32s>(), hist[1].ptr<Npp32s>(), hist[2].ptr<Npp32s>(), hist[3].ptr<Npp32s>()}; Npp32s* pHist[] = {hist[0].ptr<Npp32s>(), hist[1].ptr<Npp32s>(), hist[2].ptr<Npp32s>(), hist[3].ptr<Npp32s>()};
int nLevels[] = {levels[0].cols, levels[1].cols, levels[2].cols, levels[3].cols}; int nLevels[] = {levels[0].cols, levels[1].cols, levels[2].cols, levels[3].cols};
const Npp32s* pLevels[] = {levels[0].ptr<Npp32s>(), levels[1].ptr<Npp32s>(), levels[2].ptr<Npp32s>(), levels[3].ptr<Npp32s>()}; const level_t* pLevels[] = {levels[0].ptr<level_t>(), levels[1].ptr<level_t>(), levels[2].ptr<level_t>(), levels[3].ptr<level_t>()};
NppiSize sz; NppiSize sz;
sz.width = src.cols; sz.width = src.cols;
...@@ -1193,7 +1241,7 @@ void cv::gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int l ...@@ -1193,7 +1241,7 @@ void cv::gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int l
void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels) void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
{ {
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_16UC1 || src.type() == CV_16SC1); CV_Assert(src.type() == CV_8UC1 || src.type() == CV_16UC1 || src.type() == CV_16SC1 || src.type() == CV_32FC1);
typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, const GpuMat& levels); typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, const GpuMat& levels);
static const hist_t hist_callers[] = static const hist_t hist_callers[] =
...@@ -1201,7 +1249,9 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels) ...@@ -1201,7 +1249,9 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
NppHistogramRangeC1<CV_8U , nppiHistogramRange_8u_C1R , nppiHistogramRangeGetBufferSize_8u_C1R >::hist, NppHistogramRangeC1<CV_8U , nppiHistogramRange_8u_C1R , nppiHistogramRangeGetBufferSize_8u_C1R >::hist,
0, 0,
NppHistogramRangeC1<CV_16U, nppiHistogramRange_16u_C1R, nppiHistogramRangeGetBufferSize_16u_C1R>::hist, NppHistogramRangeC1<CV_16U, nppiHistogramRange_16u_C1R, nppiHistogramRangeGetBufferSize_16u_C1R>::hist,
NppHistogramRangeC1<CV_16S, nppiHistogramRange_16s_C1R, nppiHistogramRangeGetBufferSize_16s_C1R>::hist NppHistogramRangeC1<CV_16S, nppiHistogramRange_16s_C1R, nppiHistogramRangeGetBufferSize_16s_C1R>::hist,
0,
NppHistogramRangeC1<CV_32F, nppiHistogramRange_32f_C1R, nppiHistogramRangeGetBufferSize_32f_C1R>::hist
}; };
hist_callers[src.depth()](src, hist, levels); hist_callers[src.depth()](src, hist, levels);
...@@ -1209,7 +1259,7 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels) ...@@ -1209,7 +1259,7 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]) void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])
{ {
CV_Assert(src.type() == CV_8UC4 || src.type() == CV_16UC4 || src.type() == CV_16SC4); CV_Assert(src.type() == CV_8UC4 || src.type() == CV_16UC4 || src.type() == CV_16SC4 || src.type() == CV_32FC4);
typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]); typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);
static const hist_t hist_callers[] = static const hist_t hist_callers[] =
...@@ -1217,7 +1267,9 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4 ...@@ -1217,7 +1267,9 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4
NppHistogramRangeC4<CV_8U , nppiHistogramRange_8u_C4R , nppiHistogramRangeGetBufferSize_8u_C4R >::hist, NppHistogramRangeC4<CV_8U , nppiHistogramRange_8u_C4R , nppiHistogramRangeGetBufferSize_8u_C4R >::hist,
0, 0,
NppHistogramRangeC4<CV_16U, nppiHistogramRange_16u_C4R, nppiHistogramRangeGetBufferSize_16u_C4R>::hist, NppHistogramRangeC4<CV_16U, nppiHistogramRange_16u_C4R, nppiHistogramRangeGetBufferSize_16u_C4R>::hist,
NppHistogramRangeC4<CV_16S, nppiHistogramRange_16s_C4R, nppiHistogramRangeGetBufferSize_16s_C4R>::hist NppHistogramRangeC4<CV_16S, nppiHistogramRange_16s_C4R, nppiHistogramRangeGetBufferSize_16s_C4R>::hist,
0,
NppHistogramRangeC4<CV_32F, nppiHistogramRange_32f_C4R, nppiHistogramRangeGetBufferSize_32f_C4R>::hist
}; };
hist_callers[src.depth()](src, hist, levels); hist_callers[src.depth()](src, hist, levels);
......
...@@ -43,9 +43,6 @@ ...@@ -43,9 +43,6 @@
#include <cmath> #include <cmath>
#include <limits> #include <limits>
#include "gputest.hpp" #include "gputest.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#include <cmath> #include <cmath>
#include <limits> #include <limits>
#include "gputest.hpp" #include "gputest.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
...@@ -48,7 +48,9 @@ ...@@ -48,7 +48,9 @@
#undef max #undef max
#endif #endif
#include "opencv2/gpu/gpu.hpp" #include <opencv2/gpu/gpu.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "cxts.h" #include "cxts.h"
/****************************************************************************************/ /****************************************************************************************/
......
...@@ -43,9 +43,6 @@ ...@@ -43,9 +43,6 @@
#include <cmath> #include <cmath>
#include <limits> #include <limits>
#include "gputest.hpp" #include "gputest.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
// //
//M*/ //M*/
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h"
#include "cv.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h"
#include "cv.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
......
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h"
#include "cv.h"
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
...@@ -40,13 +40,9 @@ ...@@ -40,13 +40,9 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
struct CV_GpuStereoBPTest : public CvTest struct CV_GpuStereoBPTest : public CvTest
{ {
CV_GpuStereoBPTest() : CvTest( "GPU-StereoBP", "StereoBP" ){} CV_GpuStereoBPTest() : CvTest( "GPU-StereoBP", "StereoBP" ){}
......
...@@ -40,9 +40,6 @@ ...@@ -40,9 +40,6 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment