Esempio n. 1
0
    def test_findDistanceToMask(self):
        image_1 = self.images[0]
        image_2 = self.images[1]
        num_matches = 10
        kp1, kp2, matches = pano.findMatchesBetweenImages(
            image_1, image_2, num_matches)
        homography = pano.findHomography(kp1, kp2, matches)
        corners_1 = pano.getImageCorners(image_1)
        corners_2 = pano.getImageCorners(image_2)
        min_xy, max_xy = pano.getBoundingCorners(corners_1, corners_2,
                                                 homography)
        left_image = pano.warpCanvas(image_1, homography, min_xy, max_xy)
        right_image = np.zeros_like(left_image)
        min_xy = min_xy.astype(np.int)
        right_image[-min_xy[1]:-min_xy[1] + image_2.shape[0],
                    -min_xy[0]:-min_xy[0] + image_2.shape[1]] = image_2

        left_mask = pano.createImageMask(left_image)
        right_mask = pano.createImageMask(right_image)
        left_only_mask, overlap_mask, right_only_mask = pano.createRegionMasks(
            left_mask, right_mask)

        left_distance_mask = pano.findDistanceToMask(left_mask)
        left_only_distance_mask = pano.findDistanceToMask(left_only_mask)
        write_mask_image(left_only_distance_mask,
                         "left_only_distance_mask.png")
        overlap_distance_mask = pano.findDistanceToMask(overlap_mask)
        right_distance_mask = pano.findDistanceToMask(right_mask)
        right_only_distance_mask = pano.findDistanceToMask(right_only_mask)
        write_mask_image(right_only_distance_mask,
                         "right_only_distance_mask.png")
Esempio n. 2
0
corner_1 = a8.getImageCorners(image1)
corner_2 = a8.getImageCorners(image2)
corner_3 = a8.getImageCorners(image3)

image_1_kp, image_2_kp, matches = a8.findMatchesBetweenImages(
    image1, image2, num_matches)
#print image_1_kp

homography = a8.findHomography(image_1_kp, image_2_kp, matches)
print homography

min_xy, max_xy = a8.getBoundingCorners(corner_1, corner_2, homography)
print min_xy, max_xy

warped_image = a8.warpCanvas(image1, homography, min_xy, max_xy)
print warped_image
plt.imshow(warped_image)

point = np.int64(-min_xy)
img2 = np.zeros(warped_image.shape)
#img2[:image2.shape[0],:image2.shape[1]] = image2

#img2 = np.zeros(image2.shape)
#img2[:image2.shape[0]][:image2.shape[1]] = image2

img2[point[1]:point[1] + image2.shape[0],
     point[0]:point[0] + image2.shape[1]] = image2

#img2[point[1]:point[1]+image_2.shape[0], point[0]:point[0]+image_2.shape[1]] = image_2