Hough line detection
Let edge pixels vote for lines in a parameter space.
A supported shape is mixed with a few unrelated edge samples.
Each observation votes for compatible shapes. Agreement accumulates even when the visible boundary has gaps.
A strong accumulator peak identifies a plausible centre or line parameter pair. This view illustrates the voting mechanism.
The recovered geometry follows the consistent observations; isolated samples do not define the final shape.
Find strong peaks or supported line segments.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Run Canny first, then detect and draw probabilistic Hough line segments.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Detect document borders, lane-like structures or long straight edges.
How it works
- 01Represent a line by its normal angle and distance from the origin.
- 02Accumulate votes from compatible edge pixels.
- 03Find strong peaks or supported line segments.
ρ = x cos θ + y sin θ
What to tune
rho and theta set accumulator resolution; threshold sets vote support; HoughLinesP adds minLineLength and maxLineGap.
Where it breaks down
Texture creates extra votes. The probabilistic variant reports finite segments and depends on gap and length settings.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Image resizing
Sample the source on a new pixel grid at a different resolution.
Arbitrary remapping
Provide a source coordinate for every destination pixel.
Affine transformations
Map points with a linear transform plus translation, preserving straight lines and parallelism.
Homography and RANSAC
Estimate a projective mapping between two views of a plane, rejecting inconsistent point matches.