Commit ad4d6bed authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

refactored gpu::GeneralizedHough

parent 4087a45e
...@@ -344,34 +344,20 @@ inline void HoughCircles(InputArray src, OutputArray circles, int /*method*/, fl ...@@ -344,34 +344,20 @@ inline void HoughCircles(InputArray src, OutputArray circles, int /*method*/, fl
//! finds arbitrary template in the grayscale image using Generalized Hough Transform //! finds arbitrary template in the grayscale image using Generalized Hough Transform
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122. //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038. //! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
class CV_EXPORTS GeneralizedHough_GPU : public cv::Algorithm class CV_EXPORTS GeneralizedHough : public Algorithm
{ {
public: public:
static Ptr<GeneralizedHough_GPU> create(int method); static Ptr<GeneralizedHough> create(int method);
GeneralizedHough_GPU();
virtual ~GeneralizedHough_GPU();
//! set template to search //! set template to search
void setTemplate(const GpuMat& templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1)); virtual void setTemplate(InputArray templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1)) = 0;
void setTemplate(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter = Point(-1, -1)); virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0;
//! find template on image //! find template on image
void detect(const GpuMat& image, GpuMat& positions, int cannyThreshold = 100); virtual void detect(InputArray image, OutputArray positions, int cannyThreshold = 100) = 0;
void detect(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions); virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions) = 0;
void download(const GpuMat& d_positions, OutputArray h_positions, OutputArray h_votes = noArray());
void release();
protected: virtual void downloadResults(InputArray d_positions, OutputArray h_positions, OutputArray h_votes = noArray()) = 0;
virtual void setTemplateImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter) = 0;
virtual void detectImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions) = 0;
virtual void releaseImpl() = 0;
private:
GpuMat edges_;
Ptr<CannyEdgeDetector> canny_;
}; };
////////////////////////// Corners Detection /////////////////////////// ////////////////////////// Corners Detection ///////////////////////////
......
...@@ -286,7 +286,7 @@ PERF_TEST_P(Method_Sz, GeneralizedHough, ...@@ -286,7 +286,7 @@ PERF_TEST_P(Method_Sz, GeneralizedHough,
const cv::gpu::GpuMat d_dy(dy); const cv::gpu::GpuMat d_dy(dy);
cv::gpu::GpuMat posAndVotes; cv::gpu::GpuMat posAndVotes;
cv::Ptr<cv::gpu::GeneralizedHough_GPU> d_hough = cv::gpu::GeneralizedHough_GPU::create(method); cv::Ptr<cv::gpu::GeneralizedHough> d_hough = cv::gpu::GeneralizedHough::create(method);
if (method & GHT_ROTATION) if (method & GHT_ROTATION)
{ {
d_hough->set("maxAngle", 90.0); d_hough->set("maxAngle", 90.0);
......
This diff is collapsed.
...@@ -218,7 +218,7 @@ GPU_TEST_P(GeneralizedHough, POSITION) ...@@ -218,7 +218,7 @@ GPU_TEST_P(GeneralizedHough, POSITION)
templ.copyTo(imageROI); templ.copyTo(imageROI);
} }
cv::Ptr<cv::gpu::GeneralizedHough_GPU> hough = cv::gpu::GeneralizedHough_GPU::create(cv::GeneralizedHough::GHT_POSITION); cv::Ptr<cv::gpu::GeneralizedHough> hough = cv::gpu::GeneralizedHough::create(cv::GeneralizedHough::GHT_POSITION);
hough->set("votesThreshold", 200); hough->set("votesThreshold", 200);
hough->setTemplate(loadMat(templ, useRoi)); hough->setTemplate(loadMat(templ, useRoi));
...@@ -227,7 +227,7 @@ GPU_TEST_P(GeneralizedHough, POSITION) ...@@ -227,7 +227,7 @@ GPU_TEST_P(GeneralizedHough, POSITION)
hough->detect(loadMat(image, useRoi), d_pos); hough->detect(loadMat(image, useRoi), d_pos);
std::vector<cv::Vec4f> pos; std::vector<cv::Vec4f> pos;
hough->download(d_pos, pos); hough->downloadResults(d_pos, pos);
ASSERT_EQ(gold_count, pos.size()); ASSERT_EQ(gold_count, pos.size());
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
using namespace std; using namespace std;
using namespace cv; using namespace cv;
using namespace cv::gpu; using cv::gpu::GpuMat;
static Mat loadImage(const string& name) static Mat loadImage(const string& name)
{ {
...@@ -101,7 +101,7 @@ int main(int argc, const char* argv[]) ...@@ -101,7 +101,7 @@ int main(int argc, const char* argv[])
GpuMat d_image(image); GpuMat d_image(image);
GpuMat d_position; GpuMat d_position;
Ptr<GeneralizedHough_GPU> d_hough = GeneralizedHough_GPU::create(method); Ptr<gpu::GeneralizedHough> d_hough = gpu::GeneralizedHough::create(method);
d_hough->set("minDist", minDist); d_hough->set("minDist", minDist);
d_hough->set("levels", levels); d_hough->set("levels", levels);
d_hough->set("dp", dp); d_hough->set("dp", dp);
...@@ -134,7 +134,7 @@ int main(int argc, const char* argv[]) ...@@ -134,7 +134,7 @@ int main(int argc, const char* argv[])
tm.start(); tm.start();
d_hough->detect(d_image, d_position); d_hough->detect(d_image, d_position);
d_hough->download(d_position, position); d_hough->downloadResults(d_position, position);
tm.stop(); tm.stop();
} }
......
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