Was ich habe:

Was ich erhalten möchte

Da ist meine Funktion:
Code: Select all
def detect(self):
haystack = cv2.cvtColor(self.haystack, cv2.COLOR_BGR2GRAY)
template = cv2.cvtColor(self.template, cv2.COLOR_BGR2GRAY)
kp1, des1 = sift.detectAndCompute(haystack, None)
kp2, des2 = sift.detectAndCompute(template, None)
matches = flann.knnMatch(des1, des2, k=2)
good_matches = []
for m, n in matches:
if m.distance < self.threshold * n.distance:
good_matches.append(m)
# there's I need to calculate x and y relative to haystack image
# h, w = template.shape[:2]
# return (x, y, h, w)
Mobile version