1024programmer Java Returns the coordinates of the bounding box Google’s ObjectDetectionAPI

Returns the coordinates of the bounding box Google’s ObjectDetectionAPI

How do I get the coordinates of a generated bounding box using an inference script from Google’s Object Detection API? I know that printbox[0][i] returns the prediction for the ith detection in the image but what exactly do these returned numbers mean? Is there a way to get xmin,ymin,xmax,ymax? Thanks in advance.

1> Gal_M..:


Google Object Detection API returns bounding boxes in [ymin,xmin,ymax,xmax] format , and returned in normalized form (full description here). To find the (x,y) pixel coordinates, we need to multiply the result by the width and height of the image. First get the width and height of the image:

width, height = image.size
 

Then, extract ymin, xmin, ymax, xmax from the boxes object and multiply to get the (x, y) coordinates:

ymin = boxes[0][i][0]*height
 xmin = boxes[0][i][1]*width
 ymax = boxes[0][i][2]*height
 xmax = boxes[0][i][3]*width
 

Finally print the coordinates of the corners of the box:

print 'Top left'
 print (xmin,ymin,)
 print 'Bottom right'
 print(xmax,ymax)
 

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/771089

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索