Vincentqyw commited on
Commit
733c569
1 Parent(s): 42dde81

update: inliers too less

Browse files
Files changed (1) hide show
  1. common/utils.py +16 -14
common/utils.py CHANGED
@@ -163,7 +163,8 @@ def compute_geom(
163
  confidence=ransac_confidence,
164
  maxIters=ransac_max_iter,
165
  )
166
- geo_info["Fundamental"] = F.tolist()
 
167
  H, _ = cv2.findHomography(
168
  mkpts1,
169
  mkpts0,
@@ -172,12 +173,13 @@ def compute_geom(
172
  confidence=ransac_confidence,
173
  maxIters=ransac_max_iter,
174
  )
175
- geo_info["Homography"] = H.tolist()
176
- _, H1, H2 = cv2.stereoRectifyUncalibrated(
177
- mkpts0.reshape(-1, 2), mkpts1.reshape(-1, 2), F, imgSize=(w1, h1)
178
- )
179
- geo_info["H1"] = H1.tolist()
180
- geo_info["H2"] = H2.tolist()
 
181
  return geo_info
182
  else:
183
  return {}
@@ -352,13 +354,13 @@ def run_matching(
352
  "Image 1 - Keypoints",
353
  ]
354
  output_keypoints = plot_images([image0, image1], titles=titles, dpi=300)
355
- plot_keypoints([pred["keypoints0"], pred["keypoints1"]])
356
- text = (
357
- f"# keypoints0: {len(pred['keypoints0'])} \n"
358
- + f"# keypoints1: {len(pred['keypoints1'])}"
359
- )
360
-
361
- add_text(0, text, fs=15)
362
  output_keypoints = fig2im(output_keypoints)
363
 
364
  # plot images with raw matches
 
163
  confidence=ransac_confidence,
164
  maxIters=ransac_max_iter,
165
  )
166
+ if F is not None:
167
+ geo_info["Fundamental"] = F.tolist()
168
  H, _ = cv2.findHomography(
169
  mkpts1,
170
  mkpts0,
 
173
  confidence=ransac_confidence,
174
  maxIters=ransac_max_iter,
175
  )
176
+ if H is not None:
177
+ geo_info["Homography"] = H.tolist()
178
+ _, H1, H2 = cv2.stereoRectifyUncalibrated(
179
+ mkpts0.reshape(-1, 2), mkpts1.reshape(-1, 2), F, imgSize=(w1, h1)
180
+ )
181
+ geo_info["H1"] = H1.tolist()
182
+ geo_info["H2"] = H2.tolist()
183
  return geo_info
184
  else:
185
  return {}
 
354
  "Image 1 - Keypoints",
355
  ]
356
  output_keypoints = plot_images([image0, image1], titles=titles, dpi=300)
357
+ if "keypoints0" in pred.keys() and "keypoints1" in pred.keys():
358
+ plot_keypoints([pred["keypoints0"], pred["keypoints1"]])
359
+ text = (
360
+ f"# keypoints0: {len(pred['keypoints0'])} \n"
361
+ + f"# keypoints1: {len(pred['keypoints1'])}"
362
+ )
363
+ add_text(0, text, fs=15)
364
  output_keypoints = fig2im(output_keypoints)
365
 
366
  # plot images with raw matches