I am working on project where I have to measure size of gear. I have already find contour of the gear and teeth of the gear. Now I want to measure its real world size with 100 percent accuracy real world dimension of gear is 53mm in outer diameter and 43mm in inner diameter and teeth size is 5mm, and also if I remove this gear and place large gear it also measure its correct diameter
# count outer teeth
c = max(max_c, key=cv2.contourArea)
hull = cv2.convexHull(c, clockwise=True, returnPoints=False)
hull1 = []
for i in hull:
if len(hull1) == 0:
hull1.append(i)
else:
last = hull1[-1]
diff = c[i] - c[last]
if cv2.norm(diff) > 10:
hull1.append(i)
hull1 = np.asarray(hull1)
hull2 = hull1[:-1].copy()
# count inner teeth
defects = cv2.convexityDefects(c, hull2)
#print(defects)
inner_points = []
for i in range(defects.shape[0]):
s, e, f, d = defects[i, 0]
far = tuple(c[f][0])
#print(far)
inner_points.append(f)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…