Skip to content

Convex hulls and defects

Wrap a point set in its smallest convex boundary and measure inward deviations.

Try it on your image ↓

VISUAL WALKTHROUGHShape
REFERENCE INPUTShape with a concavity

The inward notch distinguishes the original boundary from its convex hull.

RESULTOuter convex envelope

For convexity defects, compare the original contour with hull edges.

STEP 03 / 03

For convexity defects, compare the original contour with hull edges.

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 ↗

Draw convex hulls around thresholded connected contours.

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

Estimate envelopes, detect concavities, or build coarse collision shapes.

How it works

  1. 01Order the points along the outside of the set.
  2. 02Discard turns that bend inward.
  3. 03For convexity defects, compare the original contour with hull edges.

hull = smallest convex set containing all points

What to tune

returnPoints chooses coordinates or contour indices. convexityDefects needs hull indices.

Where it breaks down

The hull intentionally discards concave detail. Defect depth uses the native fixed-point representation described in the API.

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.