Skip to content

HoughLinesP

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

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

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

The function implements the probabilistic Hough transform algorithm for line detection, described in [Matas00]

See the line detection example below:

This is a sample picture the function parameters have been tuned for:

image

And this is the output of the above program in case of the probabilistic Hough transform:

image

See: LineSegmentDetector

HoughLinesP(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, minLineLength: number, maxLineGap: number): void;
3 available overloads
HoughLinesP(image: Mat, lines: Mat, rho: number, theta: number, threshold: number): void;
HoughLinesP(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, minLineLength: number): void;
HoughLinesP(image: Mat, lines: Mat, rho: number, theta: number, threshold: number, minLineLength: number, maxLineGap: number): 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 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.

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

minLineLength

Minimum line length. Line segments shorter than that are rejected.

maxLineGap

Maximum allowed gap between points on the same line to link them.

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.