Skip to content

HoughLines

Image processingfunctionOpenCV 5.0.0
import { HoughLines } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

example: samples/cpp/tutorial_code/ImgTrans/houghlines.cpp An example using the Hough line detector Sample input image Output image example: samples/python/snippets/houghlines.py An example using the Hough line detector in python Finds lines in a binary image using the standard Hough transform.

The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See https://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform.

HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number, stn: number, min_theta: number, max_theta: number, use_edgeval: boolean): void;
6 available overloads
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number): void;
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number): void;
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number, stn: number): void;
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number, stn: number, min_theta: number): void;
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number, stn: number, min_theta: number, max_theta: number): void;
HoughLines(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, srn: number, stn: number, min_theta: number, max_theta: number, use_edgeval: boolean): void;
image

8-bit, single-channel binary source image. The image may be modified by the function.

lines

Output destination, filled by the native operation. Output vector of lines. Each line is represented by a 2 or 3 element vector (\rho, \theta) or (\rho, \theta, \textrm{votes}), where \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} ), and \textrm{votes} is the value of accumulator.

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} ).

srn

For the multi-scale Hough transform, it is a divisor for the distance resolution rho. The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these parameters should be positive.

stn

For the multi-scale Hough transform, it is a divisor for the distance resolution theta.

min_theta

For standard and multi-scale Hough transform, minimum angle to check for lines. Must fall between 0 and max_theta.

max_theta

For standard and multi-scale Hough transform, an upper bound for the angle. Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly less than max_theta, depending on the parameters min_theta and theta.

use_edgeval

True if you want to use weighted Hough transform.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.