> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/detections-shapes/shape-analysis/line-geometry.md).

# Line Geometry

This function block provides a single, flexible tool for a wide range of line and geometry operations: angles, distances, intersections, projections, midpoints, segment extraction and more. It can produce numeric results, points, extra operation-specific data and (optionally) an annotated image for visualization.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

* `Input Image` Optional image used for visualization overlays (if you want drawn lines, points or contours).
* `Line 1` Required for most operations. Accepts a line described as \[(x1, y1), (x2, y2)] or compatible shape input.
* `Line 2` Required for angle / intersection / some distance operations. Accepts a second line in the same format.
* `Anchor Point` Optional point (x, y) used by projection and point-to-line operations or when a contour is supplied for shape intersection.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

* `Output Image` Annotated image (if `Input Image` is provided and `Show Visualization` is enabled).
* `Result` Numerical result of the selected operation (for example angle in degrees or distance in pixels).
* `Point Output` A point result when the operation yields a coordinate (e.g., intersection, projection, midpoint).
* `Extra Output` Operation-specific data (for example segment endpoints, list of intersection points, or other debug info).

## 🕹️ Controls <a href="#controls" id="controls"></a>

* `Operation Type` Choose the geometry operation to perform (e.g., Angle Between Lines, Intersection Point, Segment Extraction, Projection).
* `Offset (px)` Slider used by segment / projection operations to apply an offset in pixels.
* `Interpolation Factor` Slider (0–100%) used for interpolation-based operations (segment extraction, projection along line).
* `Show Visualization` Checkbox toggles annotated `Output Image` drawing when an `Input Image` is provided.

## 🎯 Key Features <a href="#features" id="features"></a>

* Single multi-purpose block covering many common geometry tasks.
* Context-sensitive behavior: only the outputs relevant to the selected operation will contain meaningful data.
* Optional visual overlays: draw lines, midpoints, intersections, projections and segments directly on the provided image.
* Interactive tooltips and control hints help you select the right inputs and parameters for each operation.

## ⚙️ How it runs <a href="#running-mechanism" id="running-mechanism"></a>

When executed, the block reads the connected sockets and the selected `Operation Type`. It performs the requested geometric computation using the provided `Line 1`, optional `Line 2` and optional `Anchor Point`. If an `Input Image` is connected and `Show Visualization` is enabled, the block returns an annotated image in `Output Image`. Numeric and point results appear on the corresponding outputs based on the operation.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Select the desired operation in `Operation Type`.
2. Connect the required sockets: at minimum connect `Line 1`. Connect `Line 2` or `Anchor Point` where needed by the chosen operation.
3. Optionally provide `Input Image` and enable `Show Visualization` to get an annotated image overlay.
4. Adjust `Offset (px)` or `Interpolation Factor` when using Segment Extraction or Projection operations.
5. Run the scenario; inspect the `Result`, `Point Output` and/or `Extra Output` and view the visual overlay in `Output Image` or with a display block.

## 💡 Tips and Tricks (combining with other blocks) <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To get lines from contours or edges automatically, combine with `Find Contour` or `Line Detector` to extract shape/line data and feed the results into `Line Geometry`.
* Crop a region and do focused geometry with `Image ROI`, `Image ROI Select` or `Image ROI Polygon` before sending the image to this block — this reduces noise and improves results.
* Visualize outputs in the UI using `Show Image` so you can inspect annotated images and interactively verify points and intersections.
* If you need to overlay textual results on the annotated image for reports or dashboards, add `Draw Result On Image` after the visualized output.
* For measuring distances between detected features, use `Find Contour` or `Feature Detector` to locate points, then use `Line Geometry` to compute midpoints, distances or projections. Feed numeric point outputs to `Measure Position Distance` for additional distance breakdowns.
* To isolate only relevant detections before geometry calculations, use `Image ROI Select` or `Check Area (Polygon)` to filter positions and shapes.
* When combining detections and tracking workflows, use `Object Detection` or `Object Detection - Custom` upstream to provide coordinates, then use `Line Geometry` for analytics such as intersection checks or approach angle calculations.

(hint: use the block outputs like `Point Output` or `Extra Output` as inputs to other processing blocks such as `Measure Position Distance`, `Draw Point` or logging/export blocks.)

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If `Output Image` is empty: ensure an `Input Image` is connected and `Show Visualization` is enabled.
* If an operation returns no value in `Result` or `Point Output`: check that the required sockets for that operation are connected (for example, `Line 2` is required for angle/intersection operations).
* If coordinates seem wrong: verify the coordinate format and that lines are provided as \[(x1, y1), (x2, y2)]. Use preview blocks like `Show Image` or `Draw Point` to inspect intermediate points.
* For projection and interpolation results that look off, fine-tune `Offset (px)` and `Interpolation Factor` to match your expected scale and units.

If you need step-by-step visual checks, combine the block with `Show Image` and `Draw Point` to validate intermediate geometry before using results downstream.
