Commit b803c243 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

added nppSafeCall

parent 912f8ff3
This diff is collapsed.
......@@ -44,11 +44,14 @@
#define __OPENCV_CUDA_SAFE_CALL_HPP__
#include "cuda_runtime_api.h"
#include <nppdefs.h>
#if defined(__GNUC__)
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__);
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
#else /* defined(__CUDACC__) || defined(__MSVC__) */
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
#endif
namespace cv
......@@ -62,6 +65,12 @@ namespace cv
if( cudaSuccess != err)
cv::gpu::error(cudaGetErrorString(err), file, line, func);
}
static inline void ___nppSafeCall(NppStatus err, const char *file, const int line, const char *func = "")
{
if (err < 0)
cv::gpu::error("NPP Error", file, line, func);
}
}
}
......
......@@ -171,7 +171,7 @@ GpuMat& GpuMat::setTo(const Scalar& s, const GpuMat& mask)
sz.width = cols;
sz.height = rows;
Npp8u nVal = (Npp8u)s[0];
nppiSet_8u_C1R(nVal, (Npp8u*)ptr<char>(), step, sz);
nppSafeCall( nppiSet_8u_C1R(nVal, (Npp8u*)ptr<char>(), step, sz) );
break;
}
case CV_8UC4:
......@@ -180,7 +180,7 @@ GpuMat& GpuMat::setTo(const Scalar& s, const GpuMat& mask)
sz.width = cols;
sz.height = rows;
Npp8u nVal[] = {(Npp8u)s[0], (Npp8u)s[1], (Npp8u)s[2], (Npp8u)s[3]};
nppiSet_8u_C4R(nVal, (Npp8u*)ptr<char>(), step, sz);
nppSafeCall( nppiSet_8u_C4R(nVal, (Npp8u*)ptr<char>(), step, sz) );
break;
}
case CV_32SC1:
......@@ -189,7 +189,7 @@ GpuMat& GpuMat::setTo(const Scalar& s, const GpuMat& mask)
sz.width = cols;
sz.height = rows;
Npp32s nVal = (Npp32s)s[0];
nppiSet_32s_C1R(nVal, (Npp32s*)ptr<char>(), step, sz);
nppSafeCall( nppiSet_32s_C1R(nVal, (Npp32s*)ptr<char>(), step, sz) );
break;
}
case CV_32FC1:
......@@ -198,7 +198,7 @@ GpuMat& GpuMat::setTo(const Scalar& s, const GpuMat& mask)
sz.width = cols;
sz.height = rows;
Npp32f nVal = (Npp32f)s[0];
nppiSet_32f_C1R(nVal, (Npp32f*)ptr<char>(), step, sz);
nppSafeCall( nppiSet_32f_C1R(nVal, (Npp32f*)ptr<char>(), step, sz) );
break;
}
default:
......
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