Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

so, if you have the contour already, you can get the boundingbox:

(x,y,w,h) = cv2.boundingRect(contours[0]) # assuming, there is only one contour

from there, it's a straight L2 norm:

pt = (x, y+h) # bottom-left of the obj
orig = (img.shape[1], img.shape[0]); ## bottom-right of the img

dist = math.sqrt( (pt[0]-orig[0])**2 + (pt[1]-orig[1])**2 )