void cv::gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& s) { CV_Assert(src.type() == CV_32SC1 && sqr.type() == CV_64FC1); 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; cudaStream_t stream = StreamAccessor::getStream(s); NppStreamHandler h(stream); nppSafeCall( nppiRectStdDev_32s32f_C1R(src.ptr<Npp32s>(), static_cast<int>(src.step), sqr.ptr<Npp64f>(), static_cast<int>(sqr.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step), sz, nppRect) ); if (stream == 0) cudaSafeCall( cudaDeviceSynchronize() ); }
void cv::gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode, Stream& s) { using cv::gpu::cudev::imgproc::bilateral_filter_gpu; typedef void (*func_t)(const PtrStepSzb& src, PtrStepSzb dst, int kernel_size, float sigma_spatial, float sigma_color, int borderMode, cudaStream_t s); static const func_t funcs[6][4] = { {bilateral_filter_gpu<uchar> , 0 /*bilateral_filter_gpu<uchar2>*/ , bilateral_filter_gpu<uchar3> , bilateral_filter_gpu<uchar4> }, {0 /*bilateral_filter_gpu<schar>*/, 0 /*bilateral_filter_gpu<schar2>*/ , 0 /*bilateral_filter_gpu<schar3>*/, 0 /*bilateral_filter_gpu<schar4>*/}, {bilateral_filter_gpu<ushort> , 0 /*bilateral_filter_gpu<ushort2>*/, bilateral_filter_gpu<ushort3> , bilateral_filter_gpu<ushort4> }, {bilateral_filter_gpu<short> , 0 /*bilateral_filter_gpu<short2>*/ , bilateral_filter_gpu<short3> , bilateral_filter_gpu<short4> }, {0 /*bilateral_filter_gpu<int>*/ , 0 /*bilateral_filter_gpu<int2>*/ , 0 /*bilateral_filter_gpu<int3>*/ , 0 /*bilateral_filter_gpu<int4>*/ }, {bilateral_filter_gpu<float> , 0 /*bilateral_filter_gpu<float2>*/ , bilateral_filter_gpu<float3> , bilateral_filter_gpu<float4> } }; sigma_color = (sigma_color <= 0 ) ? 1 : sigma_color; sigma_spatial = (sigma_spatial <= 0 ) ? 1 : sigma_spatial; int radius = (kernel_size <= 0) ? cvRound(sigma_spatial*1.5) : kernel_size/2; kernel_size = std::max(radius, 1)*2 + 1; CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); const func_t func = funcs[src.depth()][src.channels() - 1]; CV_Assert(func != 0); CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP); int gpuBorderType; CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType)); dst.create(src.size(), src.type()); func(src, dst, kernel_size, sigma_spatial, sigma_color, gpuBorderType, StreamAccessor::getStream(s)); }
void cv::gpu::VIBE_GPU::initialize(const GpuMat& firstFrame, Stream& s) { using namespace cv::gpu::device::vibe; CV_Assert(firstFrame.type() == CV_8UC1 || firstFrame.type() == CV_8UC3 || firstFrame.type() == CV_8UC4); cudaStream_t stream = StreamAccessor::getStream(s); loadConstants(nbSamples, reqMatches, radius, subsamplingFactor); frameSize_ = firstFrame.size(); if (randStates_.size() != frameSize_) { cv::RNG rng(rngSeed_); cv::Mat h_randStates(frameSize_, CV_8UC4); rng.fill(h_randStates, cv::RNG::UNIFORM, 0, 255); randStates_.upload(h_randStates); } int ch = firstFrame.channels(); int sample_ch = ch == 1 ? 1 : 4; samples_.create(nbSamples * frameSize_.height, frameSize_.width, CV_8UC(sample_ch)); init_gpu(firstFrame, ch, samples_, randStates_, stream); }
void cv::gpu::Stream::enqueueConvert(const GpuMat& src, GpuMat& dst, int rtype, double alpha, double beta) { CV_Assert((src.depth() != CV_64F && CV_MAT_DEPTH(rtype) != CV_64F) || (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))); bool noScale = fabs(alpha-1) < std::numeric_limits<double>::epsilon() && fabs(beta) < std::numeric_limits<double>::epsilon(); if( rtype < 0 ) rtype = src.type(); else rtype = CV_MAKETYPE(CV_MAT_DEPTH(rtype), src.channels()); int sdepth = src.depth(), ddepth = CV_MAT_DEPTH(rtype); if( sdepth == ddepth && noScale ) { src.copyTo(dst); return; } GpuMat temp; const GpuMat* psrc = &src; if( sdepth != ddepth && psrc == &dst ) psrc = &(temp = src); dst.create( src.size(), rtype ); convertTo(src, dst, alpha, beta, Impl::getStream(impl)); }
void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf) { typedef void (*func_t)(const PtrStepSzb src, const PtrStepb mask, double* minval, double* maxval, PtrStepb buf); #ifdef OPENCV_TINY_GPU_MODULE static const func_t funcs[] = { ::minMax::run<uchar>, 0/*::minMax::run<schar>*/, 0/*::minMax::run<ushort>*/, 0/*::minMax::run<short>*/, 0/*::minMax::run<int>*/, ::minMax::run<float>, 0/*::minMax::run<double>*/, }; #else static const func_t funcs[] = { ::minMax::run<uchar>, ::minMax::run<schar>, ::minMax::run<ushort>, ::minMax::run<short>, ::minMax::run<int>, ::minMax::run<float>, ::minMax::run<double>, }; #endif CV_Assert( src.channels() == 1 ); CV_Assert( mask.empty() || (mask.size() == src.size() && mask.type() == CV_8U) ); if (src.depth() == CV_64F) { if (!deviceSupports(NATIVE_DOUBLE)) CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double"); } Size buf_size; ::minMax::getBufSize(src.cols, src.rows, buf_size.width, buf_size.height); ensureSizeIsEnough(buf_size, CV_8U, buf); const func_t func = funcs[src.depth()]; if (!func) CV_Error(CV_StsUnsupportedFormat, "Unsupported combination of source and destination types"); double temp1, temp2; func(src, mask, minVal ? minVal : &temp1, maxVal ? maxVal : &temp2, buf); }
void cv::gpu::FastNonLocalMeansDenoising::labMethod( const GpuMat& src, GpuMat& dst, float h_luminance, float h_color, int search_window, int block_window, Stream& s) { CV_Assert(src.type() == CV_8UC3); lab.create(src.size(), src.type()); cv::gpu::cvtColor(src, lab, cv::COLOR_BGR2Lab, 0, s); l.create(src.size(), CV_8U); ab.create(src.size(), CV_8UC2); cudev::imgproc::fnlm_split_channels(lab, l, ab, StreamAccessor::getStream(s)); simpleMethod(l, l, h_luminance, search_window, block_window, s); simpleMethod(ab, ab, h_color, search_window, block_window, s); cudev::imgproc::fnlm_merge_channels(l, ab, lab, StreamAccessor::getStream(s)); cv::gpu::cvtColor(lab, dst, cv::COLOR_Lab2BGR, 0, s); }
void cv::gpu::blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, GpuMat& result, Stream& stream) { CV_Assert(img1.size() == img2.size()); CV_Assert(img1.type() == img2.type()); CV_Assert(weights1.size() == img1.size()); CV_Assert(weights2.size() == img2.size()); CV_Assert(weights1.type() == CV_32F); CV_Assert(weights2.type() == CV_32F); const Size size = img1.size(); const int depth = img1.depth(); const int cn = img1.channels(); result.create(size, CV_MAKE_TYPE(depth, cn)); switch (depth) { case CV_8U: if (cn != 4) blendLinearCaller<uchar>(size.height, size.width, cn, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream)); else blendLinearCaller8UC4(size.height, size.width, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream)); break; case CV_32F: blendLinearCaller<float>(size.height, size.width, cn, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream)); break; default: CV_Error(CV_StsUnsupportedFormat, "bad image depth in linear blending function"); } }
double cv::gpu::norm(const GpuMat& src, int normType, const GpuMat& mask, GpuMat& buf) { CV_Assert(normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2); CV_Assert(mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size() && src.channels() == 1)); GpuMat src_single_channel = src.reshape(1); if (normType == NORM_L1) return absSum(src_single_channel, mask, buf)[0]; if (normType == NORM_L2) return std::sqrt(sqrSum(src_single_channel, mask, buf)[0]); // NORM_INF double min_val, max_val; minMax(src_single_channel, &min_val, &max_val, mask, buf); return std::max(std::abs(min_val), std::abs(max_val)); }
void cv::cuda::magnitudeSqr(InputArray _src, OutputArray _dst, Stream& stream) { GpuMat src = _src.getGpuMat(); _dst.create(src.size(), CV_32FC1); GpuMat dst = _dst.getGpuMat(); npp_magnitude(src, dst, nppiMagnitudeSqr_32fc32f_C1R, StreamAccessor::getStream(stream)); }
void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode, Scalar borderValue, Stream& stream) { using namespace cv::gpu::device::imgproc; typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc); static const func_t funcs[6][4] = { {remap_gpu<uchar> , 0 /*remap_gpu<uchar2>*/ , remap_gpu<uchar3> , remap_gpu<uchar4> }, {0 /*remap_gpu<schar>*/, 0 /*remap_gpu<char2>*/ , 0 /*remap_gpu<char3>*/, 0 /*remap_gpu<char4>*/}, {remap_gpu<ushort> , 0 /*remap_gpu<ushort2>*/, remap_gpu<ushort3> , remap_gpu<ushort4> }, {remap_gpu<short> , 0 /*remap_gpu<short2>*/ , remap_gpu<short3> , remap_gpu<short4> }, {0 /*remap_gpu<int>*/ , 0 /*remap_gpu<int2>*/ , 0 /*remap_gpu<int3>*/ , 0 /*remap_gpu<int4>*/ }, {remap_gpu<float> , 0 /*remap_gpu<float2>*/ , remap_gpu<float3> , remap_gpu<float4> } }; CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size()); CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC); CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP); const func_t func = funcs[src.depth()][src.channels() - 1]; CV_Assert(func != 0); int gpuBorderType; CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType)); dst.create(xmap.size(), src.type()); Scalar_<float> borderValueFloat; borderValueFloat = borderValue; DeviceInfo info; int cc = info.majorVersion() * 10 + info.minorVersion(); Size wholeSize; Point ofs; src.locateROI(wholeSize, ofs); func(src, PtrStepSzb(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, xmap, ymap, dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(stream), cc); }
void cv::gpu::filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor, Stream& stream) { if( ddepth < 0 ) ddepth = src.depth(); dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels())); Ptr<FilterEngine_GPU> f = createLinearFilter_GPU(src.type(), dst.type(), kernel, anchor); f->apply(src, dst, Rect(0, 0, -1, -1), stream); }
void cv::gpu::GeneralizedHough_GPU::detect(const GpuMat& image, GpuMat& positions, int cannyThreshold) { CV_Assert(image.type() == CV_8UC1); CV_Assert(cannyThreshold > 0); ensureSizeIsEnough(image.size(), CV_8UC1, edges_); Canny(image, cannyBuf_, edges_, cannyThreshold / 2, cannyThreshold); detectImpl(edges_, cannyBuf_.dx, cannyBuf_.dy, positions); }
void cv::gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor) { if( ddepth < 0 ) ddepth = src.depth(); dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels())); Ptr<FilterEngine_GPU> f = createSeparableLinearFilter_GPU(src.type(), dst.type(), kernelX, kernelY, anchor); f->apply(src, dst); }
void cv::gpu::MOG2_GPU::operator()(const GpuMat& frame, GpuMat& fgmask, float learningRate, Stream& stream) { using namespace cv::gpu::cudev::mog; int ch = frame.channels(); int work_ch = ch; if (nframes_ == 0 || learningRate >= 1.0f || frame.size() != frameSize_ || work_ch != mean_.channels()) initialize(frame.size(), frame.type()); fgmask.create(frameSize_, CV_8UC1); fgmask.setTo(cv::Scalar::all(0)); ++nframes_; learningRate = learningRate >= 0.0f && nframes_ > 1 ? learningRate : 1.0f / std::min(2 * nframes_, history); CV_Assert(learningRate >= 0.0f); mog2_gpu(frame, frame.channels(), fgmask, bgmodelUsedModes_, weight_, variance_, mean_, learningRate, -learningRate * fCT, bShadowDetection, StreamAccessor::getStream(stream)); }
void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst) { class LevelsInit { public: Npp32s pLevels[256]; const Npp32s* pLevels3[3]; int nValues3[3]; LevelsInit() { nValues3[0] = nValues3[1] = nValues3[2] = 256; for (int i = 0; i < 256; ++i) pLevels[i] = i; pLevels3[0] = pLevels3[1] = pLevels3[2] = pLevels; } }; static LevelsInit lvls; int cn = src.channels(); CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC3); CV_Assert(lut.depth() == CV_8U && (lut.channels() == 1 || lut.channels() == cn) && lut.rows * lut.cols == 256 && lut.isContinuous()); dst.create(src.size(), CV_MAKETYPE(lut.depth(), cn)); NppiSize sz; sz.height = src.rows; sz.width = src.cols; Mat nppLut; lut.convertTo(nppLut, CV_32S); if (src.type() == CV_8UC1) { nppSafeCall( nppiLUT_Linear_8u_C1R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, nppLut.ptr<Npp32s>(), lvls.pLevels, 256) ); } else { Mat nppLut3[3]; const Npp32s* pValues3[3]; if (nppLut.channels() == 1) pValues3[0] = pValues3[1] = pValues3[2] = nppLut.ptr<Npp32s>(); else { cv::split(nppLut, nppLut3); pValues3[0] = nppLut3[0].ptr<Npp32s>(); pValues3[1] = nppLut3[1].ptr<Npp32s>(); pValues3[2] = nppLut3[2].ptr<Npp32s>(); } nppSafeCall( nppiLUT_Linear_8u_C3R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, pValues3, lvls.pLevels3, lvls.nValues3) ); } }
void cv::cuda::remap(InputArray _src, OutputArray _dst, InputArray _xmap, InputArray _ymap, int interpolation, int borderMode, Scalar borderValue, Stream& stream) { using namespace cv::cuda::device::imgproc; typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); static const func_t funcs[6][4] = { {remap_gpu<uchar> , 0 /*remap_gpu<uchar2>*/ , remap_gpu<uchar3> , remap_gpu<uchar4> }, {0 /*remap_gpu<schar>*/, 0 /*remap_gpu<char2>*/ , 0 /*remap_gpu<char3>*/, 0 /*remap_gpu<char4>*/}, {remap_gpu<ushort> , 0 /*remap_gpu<ushort2>*/, remap_gpu<ushort3> , remap_gpu<ushort4> }, {remap_gpu<short> , 0 /*remap_gpu<short2>*/ , remap_gpu<short3> , remap_gpu<short4> }, {0 /*remap_gpu<int>*/ , 0 /*remap_gpu<int2>*/ , 0 /*remap_gpu<int3>*/ , 0 /*remap_gpu<int4>*/ }, {remap_gpu<float> , 0 /*remap_gpu<float2>*/ , remap_gpu<float3> , remap_gpu<float4> } }; GpuMat src = _src.getGpuMat(); GpuMat xmap = _xmap.getGpuMat(); GpuMat ymap = _ymap.getGpuMat(); CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); CV_Assert( xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size() ); CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC ); CV_Assert( borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP ); const func_t func = funcs[src.depth()][src.channels() - 1]; if (!func) CV_Error(Error::StsUnsupportedFormat, "Unsupported input type"); _dst.create(xmap.size(), src.type()); GpuMat dst = _dst.getGpuMat(); Scalar_<float> borderValueFloat; borderValueFloat = borderValue; Size wholeSize; Point ofs; src.locateROI(wholeSize, ofs); func(src, PtrStepSzb(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, xmap, ymap, dst, interpolation, borderMode, borderValueFloat.val, StreamAccessor::getStream(stream), deviceSupports(FEATURE_SET_COMPUTE_20)); }
void cv::gpu::boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor) { int sdepth = src.depth(), cn = src.channels(); if( ddepth < 0 ) ddepth = sdepth; dst.create(src.size(), CV_MAKETYPE(ddepth, cn)); Ptr<FilterEngine_GPU> f = createBoxFilter_GPU(src.type(), dst.type(), ksize, anchor); f->apply(src, dst); }
void cv::gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor, int rowBorderType, int columnBorderType, Stream& stream) { if( ddepth < 0 ) ddepth = src.depth(); dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels())); Ptr<FilterEngine_GPU> f = createSeparableLinearFilter_GPU(src.type(), dst.type(), kernelX, kernelY, anchor, rowBorderType, columnBorderType); f->apply(src, dst, Rect(0, 0, src.cols, src.rows), stream); }
void cv::gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int cmpop) { CV_DbgAssert(src1.size() == src2.size() && src1.type() == src2.type()); CV_Assert(src1.type() == CV_8UC4 || src1.type() == CV_32FC1); dst.create( src1.size(), CV_8UC1 ); static const NppCmpOp nppCmpOp[] = { NPP_CMP_EQ, NPP_CMP_GREATER, NPP_CMP_GREATER_EQ, NPP_CMP_LESS, NPP_CMP_LESS_EQ }; NppiSize sz; sz.width = src1.cols; sz.height = src1.rows; if (src1.type() == CV_8UC4) { if (cmpop != CMP_NE) { nppSafeCall( nppiCompare_8u_C4R(src1.ptr<Npp8u>(), src1.step, src2.ptr<Npp8u>(), src2.step, dst.ptr<Npp8u>(), dst.step, sz, nppCmpOp[cmpop]) ); } else { mathfunc::compare_ne_8uc4(src1, src2, dst); } } else { if (cmpop != CMP_NE) { nppSafeCall( nppiCompare_32f_C1R(src1.ptr<Npp32f>(), src1.step, src2.ptr<Npp32f>(), src2.step, dst.ptr<Npp8u>(), dst.step, sz, nppCmpOp[cmpop]) ); } else { mathfunc::compare_ne_32f(src1, src2, dst); } } }
void cv::gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& s) { CV_DbgAssert(src1.size() == src2.size() && src1.type() == src2.type()); CV_Assert(src1.type() == CV_8UC1 || src1.type() == CV_8UC4 || src1.type() == CV_32SC1 || src1.type() == CV_32FC1); dst.create( src1.size(), src1.type() ); NppiSize sz; sz.width = src1.cols; sz.height = src1.rows; cudaStream_t stream = StreamAccessor::getStream(s); NppStreamHandler h(stream); switch (src1.type()) { case CV_8UC1: nppSafeCall( nppiAbsDiff_8u_C1R(src1.ptr<Npp8u>(), static_cast<int>(src1.step), src2.ptr<Npp8u>(), static_cast<int>(src2.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz) ); break; case CV_8UC4: nppSafeCall( nppiAbsDiff_8u_C4R(src1.ptr<Npp8u>(), static_cast<int>(src1.step), src2.ptr<Npp8u>(), static_cast<int>(src2.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz) ); break; case CV_32SC1: nppSafeCall( nppiAbsDiff_32s_C1R(src1.ptr<Npp32s>(), static_cast<int>(src1.step), src2.ptr<Npp32s>(), static_cast<int>(src2.step), dst.ptr<Npp32s>(), static_cast<int>(dst.step), sz) ); break; case CV_32FC1: nppSafeCall( nppiAbsDiff_32f_C1R(src1.ptr<Npp32f>(), static_cast<int>(src1.step), src2.ptr<Npp32f>(), static_cast<int>(src2.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step), sz) ); break; default: CV_Assert(!"Unsupported source type"); } if (stream == 0) cudaSafeCall( cudaDeviceSynchronize() ); }
void cv::gpu::absdiff(const GpuMat& src, const Scalar& s, GpuMat& dst) { CV_Assert(src.type() == CV_32FC1); dst.create( src.size(), src.type() ); NppiSize sz; sz.width = src.cols; sz.height = src.rows; nppSafeCall( nppiAbsDiffC_32f_C1R(src.ptr<Npp32f>(), src.step, dst.ptr<Npp32f>(), dst.step, sz, (Npp32f)s[0]) ); }
void cv::gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, int borderType, Stream& stream) { using namespace ::cv::gpu::cudev::imgproc; CV_Assert(borderType == cv::BORDER_REFLECT101 || borderType == cv::BORDER_REPLICATE || borderType == cv::BORDER_REFLECT); extractCovData(src, Dx, Dy, buf, blockSize, ksize, borderType, stream); dst.create(src.size(), CV_32F); cornerMinEigenVal_gpu(blockSize, Dx, Dy, dst, borderType, StreamAccessor::getStream(stream)); }
void cv::cuda::fastNlMeansDenoisingColored(InputArray _src, OutputArray _dst, float h_luminance, float h_color, int search_window, int block_window, Stream& stream) { const GpuMat src = _src.getGpuMat(); CV_Assert(src.type() == CV_8UC3); BufferPool pool(stream); GpuMat lab = pool.getBuffer(src.size(), src.type()); cv::cuda::cvtColor(src, lab, cv::COLOR_BGR2Lab, 0, stream); GpuMat l = pool.getBuffer(src.size(), CV_8U); GpuMat ab = pool.getBuffer(src.size(), CV_8UC2); device::imgproc::fnlm_split_channels(lab, l, ab, StreamAccessor::getStream(stream)); fastNlMeansDenoising(l, l, h_luminance, search_window, block_window, stream); fastNlMeansDenoising(ab, ab, h_color, search_window, block_window, stream); device::imgproc::fnlm_merge_channels(l, ab, lab, StreamAccessor::getStream(stream)); cv::cuda::cvtColor(lab, _dst, cv::COLOR_Lab2BGR, 0, stream); }
void cv::gpu::log(const GpuMat& src, GpuMat& dst) { CV_Assert(src.type() == CV_32FC1); dst.create(src.size(), src.type()); NppiSize sz; sz.width = src.cols; sz.height = src.rows; nppSafeCall( nppiLn_32f_C1R(src.ptr<Npp32f>(), src.step, dst.ptr<Npp32f>(), dst.step, sz) ); }
void cv::gpu::labelComponents(const GpuMat& mask, GpuMat& components, int flags, Stream& s) { CV_Assert(!mask.empty() && mask.type() == CV_8U); if (!deviceSupports(SHARED_ATOMICS)) CV_Error(CV_StsNotImplemented, "The device doesn't support shared atomics and communicative synchronization!"); components.create(mask.size(), CV_32SC1); cudaStream_t stream = StreamAccessor::getStream(s); device::ccl::labelComponents(mask, components, flags, stream); }
NCVStatus process(const GpuMat& src, GpuMat& objects, float scaleStep, int minNeighbors, bool findLargestObject, bool visualizeInPlace, cv::Size ncvMinSize, /*out*/unsigned int& numDetections) { calculateMemReqsAndAllocate(src.size()); NCVMemPtr src_beg; src_beg.ptr = (void*)src.ptr<Ncv8u>(); src_beg.memtype = NCVMemoryTypeDevice; NCVMemSegment src_seg; src_seg.begin = src_beg; src_seg.size = src.step * src.rows; NCVMatrixReuse<Ncv8u> d_src(src_seg, static_cast<int>(devProp.textureAlignment), src.cols, src.rows, static_cast<int>(src.step), true); ncvAssertReturn(d_src.isMemReused(), NCV_ALLOCATOR_BAD_REUSE); CV_Assert(objects.rows == 1); NCVMemPtr objects_beg; objects_beg.ptr = (void*)objects.ptr<NcvRect32u>(); objects_beg.memtype = NCVMemoryTypeDevice; NCVMemSegment objects_seg; objects_seg.begin = objects_beg; objects_seg.size = objects.step * objects.rows; NCVVectorReuse<NcvRect32u> d_rects(objects_seg, objects.cols); ncvAssertReturn(d_rects.isMemReused(), NCV_ALLOCATOR_BAD_REUSE); NcvSize32u roi; roi.width = d_src.width(); roi.height = d_src.height(); NcvSize32u winMinSize(ncvMinSize.width, ncvMinSize.height); Ncv32u flags = 0; flags |= findLargestObject? NCVPipeObjDet_FindLargestObject : 0; flags |= visualizeInPlace ? NCVPipeObjDet_VisualizeInPlace : 0; ncvStat = ncvDetectObjectsMultiScale_device( d_src, roi, d_rects, numDetections, haar, *h_haarStages, *d_haarStages, *d_haarNodes, *d_haarFeatures, winMinSize, minNeighbors, scaleStep, 1, flags, *gpuAllocator, *cpuAllocator, devProp, 0); ncvAssertReturnNcvStat(ncvStat); ncvAssertCUDAReturn(cudaStreamSynchronize(0), NCV_CUDA_ERROR); return NCV_SUCCESS; }
int cv::gpu::FAST_GPU::calcKeyPointsLocation(const GpuMat& img, const GpuMat& mask) { using namespace cv::gpu::cudev::fast; CV_Assert(img.type() == CV_8UC1); CV_Assert(mask.empty() || (mask.type() == CV_8UC1 && mask.size() == img.size())); int maxKeypoints = static_cast<int>(keypointsRatio * img.size().area()); ensureSizeIsEnough(1, maxKeypoints, CV_16SC2, kpLoc_); if (nonmaxSupression) { ensureSizeIsEnough(img.size(), CV_32SC1, score_); score_.setTo(Scalar::all(0)); } count_ = calcKeypoints_gpu(img, mask, kpLoc_.ptr<short2>(), maxKeypoints, nonmaxSupression ? score_ : PtrStepSzi(), threshold); count_ = std::min(count_, maxKeypoints); return count_; }
void cv::gpu::GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2) { if (ksize.width == 1 && ksize.height == 1) { src.copyTo(dst); return; } dst.create(src.size(), src.type()); Ptr<FilterEngine_GPU> f = createGaussianFilter_GPU(src.type(), ksize, sigma1, sigma2); f->apply(src, dst); }
void cv::gpu::GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2, int rowBorderType, int columnBorderType, Stream& stream) { if (ksize.width == 1 && ksize.height == 1) { src.copyTo(dst); return; } dst.create(src.size(), src.type()); Ptr<FilterEngine_GPU> f = createGaussianFilter_GPU(src.type(), ksize, sigma1, sigma2, rowBorderType, columnBorderType); f->apply(src, dst, Rect(0, 0, src.cols, src.rows), stream); }
void cv::gpu::GeneralizedHough_GPU::setTemplate(const GpuMat& templ, int cannyThreshold, Point templCenter) { CV_Assert(templ.type() == CV_8UC1); CV_Assert(cannyThreshold > 0); ensureSizeIsEnough(templ.size(), CV_8UC1, edges_); Canny(templ, cannyBuf_, edges_, cannyThreshold / 2, cannyThreshold); if (templCenter == Point(-1, -1)) templCenter = Point(templ.cols / 2, templ.rows / 2); setTemplateImpl(edges_, cannyBuf_.dx, cannyBuf_.dy, templCenter); }