AI identified the object. The bounding box shifted after conversion
Work with coordinates returned by AI: axis order, scale, crop and rotation. Follow a worked example from model input to preview.
Article language: English

In this article
Several boxes stand in a photograph. The model identifies the right blue one, but the box in the preview surrounds its neighbour. The label in the report is correct, and all four values are valid numbers, yet the employee is still looking at the wrong box. Before changing the AI prompt, trace what happened to those coordinates.
Identifying an object and displaying its location are two separate results. Between the two, an application may resize the photograph, crop it, rotate it or add margins. A correct location in one of those views will not necessarily be correct in another.
Consider a fictional workshop that labels boxes of paper samples. We are not controlling a device or a robot. The task is to mark an object in a photograph viewer. The conversion below was checked arithmetically using artificial data; it is not the result of a model analysing a photograph.
The same four numbers can mean different things
A bounding box is a rectangle around the identified object. To draw it, we need to know where distances start, how the position is represented and the dimensions of the reference image. A list of four values does not answer those questions by itself.
Also agree on what the rectangle should include. In the workshop it covers the visible box, excluding its shadow and papers sticking out of a neighbouring container. For this task, the box includes its visible open lid. That is a proposed workshop rule, not a property of every model. If one person marks only the body and another includes the lid, you will get two different reference annotations. Resolve that difference before evaluating the answer, or the disagreement about the box will begin before any conversion.
In the Gemini object detection example, the box is ordered ymin, xmin, ymax, xmax, with coordinates scaled to a range from 0 to 1000 relative to the image. The first value therefore refers to the vertical axis. This is the convention for the method described, not a universal format for every AI response.
The Amazon Rekognition BoundingBox reference instead describes the position of the top-left corner and the width and height as proportions of the image dimensions. The origin is at the top left. Values representing the rectangle's size are not the coordinates of the opposite corner. The reference also allows coordinates outside the image, for example when a face is only partly visible.
If an application swaps those two descriptions, it can draw a box without reporting an error. That is why valid JSON does not establish what the data means (in Polish). Acceptance should cover field names, axis order and units, not just the presence of four numbers.
For a particular integration, write a simple input and output description: which file was sent to the model, its dimensions, how to interpret the returned values and which image they will be used on. Do not leave this under a label such as "standard coordinates". What is standard to one tool is not necessarily familiar to the next.
Base range checks on that description. If corners are reversed or a size is invalid, stop the result from being used and show why. When a box is allowed to extend beyond the photograph, distinguish the raw result from the part actually visible on screen. Clipping the drawn outline to the view should not silently replace data intended for a later step. The clipping rule is part of acceptance, not a cosmetic detail.
Before doing the arithmetic, separate the accuracy of the identification from the conversion. A box may surround the right object in the input image and shift in the preview. It may also be transferred perfectly from an input on which the model identified the wrong object. The first fault concerns the transfer of location, the second recognition. Correcting both at once makes it harder to establish what actually worked.
Follow one rectangle through three images
Take a photograph 2400 pixels wide and 1600 pixels high. The application crops a section starting 600 pixels from the left and 200 from the top. The crop is 1200 by 800 pixels, then it is reduced to 600 by 400. Only this image is sent to the model.
Suppose the returned box is, in the stated order ymin, xmin, ymax, xmax: 250, 200, 750, 800. These values are invented for the calculation, not a measurement of model quality. The point pairs below are already in x, y order: distance from the left first, then distance from the top. The conversion is as follows:
- On the 600 by 400 pixel input, the left edge is at 120, the right at 480, the top at 100 and the bottom at 300 pixels. Divide by 1000, then multiply horizontal values by width and vertical values by height.
- Returning to the 1200 by 800 crop means doubling the distances in this example. The box extends from 240, 200 to 960, 600, measured from the crop's origin.
- Returning to the full photograph requires adding the crop offset: 600 horizontally and 200 vertically. The corners are 840, 400 and 1560, 800 relative to the original.
The arithmetic can be checked independently of AI. I checked these artificial values in a short script, including the subsequent preview and rotation. No image was created and no model was called. This kind of test isolates the geometry from recognition accuracy.
Simply multiplying the result by the original dimensions would omit the crop. The box would be converted as if the model had seen the entire photograph. This is the kind of error to expose before assessing another version of the prompt. More detail in the input cannot restore an offset that has been lost.
The canvas drawImage documentation separates the source rectangle cropped from the image from the destination rectangle in which it is drawn. This is a useful example of why the dimensions and position in a preview need not match the source coordinates. The parameters of the two stages have distinct meanings.

Continue the calculation to the preview. When the entire original is reduced by a factor of four to 600 by 400 pixels, the box runs from 210, 100 to 390, 200. If the image is placed on a larger canvas with a margin of 100 pixels on the left and 50 at the top, the outline's corners on that canvas are 310, 150 and 490, 250. I also checked this case arithmetically. Omitting the margin shifts a correctly scaled box.
At a different window width, the preview may have a different size and margins. The conversion must then reflect how it is currently displayed. In the proposed acceptance test, resize the view after the response has arrived. Showing the right rectangle once in the initial layout is not enough.
Rotation also changes the reference system. In our calculation, rotating the whole original 90 degrees clockwise produces a 1600 by 2400 pixel image. After converting the corners, the same box extends from 800, 840 to 1200, 1560. Swapping the image width and height while leaving the old position unchanged is not enough.
Here we calculate continuous edge positions, not individual pixel indices. Convert all the corners, then choose the extremes that form the new rectangle. The implementer should document the rounding rule for cropping separately. Rounding too early, before further changes of scale, can affect the final edge. Check the file actually saved, not only values from before rounding.
The Rekognition orientation documentation, for the face-analysis operations it describes, also identifies a case where boxes are already corrected for Exif orientation. Do not apply the same correction again in that case. An integration must state which image its actual result refers to.
Recorded orientation and physically rotated pixels must be distinguished. Do not assume every stage of the image workflow performed the same operation. Acceptance needs images from each stage and their dimensions. A discussion over a screenshot, without identifying which file it shows, can easily end with agreement on two different states.
The box must work where someone uses it
In the workshop, a preview may be used to select a box, while a later step crops its photograph. Examine both results. The outline on screen can look right even when the cropping function received numbers for an image of a different size. Accepting the outline alone does not confirm the resulting file is correct.
When saving a crop, select the original photograph again and show where the content was taken from. If an employee corrected the box, keep the approved version separate from the raw model response. A later analysis will then not overwrite the manual correction silently. The report should still distinguish a correct AI identification from a result made correct by a person.
If the selection defines the scope of AI editing of a product photograph (in Polish), the right location is only the start of acceptance. Separately define what may change inside the area and what must remain. A box does not grant permission to redesign the product.
If the marking becomes a clickable area, test the click itself too. In an interactive venue plan with a list and zones (in Polish), selecting an area should lead to the right information. The same responsibility arises in a photograph: the visible box and active area must refer to the same item, including after the view is resized.
When preparing an image before a model (in Polish), preserve the data needed to get back to the original. Keeping only the final numbers and the name of the box is not enough. After a crop changes, old coordinates disconnected from the file do not become current simply because they still concern the blue object.
Allow for a delayed response. An employee may already have opened the next photograph when analysis of the previous one finishes. Tie the response to the specific input and its version instead of overlaying it on whatever image is currently visible. In an acceptance test, reverse the arrival order of two results. Each box should remain with its own photograph. A faster animation is no substitute for that association.
In an Aeneia Audit review of AI use, this process can be broken down into images, results and acceptance decisions. Bring the original, the material actually sent for analysis, the raw response and the final preview or crop. Together they help establish where the meaning of the location changed.
Visual product search (in Polish) answers a different question: whether the right model or variant was found. A correct box does not prove the box's identity in a catalogue. If the marked object should lead to a product page, that transition needs checking too.
Set the acceptable position difference according to how the result will be used. A preview may allow a small margin around the box; a crop should not lose its lid. In both cases, enclosing a neighbouring object is a different error from a slight shift of an edge. Compare the final result with the agreed annotation on the same image. Do not calculate a tolerance in pixels without stating the size it refers to.
Finally, ask someone to identify one object and follow the whole path to the result that will be used. The label, rectangle and final file must describe the same object on the correct image version. If the box still surrounds its neighbour, do not change the neighbour's label. Go back to the first point where the coordinate systems diverged.






