I have a python server returning a list of bounding boxes after running OCR (like Tesseract or something)
"bbox": [{
"x1": 223,
"y1": 426,
"x2": 1550,
"y2": 1736
}..]
Now to draw this bounding box on the client, I'm using the Q-img tag and created a div tag within it like this
<q-img :src="imageData.src">
<div
style="
position: absolute;
background-color: rgba(0, 100, 0, 0.1);
left: 223px;
top: 426px;
height: 1310px;
width: 1327px;
border: 0.5px solid blue;
"
/>
</q-img>
The problem is that this bounding box drawn on the client is way off from the actual location of the object on the image which the server returned.
It sounds like there's a misalignment between the coordinate systems used by your Python server for the bounding boxes and the coordinate system used by the Q-img tag in your frontend.
Check image dimension to make sure that the image dimensions (
imageData.widthandimageData.height) provided by the server match the actual dimensions of the image displayed by the Q-img tag. Any resizing or scaling on the client-side could offset the coordinates.Also check if the server returns bounding box coordinates relative to the image dimensions (e.g., percentages) or in absolute pixels. Your CSS styles currently use absolute pixel values. If the server provides absolute pixel coordinates and your
divtag needs relative positioning, you'll need to calculate the percentages:Log the bounding box coordinates received from the server and the computed styles of the
divelement in your browser's console (usingconsole.log). Compare them to see if the mismatch becomes obvious. Use your browser's developer tools to inspect the image and the overlayingdiv. Check if thedivtag is rendered at the expected location and if it has the correct dimensions. You're gunna need to do some investigation here.Assuming your server returns coordinates as percentages (0.0 to 1.0), here's how you could modify the template: