Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

python - How to measure size of gear using OpenCV

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

my image is here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...