Skip to content

Hough line detection

Let edge pixels vote for lines in a parameter space.

Try it on your image ↓

VISUAL WALKTHROUGHGeometry
REFERENCE INPUTEdge observations

A supported shape is mixed with a few unrelated edge samples.

RESULTRecover a supported line

The recovered geometry follows the consistent observations; isolated samples do not define the final shape.

STEP 03 / 03

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

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Run Canny first, then detect and draw probabilistic Hough line segments.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

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
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Detect document borders, lane-like structures or long straight edges.

How it works

  1. 01Represent a line by its normal angle and distance from the origin.
  2. 02Accumulate votes from compatible edge pixels.
  3. 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.