示例#1
0
 def run(self):
     try:
         matcher = DescriptorMatcher(self.__descriptor_set1, self.__descriptor_set2)
         matcher.match()
         self.__feature_matches = matcher.get_feature_matches()
     except Exception as error:
         logger.exception(error)
示例#2
0
def align_images(img1, img2, threshold):
    descriptors1 = SURFDetector.extract_features(img1, threshold)
    descriptors2 = SURFDetector.extract_features(img2, threshold)
    matcher = DescriptorMatcher(descriptors1, descriptors2)
    matcher.match()
    estimator = RansacHomographyEstimator.create_for_matches(matcher.get_feature_matches())
    estimator.estimate()
    homography = estimator.homography
    print homography
    np.save('D:\\test\\test2\\ololo.txt', homography)
示例#3
0
 def run(self):
     try:
         matcher = DescriptorMatcher(self.__descriptor_set1, self.__descriptor_set2)
         matcher.match()
         estimator = RansacHomographyEstimator.create_for_matcher(matcher)
         estimator.estimate()
         self.__homography = estimator.homography
         self.__inliers = estimator.inliers
     except Exception as error:
         logger.exception(error)
示例#4
0
 def stitch(img1, img2):
     descriptors1 = SURFDetector.extract_features(img1)
     descriptors2 = SURFDetector.extract_features(img2)
     matcher = DescriptorMatcher(descriptors1, descriptors2)
     matcher.match()
     
     estimator = RansacHomographyEstimator.create_for_matches(matcher.get_feature_matches())
     estimator.estimate()
     homography = estimator.homography
     
     h1, w1 = img1.shape[0], img1.shape[1]
     w2 = img2.shape[1]
     dsize = (w1 + w2, h1)
     inv_homography = np.linalg.inv(homography)
     warped_img2 = cv2.warpPerspective(img2, inv_homography, dsize)
     
     panorama = blending.pyramid_blending(img1, warped_img2, 5)
     
     return imgtools.crop_panorama(panorama)