Skip to content

Support vector machines

Algorithm atlasMachine learning

Learn a decision boundary that balances class separation against margin violations.

Try it on your image ↓

VISUAL WALKTHROUGHMachine learning
REFERENCE INPUTLabelled feature vectors

A linear decision boundary separates these two illustrative classes.

RESULTClassify a new feature vector

The side of the boundary determines the predicted class in this linear example. Kernel models can produce nonlinear boundaries.

STEP 03 / 03

Optimize the margin objective and predict labels or scores for new samples.

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 ↗

Train a colour classifier: samples inside the rectangle are foreground, image-border samples are background. Apply it to every pixel. This demonstrates supervised training, not semantic segmentation.

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

Classify image descriptors or build small supervised vision models.

How it works

  1. 01Arrange labelled feature vectors consistently.
  2. 02Select a linear or kernel-based decision model.
  3. 03Optimize the margin objective and predict labels or scores for new samples.

decision boundary with a margin around supported samples

What to tune

C controls violation cost; kernel parameters set similarity; choose the correct SVM type for classification, regression or one-class learning.

Where it breaks down

Training accuracy does not estimate generalization. Scaling, validation splits and hyperparameter selection matter.

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.