ComfyUI Node

unpack_box2

Crack a bounding box open into plain integers

By cardenluo·Created 2 years ago·Updated a day ago· 324
unpack_box2
  • box2
  • w
  • h
  • x
  • y

unpack_box2 takes a BOX2 - a single bounding-box bundle - and hands you its four parts as plain integers: w, h, x, and y. If you've ever received a box as one opaque wire and then needed the raw numbers to feed into a crop, a resize, or a bit of math, this is the node that opens it up.

The reason boxes travel as bundles in the first place is graph hygiene. The whole philosophy of this pack is the "Loader - Controller - Sampler" framework, where the controller stacks pass compact bundles around so your canvas doesn't look like a plate of spaghetti. A BOX2 is one such bundle: it keeps a region's geometry in a single wire, which is great until you actually need to compute with it. That's the moment the unpack node earns its keep.

How it works

The box arrives as a tuple holding (x, y, w, h). The node splits it and emits each value on its own INT output. There's no math, no interpretation - it's the region equivalent of a type conversion, and that's all it should be. You connect the BOX2 output of whatever stack or detector node produced it, and four typed ints come out the other side.

The inputs and outputs that matter

Only one input, which keeps the risk of misuse low:

  • box2 (BOX2) - the required input. Wire in the box bundle from a region/box-producing node in the pack.

Four outputs:

  • w (INT) - width of the box
  • h (INT) - height
  • x (INT) - left/top-left coordinate
  • y (INT) - top coordinate

These feed the standard consumers: crop nodes, region resize, or arithmetic like centering a box in a canvas before a masked resample.

How to install it

It's part of ComfyUI-Apt_Preset, so one install covers it. ComfyUI Manager can fetch it by searching "ComfyUI-Apt_Preset", or:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset

then run install.bat (Windows) or pip install -r requirements.txt and restart ComfyUI. No model downloads - this is pure plumbing, nothing heavy to fetch.

Common issues & troubleshooting

The realistic gotcha isn't the node, it's the box. Different packs define their box tuples differently - (x, y, w, h) versus (x1, y1, x2, y2). This node expects the pack's BOX2 format. If you feed it a box from another pack and your crops come out shifted or a weird size, that's a format mismatch, not a bug. If you're mixing box types across packs, check which convention each side uses before wiring.

And the usual pack-level note: this is a niche pack by a Bilibili-based author, with a translated README and terse node names. The most common real-world issue with the pack is an IMPORT FAILED in custom_nodes when dependencies aren't installed - run install.bat, restart ComfyUI, and confirm the node list before you start debugging the workflow itself.

CategoryApt_Preset/stack

Inputs (1)

NameTypeDefaultDescription
box2BOX2

Outputs (4)

NameTypeDescription
wINT
hINT
xINT
yINT