### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0.0-dev documentation »
- OpenCV API Reference »
- gpuimgproc. GPU-accelerated Image Processing »

# Hough Transform

## gpu::HoughLinesDetector

class `gpu::``HoughLinesDetector` : public `Algorithm`

Base class for lines detector algorithm.

    class CV_EXPORTS HoughLinesDetector : public Algorithm
    {
    public:
        virtual void detect(InputArray src, OutputArray lines) = 0;
        virtual void downloadResults(InputArray d_lines, OutputArray h_lines, OutputArray h_votes = noArray()) = 0;

        virtual void setRho(float rho) = 0;
        virtual float getRho() const = 0;

        virtual void setTheta(float theta) = 0;
        virtual float getTheta() const = 0;

        virtual void setThreshold(int threshold) = 0;
        virtual int getThreshold() const = 0;

        virtual void setDoSort(bool doSort) = 0;
        virtual bool getDoSort() const = 0;

        virtual void setMaxLines(int maxLines) = 0;
        virtual int getMaxLines() const = 0;
    };

## gpu::HoughLinesDetector::detect

Finds lines in a binary image using the classical Hough transform.

C++:`` void `gpu::HoughLinesDetector::``detect`(InputArray src, OutputArray lines)

  Parameters: | src – 8-bit, single-channel binary source image. lines – Output vector of lines. Each line is represented by a two-element vector . is the distance from the coordinate origin (top-left corner of the image). is the line rotation angle in radians ( ).

See also

`HoughLines()`

## gpu::HoughLinesDetector::downloadResults

Downloads results from `gpu::HoughLinesDetector::detect()` to host memory.

C++:`` void `gpu::HoughLinesDetector::``downloadResults`(InputArray d_lines, OutputArray h_lines, OutputArray h_votes=noArray())

  Parameters: | d_lines – Result of `gpu::HoughLinesDetector::detect()` . h_lines – Output host array. h_votes – Optional output array for line’s votes.

## gpu::createHoughLinesDetector

Creates implementation for `gpu::HoughLinesDetector` .

C++:`` Ptr<HoughLinesDetector> `gpu::``createHoughLinesDetector`(float rho, float theta, int threshold, bool doSort=false, int maxLines=4096)

  Parameters: | rho – Distance resolution of the accumulator in pixels. theta – Angle resolution of the accumulator in radians. threshold – Accumulator threshold parameter. Only those lines are returned that get enough votes ( ). doSort – Performs lines sort by votes. maxLines – Maximum number of output lines.

## gpu::HoughSegmentDetector

class `gpu::``HoughSegmentDetector` : public `Algorithm`

Base class for line segments detector algorithm.

    class CV_EXPORTS HoughSegmentDetector : public Algorithm
    {
    public:
        virtual void detect(InputArray src, OutputArray lines) = 0;

        virtual void setRho(float rho) = 0;
        virtual float getRho() const = 0;

        virtual void setTheta(float theta) = 0;
        virtual float getTheta() const = 0;

        virtual void setMinLineLength(int minLineLength) = 0;
        virtual int getMinLineLength() const = 0;

        virtual void setMaxLineGap(int maxLineGap) = 0;
        virtual int getMaxLineGap() const = 0;

        virtual void setMaxLines(int maxLines) = 0;
        virtual int getMaxLines() const = 0;
    };

Note

- An example using the Hough segment detector can be found at opencv_source_code/samples/gpu/houghlines.cpp

## gpu::HoughSegmentDetector::detect

Finds line segments in a binary image using the probabilistic Hough transform.

C++:`` void `gpu::HoughSegmentDetector::``detect`(InputArray src, OutputArray lines)

  Parameters: | src – 8-bit, single-channel binary source image. lines – Output vector of lines. Each line is represented by a 4-element vector , where and are the ending points of each detected line segment.

See also

`HoughLinesP()`

## gpu::createHoughSegmentDetector

Creates implementation for `gpu::HoughSegmentDetector` .

C++:`` Ptr<HoughSegmentDetector> `gpu::``createHoughSegmentDetector`(float rho, float theta, int minLineLength, int maxLineGap, int maxLines=4096)

  Parameters: | rho – Distance resolution of the accumulator in pixels. theta – Angle resolution of the accumulator in radians. minLineLength – Minimum line length. Line segments shorter than that are rejected. maxLineGap – Maximum allowed gap between points on the same line to link them. maxLines – Maximum number of output lines.

## gpu::HoughCirclesDetector

class `gpu::``HoughCirclesDetector` : public `Algorithm`

Base class for circles detector algorithm.

    class CV_EXPORTS HoughCirclesDetector : public Algorithm
    {
    public:
        virtual void detect(InputArray src, OutputArray circles) = 0;

        virtual void setDp(float dp) = 0;
        virtual float getDp() const = 0;

        virtual void setMinDist(float minDist) = 0;
        virtual float getMinDist() const = 0;

        virtual void setCannyThreshold(int cannyThreshold) = 0;
        virtual int getCannyThreshold() const = 0;

        virtual void setVotesThreshold(int votesThreshold) = 0;
        virtual int getVotesThreshold() const = 0;

        virtual void setMinRadius(int minRadius) = 0;
        virtual int getMinRadius() const = 0;

        virtual void setMaxRadius(int maxRadius) = 0;
        virtual int getMaxRadius() const = 0;

        virtual void setMaxCircles(int maxCircles) = 0;
        virtual int getMaxCircles() const = 0;
    };

## gpu::HoughCirclesDetector::detect

Finds circles in a grayscale image using the Hough transform.

C++:`` void `gpu::HoughCirclesDetector::``detect`(InputArray src, OutputArray circles)

  Parameters: | src – 8-bit, single-channel grayscale input image. circles – Output vector of found circles. Each vector is encoded as a 3-element floating-point vector .

See also

`HoughCircles()`

## gpu::createHoughCirclesDetector

Creates implementation for `gpu::HoughCirclesDetector` .

C++:`` Ptr<HoughCirclesDetector> `gpu::``createHoughCirclesDetector`(float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles=4096)

  Parameters: | dp – Inverse ratio of the accumulator resolution to the image resolution. For example, if `dp=1` , the accumulator has the same resolution as the input image. If `dp=2` , the accumulator has half as big width and height. minDist – Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed. cannyThreshold – The higher threshold of the two passed to Canny edge detector (the lower one is twice smaller). votesThreshold – The accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. minRadius – Minimum circle radius. maxRadius – Maximum circle radius. maxCircles – Maximum number of output circles.

## gpu::createGeneralizedHoughBallard

Creates implementation for generalized hough transform from [Ballard1981] .

C++:`` Ptr<GeneralizedHoughBallard> `gpu::``createGeneralizedHoughBallard`()

## gpu::createGeneralizedHoughGuil

Creates implementation for generalized hough transform from [Guil1999] .

C++:`` Ptr<GeneralizedHoughGuil> `gpu::``createGeneralizedHoughGuil`()

[Ballard1981] | Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.

[Guil1999] | 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.

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0.0-dev documentation »
- OpenCV API Reference »
- gpuimgproc. GPU-accelerated Image Processing »