Gemini Bboxes to Coords
The smallest node in the pack, and the one that completes the chain
- coords_json
- match_count
This is the closing link of the pack's pipeline. GeminiSpatialBBoxNode gives you pixel-space boxes; this node takes those boxes and hands back the center of each one as a plain {"x", "y", "label"} coordinate. No image input, no vision, no API - it's pure arithmetic on a JSON string, and it's over in a millisecond.
The full chain looks like this:
GeminiSpatialNode
→ json_output ──► GeminiSpatialBBoxNode ──► bboxes_json ──► this node ──► coords_json
Boxes are the right shape when you're masking or detailing. But plenty of jobs only care about where the middle is - aiming a crop, placing a mark, positioning something relative to a detected object, feeding a control point. That's the gap this node fills: it converts "a rectangle spanning from x1,y1 to x2,y2" into "one point, right in the middle."
How it works
It reads the bboxes_json you give it, and for each entry computes the midpoint: x = (x1 + x2) // 2, y = (y1 + y2) // 2, keeping whatever label came along. It assumes the input is already in the pixel-space format the GeminiSpatialBBoxNode emits - keys x1, y1, x2, y2 - because that's the format the two nodes are built to chain.
Two outputs:
coords_json- a JSON string of center points.match_count- the number of boxes converted, i.e. the number of points you got.
The single input is bboxes_json, a multiline string defaulting to "[]". You can wire the bboxes_json output from GeminiSpatialBBoxNode straight into it, or paste the JSON by hand if you saved it.
The trap to know about
The node is forgiving to a fault. Every missing key silently defaults to 0, so if you feed it something that isn't the expected schema - a box in 0–1000 normalized space, a different key name, raw prose - it doesn't error; it quietly emits coordinates at the origin (0,0) with a matching match_count. A bunch of points in the top-left corner of your image is the symptom, and the fix is to check exactly what's in the bboxes_json you fed it. It is not a JSON validator, and it won't tell you it's confused.
Install is just the pack: search ComfyUI-Gemini-Spatial in ComfyUI Manager, or git clone https://github.com/nova452/ComfyUI-Gemini-Spatial into custom_nodes and restart. This is the one node in the pack you could honestly reimplement in five lines of Python - but if the boxes are already flowing through your graph, it's five lines you don't need to write.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| bboxes_json | STRING | [] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| coords_json | STRING | — |
| match_count | INT | — |