def main(argv):
if len(argv) == 2:
detector = detectors.get_detector(argv[0], params[argv[0]])
image = cv2.cvtColor(cv2.imread(argv[1]), cv2.COLOR_BGR2GRAY)
keypoints = detector.detect(image)
visualize_keypoints(image, keypoints)
elif len(argv) == 5:
detector = detectors.get_detector(argv[1], params[argv[1]])
descriptor = descriptors.get_descriptor(argv[2])
matcher = cv2.BFMatcher()
image1 = cv2.cvtColor(cv2.imread(argv[3]), cv2.COLOR_BGR2GRAY)
image2 = cv2.cvtColor(cv2.imread(argv[4]), cv2.COLOR_BGR2GRAY)
keypoints1 = detector.detect(image1)
keypoints2 = detector.detect(image2)
keypoints1, descriptors1 = descriptor.compute(image1, keypoints1)
keypoints2, descriptors2 = descriptor.compute(image2, keypoints2)
print type(descriptors1), type(descriptors2)
matches = matcher.knnMatch(descriptors1, descriptors2, k=2)
matches = sorted(matches, key=lambda x: x[0].distance)
visualize_matches(image1, keypoints1, image2, keypoints2, matches[:100])
评论列表
文章目录