Get Started
Line Tracking
On this page
  1. Commands
  2. Settings
  3. Output Variables
  4. JSON Output

Line Tracking

For line-following robots. Detects a line on the floor and provides its offset from the frame center, its tilt angle, and its vector, which are used to correct steering.

Commands

CommandDescription
Line InfoWrites the detection result, offset, angle, vector, and line width of the detected line. This is the core command for steering control.
Has Line?Checks whether a line is detected.
All Info (JSON)Writes all line tracking information as JSON.

Settings

SettingDescription
Color ModeDark Line on Light BG (default), Light Line on Dark BG, or Custom Color. Custom Color detects lines whose color lies between the Start Color and End Color below.
Start Color / End ColorThe color range for Custom Color mode. Both default to #FF0000.
Sensitivity (%)0 to 100, default 50. Higher values detect faint lines but increase false detections; lower values detect only clear lines.

Output Variables

FieldTypeValue
DetectedDigitalTrue when a line is detected.
Offset X (-1~1)NumberHorizontal position of the line relative to the frame center: -1 (left edge) to 1 (right edge), 0 when centered. Used for left/right correction.
Angle (deg)NumberTilt of the line, -90 to 90 degrees, 0 when vertical. Used for heading correction.
Vector X0 / Y0 / X1 / Y1NumberPixel coordinates of the line vector's start (X0, Y0) and end (X1, Y1).
Line WidthNumberLine width as a fraction of the frame width, 0 to 1.
Output (JSON Text)TextA JSON object with all values.

When no line is detected, Detected becomes false and the remaining numeric values are written as 0.

JSON Output

A single object, not an array. offset_x and line_width are fractions as described in the table.

{
  "detected": true,
  "offset_x": 0.15,
  "angle": 12.5,
  "line_width": 0.06,
  "vector_x0": 100,
  "vector_y0": 200,
  "vector_x1": 540,
  "vector_y1": 210
}