提交 5da72400 编写于 作者: V Vladislav Vinogradov

made dependecy from gpufilters optional

上级 f614e354
......@@ -6,4 +6,4 @@ set(the_description "GPU-accelerated Image Processing")
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4100 /wd4324 /wd4512 /wd4515 -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter)
ocv_define_module(gpuimgproc opencv_imgproc opencv_gpufilters OPTIONAL opencv_gpuarithm)
ocv_define_module(gpuimgproc opencv_imgproc OPTIONAL opencv_gpuarithm opencv_gpufilters)
......@@ -122,7 +122,9 @@ namespace
GpuMat mag_;
GpuMat map_;
GpuMat st1_, st2_;
#ifdef HAVE_OPENCV_GPUFILTERS
Ptr<Filter> filterDX_, filterDY_;
#endif
int old_apperture_size_;
};
......@@ -152,10 +154,14 @@ namespace
}
else
{
#ifndef HAVE_OPENCV_GPUFILTERS
throw_no_cuda();
#else
filterDX_->apply(image, dx_);
filterDY_->apply(image, dy_);
canny::calcMagnitude(dx_, dy_, mag_, L2gradient_);
#endif
}
CannyCaller(edges);
......@@ -191,12 +197,14 @@ namespace
ensureSizeIsEnough(image_size, CV_32SC1, dx_);
ensureSizeIsEnough(image_size, CV_32SC1, dy_);
#ifdef HAVE_OPENCV_GPUFILTERS
if (apperture_size_ != 3 && apperture_size_ != old_apperture_size_)
{
filterDX_ = gpu::createDerivFilter(CV_8UC1, CV_32S, 1, 0, apperture_size_, false, 1, BORDER_REPLICATE);
filterDY_ = gpu::createDerivFilter(CV_8UC1, CV_32S, 0, 1, apperture_size_, false, 1, BORDER_REPLICATE);
old_apperture_size_ = apperture_size_;
}
#endif
ensureSizeIsEnough(image_size, CV_32FC1, mag_);
ensureSizeIsEnough(image_size, CV_32SC1, map_);
......
......@@ -45,7 +45,7 @@
using namespace cv;
using namespace cv::gpu;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || !defined(HAVE_OPENCV_GPUFILTERS)
Ptr<gpu::CornernessCriteria> cv::gpu::createHarrisCorner(int, int, int, double, int) { throw_no_cuda(); return Ptr<gpu::CornernessCriteria>(); }
Ptr<gpu::CornernessCriteria> cv::gpu::createMinEigenValCorner(int, int, int, int) { throw_no_cuda(); return Ptr<gpu::CornernessCriteria>(); }
......
......@@ -48,6 +48,10 @@
#include "opencv2/core/cuda/saturate_cast.hpp"
#include "opencv2/core/cuda/border_interpolate.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_GPUFILTERS
namespace cv { namespace gpu { namespace cudev
{
namespace imgproc
......@@ -271,4 +275,6 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
#endif
#endif // HAVE_OPENCV_GPUFILTERS
#endif // CUDA_DISABLER
......@@ -46,6 +46,10 @@
#include "opencv2/core/cuda/emulation.hpp"
#include "opencv2/core/cuda/dynamic_smem.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_GPUFILTERS
namespace cv { namespace gpu { namespace cudev
{
namespace hough_circles
......@@ -251,5 +255,6 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
#endif // HAVE_OPENCV_GPUFILTERS
#endif /* CUDA_DISABLER */
......@@ -133,22 +133,32 @@ namespace
virtual void detectImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, OutputArray positions) = 0;
private:
#ifdef HAVE_OPENCV_GPUFILTERS
GpuMat dx_, dy_;
GpuMat edges_;
Ptr<gpu::CannyEdgeDetector> canny_;
Ptr<gpu::Filter> filterDx_;
Ptr<gpu::Filter> filterDy_;
#endif
};
GeneralizedHoughBase::GeneralizedHoughBase()
{
#ifdef HAVE_OPENCV_GPUFILTERS
canny_ = gpu::createCannyEdgeDetector(50, 100);
filterDx_ = gpu::createSobelFilter(CV_8UC1, CV_32S, 1, 0);
filterDy_ = gpu::createSobelFilter(CV_8UC1, CV_32S, 0, 1);
#endif
}
void GeneralizedHoughBase::setTemplate(InputArray _templ, int cannyThreshold, Point templCenter)
{
#ifndef HAVE_OPENCV_GPUFILTERS
(void) _templ;
(void) cannyThreshold;
(void) templCenter;
throw_no_cuda();
#else
GpuMat templ = _templ.getGpuMat();
CV_Assert( templ.type() == CV_8UC1 );
......@@ -170,6 +180,7 @@ namespace
templCenter = Point(templ.cols / 2, templ.rows / 2);
setTemplateImpl(edges_, dx_, dy_, templCenter);
#endif
}
void GeneralizedHoughBase::setTemplate(InputArray _edges, InputArray _dx, InputArray _dy, Point templCenter)
......@@ -186,6 +197,12 @@ namespace
void GeneralizedHoughBase::detect(InputArray _image, OutputArray positions, int cannyThreshold)
{
#ifndef HAVE_OPENCV_GPUFILTERS
(void) _image;
(void) positions;
(void) cannyThreshold;
throw_no_cuda();
#else
GpuMat image = _image.getGpuMat();
CV_Assert( image.type() == CV_8UC1 );
......@@ -204,6 +221,7 @@ namespace
canny_->detect(dx_, dy_, edges_);
detectImpl(edges_, dx_, dy_, positions);
#endif
}
void GeneralizedHoughBase::detect(InputArray _edges, InputArray _dx, InputArray _dy, OutputArray positions)
......
......@@ -45,7 +45,7 @@
using namespace cv;
using namespace cv::gpu;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || !defined(HAVE_OPENCV_GPUFILTERS)
Ptr<gpu::HoughCirclesDetector> cv::gpu::createHoughCirclesDetector(float, float, int, int, int, int, int) { throw_no_cuda(); return Ptr<HoughCirclesDetector>(); }
......
......@@ -44,7 +44,6 @@
#define __OPENCV_PRECOMP_H__
#include "opencv2/gpuimgproc.hpp"
#include "opencv2/gpufilters.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
......@@ -56,4 +55,8 @@
# include "opencv2/gpuarithm.hpp"
#endif
#ifdef HAVE_OPENCV_GPUFILTERS
# include "opencv2/gpufilters.hpp"
#endif
#endif /* __OPENCV_PRECOMP_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册