Nodes/comfyui_cv/CV Crop by BBoxes
ComfyUI Node

CV Crop by BBoxes

Crops one region per bounding box, in the SOURCE'S OWN TYPE - IMAGE, MASK, NPARRAY or LATENT all work, and the slice is exact (no uint8 round trip), so crop -> process -> 'CV Paste by BBox' is lossless. The policy MODE picks the use case: '-> batch' stacks every crop at one common size (downstream runs once - the inpainting case), '-> list' emits one item per region at its own tight size (downstream runs once per region). The 'per-frame' modes pair region group g with frame g of a batch instead of reading frame 0. Several BOUNDING_BOX values wired in are simply concatenated - the type already nests one group per frame, so there is no separate 'box list' input. Boxes are in the source's own coordinate space (use 'CV Scale BBoxes' for a LATENT). Empty input yields an empty batch and never raises.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Crop by BBoxes
  • source
  • bboxes
  • crops
  • bboxes
  • width
  • height
  • count
policyone source, regions -> batch
Categoryimage/CV

Inputs (3)

NameTypeDefaultDescription
sourceCOMFY_MATCHTYPE_V3What to crop. IMAGE / MASK / NPARRAY / LATENT; the crops come back in the same type. A batch - or several inputs - flattens into one frame sequence.
bboxesBOUNDING_BOX[object Object]Core BOUNDING_BOX data: per-frame lists of {x, y, width, height} dicts - compatible with Draw BBoxes, Crop By Bounding Boxes, Image Crop, etc. Boxes in the source's coordinate space. The per-frame nesting IS the grouping; several values are concatenated.
policyoptSTRINGone source, regions -> batchWhich use case this crop serves. 'one source, regions -> batch' crops every region out of frame 0 at one common size and stacks them (the inpainting case - downstream runs once on the batch). '-> list' instead emits one item per region at its own tight size, so downstream runs once per region. The 'per-frame' modes pair region group g with frame g of a batch instead of always reading frame 0. Crop policy. In the UI this is a mode dropdown plus one widget per option; wire an 'CV Snap BBoxes' node in to drive several crop nodes from one place (the widgets then hide). A linked policy overrides only the fields it actually sets. Boxes are always clamped inside the source.

Outputs (5)

NameTypeDescription
cropsCOMFY_MATCHTYPE_V3One stacked batch (batch modes) or one item per region (list modes), in the source's own type.
bboxesBOUNDING_BOXCore BOUNDING_BOX data: per-frame lists of {x, y, width, height} dicts - compatible with Draw BBoxes, Crop By Bounding Boxes, Image Crop, etc. The SNAPPED boxes actually cropped, fanned out in lockstep with 'crops' - feed these to 'OpenCV Paste by BBox', not the input boxes.
widthINTCrop width (the largest one when sizes vary).
heightINTCrop height (the largest one when sizes vary).
countINTNumber of crops (regions), whatever the output shape.