Problems in aligning figures

Hi all,

I have tried to follow this tutorial for aligning two figures but I get a wrong result. In particular, independently of the images I use for feeding the code, I always get a picture like that reported in the figure on the right in the following image:

It seems that the feature matching is not right. Below, you will find the code that I have used. How can I solve this issue? Any suggestion is appreciated.
Thanks.

MAX_FEATURES = 5000
GOOD_MATCH_PERCENT = 0.15

im1=cv2.imread("xxx1.jpg")
im2=cv2.imread("xxx2.jpg")

# Convert images to grayscale
im1Gray = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY)
im2Gray = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY)               

orb = cv2.ORB_create(MAX_FEATURES)
keypoints1, descriptors1 = orb.detectAndCompute(im1Gray, None)
keypoints2, descriptors2 = orb.detectAndCompute(im2Gray, None)       

im1_diplay = cv2.drawKeypoints(im1Gray,keypoints1, outImage=np.array([]), color=(255,0,0), flags=None)
im2_diplay = cv2.drawKeypoints(im2Gray,keypoints2, outImage=np.array([]), color=(255,0,0), flags=None)

plt.figure(figsize=[20,10])
plt.subplot(121); plt.axis('off'); plt.imshow(im1_diplay); plt.title("original form")
plt.subplot(122); plt.axis('off'); plt.imshow(im2_diplay); plt.title("tilted form")
plt.show()

# Match features
matcher =cv2.DescriptorMatcher_create(cv2.DESCRIPTOR_MATCHER_BRUTEFORCE_HAMMING)
matches = matcher.match(descriptors1,descriptors2,None)
if matches is None:
    print("the matches is none")
    sys.exit()
# sort matches by score
matches=sorted(matches,key=lambda x: x.distance)
print(type(matches))

#Remove not so good matches
numGoodMatches = int(len(matches)*0.2)
matches = matches[:numGoodMatches]

im_matches = cv2.drawMatches(im1,keypoints1, im2, keypoints2, matches, None)

plt.figure(figsize=[40,10])
plt.imshow(im_matches); plt.axis("off"); plt.title("Original form")
plt.show()

points1= np.zeros((len(matches),2),dtype=np.float32)
points2= np.zeros((len(matches),2),dtype=np.float32)

for i, match in enumerate(matches):
    points1[i,:] = keypoints1[match.queryIdx].pt
    points2[i,:] = keypoints2[match.queryIdx].pt


h, mask = cv2.findHomography(points2,points1, cv2.RANSAC)

height, width, channels = im1.shape
im2_reg = cv2.warpPerspective(im2, h, (width, height))

# Display results
plt.figure(figsize=[20,10])
plt.subplot(121); plt.imshow(im1); plt.axis("off"); plt.title("original")
plt.subplot(122); plt.imshow(im2_reg); plt.axis("off"); plt.title("scanned")
plt.show()