Console ↗

Box

A Box question returns top, left, bottom and right edges as fractions of image dimensions. Multiply horizontal coordinates by the displayed width and vertical coordinates by the displayed height. Check confidence before drawing a box.

bounds = answer['box']
x = bounds['left'] * width
y = bounds['top'] * height
w = (bounds['right'] - bounds['left']) * width
h = (bounds['bottom'] - bounds['top']) * height

Display the overlay

Apply the normalized coordinates to the displayed image content, excluding letterboxing. In Playground, expand the Box row to see the whole image with its box; the collapsed view shows the crop.

Measure both horizontal edges from the left and both vertical edges from the top. In an 800 × 600 image, this rectangle starts at (200, 150) and measures 400 × 300 pixels.