ComfyUI Node
CV Fit Points To Box
Scales and centres a set of 2D points so they fill a width x height pixel box (with a margin), preserving the aspect ratio (one uniform scale for both axes) - turns metric coordinates like a triangulated cloud projected top-down ('CV Project To Plane') or a 'Compose Pose' trajectory into drawable pixels for 'CV Draw Points' / 'CV Draw Polygon'. Failure-tolerant: None/empty passes through as an empty array and a single point (or a zero-extent set) lands at the box centre, so it never divides by zero or raises.
CV Fit Points To Box
- points
- extent_from
- points
- scale
- offset_x
- offset_y
◄width300►
◄height300►
◄margin20►
◄y_axisy down (pixel rows)►
Categoryimage/CV/points
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| points | NPARRAY | 2D points, Nx2 or Nx1x2 (None/empty -> empty output). | |
| width | INT | 3001–16384 | Target box width in pixels (match your canvas). |
| height | INT | 3001–16384 | Target box height in pixels. |
| margin | INT | 200–4096 | Padding kept clear inside the box, in pixels. |
| extent_fromopt | NPARRAY | Take the range to fit from THESE points instead of 'points'. Two tracks fitted separately each fill the box, so overlaying them silently rescales one against the other - pass both tracks concatenated here (and to 'CV Draw Plot Frame') and every set shares one mapping. Empty = use 'points', as before. | |
| y_axisopt | COMBO | y down (pixel rows) | Which way the second coordinate grows on the canvas. Pixel rows grow DOWNWARD, so mapping a world axis straight onto them draws it upside down - for a top-down (XZ) map that mirrors the picture and a left turn comes out looking like a right turn. Choose 'y up (world)' whenever the second coordinate is a world axis you want read as a map; leave it 'y down' when the points are already in pixel space. Pass the SAME value to 'OpenCV Draw Plot Frame' so the grid and the data agree. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| points | NPARRAY | Points scaled into the box, Nx1x2 float32. |
| scale | FLOAT | Pixels per world unit, i.e. pixel = world * scale + offset. Feed it to a scale bar or a measurement. |
| offset_x | FLOAT | Pixel column that world x = 0 maps to. |
| offset_y | FLOAT | Pixel row that world y = 0 maps to. |