KJNodes/maskinggenerated

Bbox To Int(BboxToInt)

This node takes a list of BBOX type as input, which typically contains multiple bounding boxes defined by (x_min, y_min, width, height).

Bbox To Int

bboxes
x_min
y_min
width
height
center_x
center_y
index
0
KJNodes

The Bbox To Int node receives a list of BBOX type as input. This list typically contains multiple bounding boxes defined by (x_min, y_min, width, height).

The Bbox To Int node is a utility tool for processing bounding box data. Its core function is to extract a single bounding box at a specified index from a list of bounding boxes and decompose its geometric properties into separate integer value outputs. This allows subsequent nodes to conveniently use these specific coordinate and dimension values.

Node Function

This node receives a list of BBOX type as input. This list typically contains multiple bounding boxes defined by (x_min, y_min, width, height). The user specifies the position of the bounding box to extract from the list via the index parameter. Internally, the node calculates the center point coordinates of the selected bounding box and finally outputs all six values (four bounding parameters and two center point coordinates) as separate INT type outputs.

Node Parameter Description - Bbox To Int

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
bboxesBBOXYes--Input a list of bounding boxes. The node will extract the bounding box data at the specified index from this list. Type is BBOX.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
indexINTYes00 - 99999999 (Step: 1)Specifies the index position (starting from 0) of the bounding box to extract from the bboxes list. Valid range is 0 to 99999999 with a step of 1.

Output

Parameter NameData TypeDescription
x_minINTOutputs the X-axis coordinate of the top-left corner of the selected bounding box.
y_minINTOutputs the Y-axis coordinate of the top-left corner of the selected bounding box.
widthINTOutputs the width of the selected bounding box.
heightINTOutputs the height of the selected bounding box.
center_xINTOutputs the X-axis coordinate of the center point of the selected bounding box.
center_yINTOutputs the Y-axis coordinate of the center point of the selected bounding box.

Usage Scenarios

This node is very useful in workflows involving object detection and region refinement. For example, after using a detection model (such as YOLO or GroundingDino) to identify multiple objects in an image and generate a list of bounding boxes, you can use the Bbox To Int node to extract the bounding box of a specific object of interest (e.g., the first person). Subsequently, the output coordinates and dimensions can be passed to a Crop Image node to crop that region, or to other nodes that require specific numerical parameters for further processing.

Notes

Please note that the index parameter must be less than the length of the input bboxes list; otherwise, an index error will occur. Ensure that the bounding box list provided by the upstream node is not empty and that the index value is valid.

The Bbox To Int node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…