linrl3 / Image-Stitching-OpenCV

Simple image stitching algorithm based on SIFT, homography, KNN and Ransac in Python and OpenCV
MIT License
198 stars 43 forks source link

Value error #1

Open ceylanbagci opened 5 years ago

ceylanbagci commented 5 years ago

Hi; My images can not make mask on this line can you help me please. `--------------------------------------------------------------------------- ValueError Traceback (most recent call last)

in 7 if __name__ == '__main__': 8 try: ----> 9 main() 10 except IndexError: 11 print ("Please input two source images: ") in main() 2 img1 = cv2.imread('data/Rainier1.png') 3 img2 = cv2.imread('data/Rainier2.png') ----> 4 final=Image_Stitching().blending(img1,img2) 5 cv2.imwrite('panorama.jpg', final) 6 in blending(self, img1, img2) 53 54 panorama1 = np.zeros((height_panorama, width_panorama, 3)) ---> 55 mask1 = self.create_mask(img1,img2,version='left_image') 56 panorama1[0:img1.shape[0], 0:img1.shape[1], :] = img1 57 panorama1 *= mask1 in create_mask(self, img1, img2, version) 37 mask = np.zeros((height_panorama, width_panorama)) 38 if version== 'left_image': ---> 39 mask[:, barrier - offset:barrier + offset ] = np.tile(np.linspace(1, 0, 2 * offset ).T, (height_panorama, 1)) 40 mask[:, :barrier - offset] = 1 41 else: ValueError: could not broadcast input array from shape (388,800) into shape (388,0)` Images link: [ https://drive.google.com/drive/folders/1nyWK45IjSofDFvkWRkJqtYx3Gn1n6QSp?usp=sharing ](url) Thank you then.
Pinnh commented 3 years ago

I find set smoothing_window_size=0 or less than 800 is OK, because barrier - offset is <0,the array slice can't get the correct array