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
529 views
in Technique[技术] by (71.8m points)

how to find missing component in pcb using feature matching in opencv python

I am working on project where i have to find missing component in PCB, i have try it with image subtraction but as my lighting conditions are not good also images are of not same orientation so i am trying it with feature matching. I am not able to detect each an every component also not able to locate the position of missing component properly. please tell me how should i proceed further.Here is my code

import cv2

img1 = cv2.imread('./pcb_images/frame_51.png')
img1 = cv2.resize(img1, (640, 480))

img2 = cv2.imread('./pcb_images/frame_56.png')
img2 = cv2.resize(img2, (640, 480))

orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)
#print(kp1)
#print(kp2)
img_kp = cv2.drawKeypoints(img2, kp2, 0, color=(0,255,0), flags=0)
cv2.imshow("img_kp",img_kp)
# matcher takes normType, which is set to cv2.NORM_L2 for SIFT        and SURF, cv2.NORM_HAMMING for ORB, FAST and BRIEF
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
#print(bf)
matches = bf.match(des1, des2)
matches = sorted(matches, key=lambda x: x.distance)# draw first 50 matches
#print(matches)


 match_img = cv2.drawMatches(img1, kp1, img2, kp2, matches[:20], None)
 cv2.imshow('Matches', match_img)
 cv2.waitKey()
 cv2.destroyAllWindows()

[![original image]2]2 [defected image3

question from:https://stackoverflow.com/questions/65951198/how-to-find-missing-component-in-pcb-using-feature-matching-in-opencv-python

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

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

...