Bbox To Int
Unpack a bounding box into plain integers
- bboxes
- x_min
- y_min
- width
- height
- center_x
- center_y
Detection and segmentation nodes hand you a BBOX - a bounding box (or a list of them) around whatever they found: a face, a person, an object. The catch is that a BBOX is an opaque bundle, and half the time what you actually need is the raw numbers: crop coordinates, a width and height to size something, a center point to place a shape. BboxToInt cracks one box out of the list and gives you six plain integers you can wire anywhere. As its description puts it, it "returns selected index from bounding box list as integers."
It sits in the masking category of Kijai's KJNodes, which is where a lot of the detect-then-crop-then-composite plumbing lives. Detectors (the Impact Pack ones, YOLO, SAM-adjacent tools) are great at finding things; getting from "found it" to "now do math with its position" is where this little adapter earns its spot.
How it works
You give it the BBOX list and an index, and it reads out that one box's geometry as six integer outputs. No transformation, no clever logic - it's a converter from a typed bundle into numbers ComfyUI's INT-consuming nodes can actually use.
The inputs and outputs that matter
bboxes(BBOX) - the box list from your detector.index(INT, default 0) - which box to unpack. 0 is the first detection. If your detector sorts by confidence or size, index 0 is usually the "best" one.
Six INT outputs, and they're exactly what you'd want:
x_min,y_min- the top-left corner.width,height- the box size.center_x,center_y- the middle point.
Feed x_min/y_min/width/height into a crop node to cut out the region; feed center_x/center_y into a shape or text generator to drop something right where the detection is. That center pair saves you from computing it by hand every time.
How to install it
ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
then restart (portable: pip via python_embeded\python.exe). Nothing to download.
Common issues & troubleshooting
Index out of range. If your detector found two boxes and you ask for index 5, it errors. Worse, if it found nothing, index 0 is already out of range. Detection counts vary run to run, so don't hard-code an index you can't guarantee exists - and consider handling the zero-detection case upstream.
Wrong BBOX format. "BBOX" isn't perfectly universal across packs. Impact Pack, for one, works largely in SEGS and has its own way of exposing box coordinates; a raw BBOX from one source may not be shaped the way another node expects. If BboxToInt refuses your input, check what your detector actually outputs and convert if needed.
The crop is offset. Remember x_min/y_min is the corner, not the center. If your crop landed shifted, you probably wired center_x/center_y where the node wanted the corner, or vice versa. The two pairs are there precisely so you can pick the right anchor for the job.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| bboxes | BBOX | — | |
| index | INT | 00–99999999 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| x_min | INT | — |
| y_min | INT | — |
| width | INT | — |
| height | INT | — |
| center_x | INT | — |
| center_y | INT | — |