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
//! 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.
//! 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:
static Ptr<GeneralizedHough_GPU> create(int method);
GeneralizedHough_GPU();
virtual ~GeneralizedHough_GPU();
static Ptr<GeneralizedHough> create(int method);
//! set template to search
void setTemplate(const GpuMat& templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1));
void setTemplate(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter = Point(-1, -1));
virtual void setTemplate(InputArray templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1)) = 0;
virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0;
//! find template on image
void detect(const GpuMat& image, GpuMat& positions, int cannyThreshold = 100);
void detect(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions);
void download(const GpuMat& d_positions, OutputArray h_positions, OutputArray h_votes = noArray());
void release();
virtual void detect(InputArray image, OutputArray positions, int cannyThreshold = 100) = 0;
virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions) = 0;
protected:
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_;
virtual void downloadResults(InputArray d_positions, OutputArray h_positions, OutputArray h_votes = noArray()) = 0;
};
////////////////////////// Corners Detection ///////////////////////////
......
......@@ -286,7 +286,7 @@ PERF_TEST_P(Method_Sz, GeneralizedHough,
const cv::gpu::GpuMat d_dy(dy);
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)
{
d_hough->set("maxAngle", 90.0);
......
This diff is collapsed.
......@@ -218,7 +218,7 @@ GPU_TEST_P(GeneralizedHough, POSITION)
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->setTemplate(loadMat(templ, useRoi));
......@@ -227,7 +227,7 @@ GPU_TEST_P(GeneralizedHough, POSITION)
hough->detect(loadMat(image, useRoi), d_pos);
std::vector<cv::Vec4f> pos;
hough->download(d_pos, pos);
hough->downloadResults(d_pos, pos);
ASSERT_EQ(gold_count, pos.size());
......
......@@ -11,7 +11,7 @@
using namespace std;
using namespace cv;
using namespace cv::gpu;
using cv::gpu::GpuMat;
static Mat loadImage(const string& name)
{
......@@ -101,7 +101,7 @@ int main(int argc, const char* argv[])
GpuMat d_image(image);
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("levels", levels);
d_hough->set("dp", dp);
......@@ -134,7 +134,7 @@ int main(int argc, const char* argv[])
tm.start();
d_hough->detect(d_image, d_position);
d_hough->download(d_position, position);
d_hough->downloadResults(d_position, position);
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