IbrahimHasani commited on
Commit
3f492a7
1 Parent(s): 1dc1aec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -60,6 +60,39 @@ def stitch_images(images):
60
 
61
  return composite
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # Main functions
64
  def detect_and_crop(target_image, query_image, threshold=0.5, nms_threshold=0.3):
65
  target_sizes = torch.Tensor([target_image.size[::-1]])
 
60
 
61
  return composite
62
 
63
+ def unified_matching_plot2(image0, image1, kpts0, kpts1, mkpts0, mkpts1, color, text, path=None, show_keypoints=False, fast_viz=False, opencv_display=False, opencv_title='matches', small_text=[]):
64
+ plt.figure(figsize=(15, 15))
65
+ plt.subplot(1, 2, 1)
66
+ plt.imshow(image0)
67
+ plt.scatter(kpts0[:, 0], kpts0[:, 1], color='r', s=1)
68
+ plt.axis('off')
69
+
70
+ plt.subplot(1, 2, 2)
71
+ plt.imshow(image1)
72
+ plt.scatter(kpts1[:, 0], kpts1[:, 1], color='r', s=1)
73
+ plt.axis('off')
74
+
75
+ fig, ax = plt.subplots(figsize=(20, 20))
76
+ plt.plot([mkpts0[:, 0], mkpts1[:, 0] + image0.shape[1]], [mkpts0[:, 1], mkpts1[:, 1]], 'r', lw=0.5)
77
+ plt.scatter(mkpts0[:, 0], mkpts0[:, 1], s=2, marker='o', color='b')
78
+ plt.scatter(mkpts1[:, 0] + image0.shape[1], mkpts1[:, 1], s=2, marker='o', color='g')
79
+ plt.imshow(np.hstack([image0, image1]), aspect='auto')
80
+
81
+ plt.suptitle('\n'.join(text), fontsize=20, fontweight='bold')
82
+ plt.tight_layout()
83
+ plt.show()
84
+
85
+ buf = BytesIO()
86
+ plt.savefig(buf, format='png')
87
+ buf.seek(0)
88
+ img_arr = np.frombuffer(buf.getvalue(), dtype=np.uint8)
89
+ buf.close()
90
+ img = cv2.imdecode(img_arr, 1)
91
+ img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
92
+ plt.close(fig)
93
+
94
+ return img
95
+
96
  # Main functions
97
  def detect_and_crop(target_image, query_image, threshold=0.5, nms_threshold=0.3):
98
  target_sizes = torch.Tensor([target_image.size[::-1]])