fixed compilation with latest master changes
This commit is contained in:
@@ -42,6 +42,9 @@
|
||||
|
||||
#include "opencv2/core/cuda_devptrs.hpp"
|
||||
|
||||
namespace cv { namespace softcascade { namespace internal {
|
||||
void error(const char *error_string, const char *file, const int line, const char *func);
|
||||
}}}
|
||||
#if defined(__GNUC__)
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||
@@ -50,7 +53,7 @@
|
||||
|
||||
static inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
// if (cudaSuccess != err) cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
if (cudaSuccess != err) cv::softcascade::internal::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ int divUp(int total, int grain)
|
||||
@@ -490,16 +493,30 @@ namespace cv { namespace softcascade { namespace device
|
||||
B2Y = 1868
|
||||
};
|
||||
|
||||
template <int bidx> static __device__ __forceinline__ unsigned char RGB2GrayConvert(uint src)
|
||||
template <int bidx> static __device__ __forceinline__ unsigned char RGB2GrayConvert(unsigned char b, unsigned char g, unsigned char r)
|
||||
{
|
||||
uint b = 0xffu & (src >> (bidx * 8));
|
||||
uint g = 0xffu & (src >> 8);
|
||||
uint r = 0xffu & (src >> ((bidx ^ 2) * 8));
|
||||
// uint b = 0xffu & (src >> (bidx * 8));
|
||||
// uint g = 0xffu & (src >> 8);
|
||||
// uint r = 0xffu & (src >> ((bidx ^ 2) * 8));
|
||||
return CV_DESCALE((uint)(b * B2Y + g * G2Y + r * R2Y), yuv_shift);
|
||||
}
|
||||
|
||||
__global__ void device_transform(const cv::gpu::PtrStepSz<uchar3> bgr, cv::gpu::PtrStepSzb gray)
|
||||
{
|
||||
const int y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
|
||||
const uchar3 colored = (uchar3)(bgr.ptr(y))[x];
|
||||
|
||||
gray.ptr(y)[x] = RGB2GrayConvert<0>(colored.x, colored.y, colored.z);
|
||||
}
|
||||
|
||||
///////
|
||||
void transform(const cv::gpu::PtrStepSz<uchar3>& bgr, cv::gpu::PtrStepSzb gray)
|
||||
{
|
||||
|
||||
const dim3 block(32, 8);
|
||||
const dim3 grid(divUp(bgr.cols, block.x), divUp(bgr.rows, block.y));
|
||||
device_transform<<<grid, block>>>(bgr, gray);
|
||||
cudaSafeCall(cudaDeviceSynchronize());
|
||||
}
|
||||
}}}
|
||||
@@ -536,7 +536,7 @@ void cv::softcascade::SCascade::detect(InputArray _image, InputArray _rois, Outp
|
||||
|
||||
flds.mask.create( rois.cols / shr, rois.rows / shr, rois.type());
|
||||
|
||||
device::shrink(rois, flds.genRoiTmp);
|
||||
device::shrink(rois, flds.mask);
|
||||
//cv::gpu::transpose(flds.genRoiTmp, flds.mask, s);
|
||||
|
||||
if (type == CV_8UC3)
|
||||
@@ -594,15 +594,16 @@ struct SeparablePreprocessor : public cv::softcascade::ChannelsProcessor
|
||||
|
||||
virtual void apply(InputArray _frame, OutputArray _shrunk, cv::gpu::Stream& s = cv::gpu::Stream::Null())
|
||||
{
|
||||
const cv::gpu::GpuMat frame = _frame.getGpuMat();
|
||||
bgr = _frame.getGpuMat();
|
||||
//cv::gpu::GaussianBlur(frame, bgr, cv::Size(3, 3), -1.0);
|
||||
|
||||
_shrunk.create(frame.rows * (4 + bins) / shrinkage, frame.cols / shrinkage, CV_8UC1);
|
||||
_shrunk.create(bgr.rows * (4 + bins) / shrinkage, bgr.cols / shrinkage, CV_8UC1);
|
||||
cv::gpu::GpuMat shrunk = _shrunk.getGpuMat();
|
||||
|
||||
channels.create(frame.rows * (4 + bins), frame.cols, CV_8UC1);
|
||||
channels.create(bgr.rows * (4 + bins), bgr.cols, CV_8UC1);
|
||||
setZero(channels, s);
|
||||
|
||||
gray.create(bgr.size(), CV_8UC1);
|
||||
cv::softcascade::device::transform(bgr, gray); //cv::gpu::cvtColor(bgr, gray, CV_BGR2GRAY);
|
||||
cv::softcascade::device::gray2hog(gray, channels(cv::Rect(0, 0, bgr.cols, bgr.rows * (bins + 1))), bins);
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
|
||||
namespace cv { namespace softcascade { namespace internal
|
||||
{
|
||||
|
||||
namespace rnd {
|
||||
|
||||
typedef cv::RNG_MT19937 engine;
|
||||
|
||||
@@ -63,4 +63,22 @@ bool initModule_softcascade(void)
|
||||
return (sc1->info() != 0) && (sc->info() != 0);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
void error(const char *error_string, const char *file, const int line, const char *func)
|
||||
{
|
||||
int code = CV_GpuApiCallError;
|
||||
|
||||
if (std::uncaught_exception())
|
||||
{
|
||||
const char* errorStr = cvErrorStr(code);
|
||||
const char* function = func ? func : "unknown function";
|
||||
|
||||
std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line;
|
||||
std::cerr.flush();
|
||||
}
|
||||
else
|
||||
cv::error( cv::Exception(code, error_string, func, file, line) );
|
||||
}
|
||||
}
|
||||
|
||||
} }
|
||||
Reference in New Issue
Block a user