Table Of Contents

Previous topic

Histogram Calculation

Next topic

Feature Detection

Hough Transform

cuda::HoughLinesDetector

class cuda::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;
};

cuda::HoughLinesDetector::detect

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

C++: void cuda::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 (\rho, \theta) . \rho is the distance from the coordinate origin (0,0) (top-left corner of the image). \theta is the line rotation angle in radians ( 0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line} ).

See also

HoughLines()

cuda::HoughLinesDetector::downloadResults

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

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

cuda::createHoughLinesDetector

Creates implementation for cuda::HoughLinesDetector .

C++: Ptr<HoughLinesDetector> cuda::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 ( >\texttt{threshold} ).
  • doSort – Performs lines sort by votes.
  • maxLines – Maximum number of output lines.

cuda::HoughSegmentDetector

class cuda::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

cuda::HoughSegmentDetector::detect

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

C++: void cuda::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 (x_1, y_1, x_2, y_2) , where (x_1,y_1) and (x_2, y_2) are the ending points of each detected line segment.

See also

HoughLinesP()

cuda::createHoughSegmentDetector

Creates implementation for cuda::HoughSegmentDetector .

C++: Ptr<HoughSegmentDetector> cuda::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.

cuda::HoughCirclesDetector

class cuda::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;
};

cuda::HoughCirclesDetector::detect

Finds circles in a grayscale image using the Hough transform.

C++: void cuda::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 (x, y, radius) .

See also

HoughCircles()

cuda::createHoughCirclesDetector

Creates implementation for cuda::HoughCirclesDetector .

C++: Ptr<HoughCirclesDetector> cuda::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.

cuda::createGeneralizedHoughBallard

Creates implementation for generalized hough transform from [Ballard1981] .

C++: Ptr<GeneralizedHoughBallard> cuda::createGeneralizedHoughBallard()

cuda::createGeneralizedHoughGuil

Creates implementation for generalized hough transform from [Guil1999] .

C++: Ptr<GeneralizedHoughGuil> cuda::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.