BBox to XYWH
One detection, converted to a usable crop
- bbox
- StrBox
- BOXES
- X_coord
- Y_coord
- Width
- Height
YOLO boxes are stored with x/y at the center of the box: x, y, width, height. ComfyUI's crop and inpaint tooling generally expects the top-left corner. This node is the translator - and it also picks a single detection out of the batch, which is the part people underrate.
Inputs: bbox (the BOXES output from UltralyticsInference) and index (which detection you want, default 0). It outputs X_coord, Y_coord, Width, Height as ints - the box converted to top-left form - plus StrBox, a human-readable "x: .., y: .., w: .., h: .." string you can drop into a text display, and a BOXES output that passes the original box through.
The classic workflow: detect a face with YOLO, pick index 0, feed the four ints into a crop node, and you've got a tight crop of just that face for a detail pass or an upscale - the same detect-then-crop idea that makes FaceDetailer work, done manually and visibly. That's the whole reason this node exists: turning a raw detection into coordinates a crop node will accept.
It's marked as an output node in the schema, so ComfyUI treats it as a terminal - the StrBox string shows up in its widget, handy for eyeballing what a detection actually resolved to. The conversion math is simple and correct: top_left = center − w/2. Everything here matches the source.
Install is the shared pack story - Manager (search "ComfyUI-YOLO"), or clone into custom_nodes, restart, and let it grab ultralytics>=8.2.27. The only thing to remember is that index counts detections from 0, and which one you get depends on the order the detector returned them. Three people in frame and you want the second? That's index 1 - and it may not be the "second" person the way you'd think.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 0 | — |
| bbox | BOXES | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| StrBox | STRING | — |
| BOXES | INT | — |
| X_coord | INT | — |
| Y_coord | INT | — |
| Width | INT | — |
| Height | INT | — |