def distance_from_center(img_height, img_width, center, draw_on):
imgCX = img_width / 2
imgCY = img_height / 2
boxCX = center[0][0]
boxCY = center[0][1]
catW = math.sqrt(((imgCX - boxCX) ** 2) + ((boxCY - boxCY) ** 2))
catH = math.sqrt(((imgCX - imgCX) ** 2) + ((imgCY - boxCY) ** 2))
distPX = math.sqrt(((boxCX - imgCX) ** 2) + ((boxCY - imgCY) ** 2))
distPercent = max(catH / imgCY, catW / imgCX)
return distPX, distPercent
def distance_from_center(img_height, img_width, center, draw_on):
imgCX = img_width / 2
imgCY = img_height / 2
boxCX = center[0][0]
boxCY = center[0][1]
maxDist = math.sqrt((img_width * (img_width / 4)) + (img_height * (img_height / 4)))
distPX = math.sqrt(((boxCX - imgCX) ** 2) + ((boxCY - imgCY) ** 2))
distPercent = 100 * distPX / maxDist
return distPX, distPercent