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
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()