snowzach / doods

DOODS - Dedicated Open Object Detection Service
MIT License
303 stars 31 forks source link

Question - What "ratio" is the detection result size? #47

Closed scottgrobinson closed 3 years ago

scottgrobinson commented 3 years ago

I'm trying to work this out from testing and the code but not getting too far...

            "top": 0,
            "left": 0.05,
            "bottom": .8552,
            "right": 0.9441,

What "ratio" is this in/how do these positions relate to the original image? Is it a "percentage"? I.E right is 0.94% from the left of the image?

I'm trying to use cv2.drawrectangle to draw a bounding box around the detected object. Boxes are getting drawn, just not in the right place! :)

1ubuntuuser commented 3 years ago

Yep that's right. admittedly it's pretty unreadable but here is my code in Xojo.

I'm multiplying the

...  
  for each detect as detection in detections
    underlay.Graphics.DrawRectangle(Underlay.width*detect.left, Underlay.Height*detect.top, Underlay.width*detect.right-Underlay.width*detect.left,Underlay.Height*detect.bottom-Underlay.Height*detect.top)
  next
...
1ubuntuuser commented 3 years ago

Basically...

picture.width*detect.left = LEFT
picture.Height*detect.top = TOP
picture.width*detect.right-picture.width*detect.left, = WIDTH
picture.Height*detect.bottom-picture.Height*detect.top = HEIGTH
scottgrobinson commented 3 years ago

Thanks @danielwilson654 - That did it 👍