Find the length of the dril bits in different size?

I want to find the length of the dril bit

I try some way that result not accurate value and if i change the dril bits image to another size that the time that program not work

condril

This dril bit size is 5mm is actual size are 3.4
My program

import cv2
import numpy as np
image=cv2.imread('dril1.png',0)
ret,thresh = cv2.threshold(image,127, 255,0)
contours,hierarchy=cv2.findContours(thresh,2,1)
cnt=contours[13]
x,y,w,h=cv2.boundingRect(cnt)
rect=cv2.minAreaRect(cnt)
cv2.rectangle(image,(x,y),(x+w,y+h),(0,0,127),2)
cv2.circle(image,(int(rect[0][0]),int(rect[0][1])), 5, (255,0,0), -1)
cv2.putText(image, f'Width : {int(rect[1][0])}',(int(rect[0][0]),int(rect[0][1])),cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,0,0),1, cv2.LINE_AA)
cv2.putText(image, f'Height : {int(rect[1][1])}',(int(rect[0][0]),int(rect[0][1])-20),cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,0,0),1, cv2.LINE_AA)
cv2.imshow('img',image)
cv2.imwrite('drill.png',image)
cv2.waitKey(0)
cv2.destroyAllWindows()

related:

I want to find the length of the dril bit

I try some way that result not accurate value and if i change the dril bits image to another size that the time that program not work

condril

This dril bit size is 5mm is actual size are 3.4225 inches.

i raised the same question into stack over flow but no one can reply this. so i ask in opencv community.

that’s because you keep ignoring what people tell you, and you appear to expend no mental effort at all on understanding the high school math behind the problem. there’s no way to be more diplomatic about that. this task might just be beyond your capabilities, and nobody has any reason to just hand you the solution. it’s clearly a commercial application that you try to earn your living with. time to reconsider.