Spaces:
Runtime error
Runtime error
fix: fundamental
Browse files- common/utils.py +11 -11
common/utils.py
CHANGED
|
@@ -374,7 +374,7 @@ def wrap_images(
|
|
| 374 |
rectified_image0 = img0
|
| 375 |
rectified_image1 = None
|
| 376 |
H = np.array(geo_info["Homography"])
|
| 377 |
-
|
| 378 |
title: List[str] = []
|
| 379 |
if geom_type == "Homography":
|
| 380 |
rectified_image1 = cv2.warpPerspective(
|
|
@@ -383,11 +383,15 @@ def wrap_images(
|
|
| 383 |
result_matrix = H
|
| 384 |
title = ["Image 0", "Image 1 - warped"]
|
| 385 |
elif geom_type == "Fundamental":
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
else:
|
| 392 |
print("Error: Unknown geometry type")
|
| 393 |
fig = plot_images(
|
|
@@ -395,11 +399,7 @@ def wrap_images(
|
|
| 395 |
title,
|
| 396 |
dpi=300,
|
| 397 |
)
|
| 398 |
-
dictionary = {
|
| 399 |
-
"row1": result_matrix[0].tolist(),
|
| 400 |
-
"row2": result_matrix[1].tolist(),
|
| 401 |
-
"row3": result_matrix[2].tolist(),
|
| 402 |
-
}
|
| 403 |
return fig2im(fig), dictionary
|
| 404 |
else:
|
| 405 |
return None, None
|
|
|
|
| 374 |
rectified_image0 = img0
|
| 375 |
rectified_image1 = None
|
| 376 |
H = np.array(geo_info["Homography"])
|
| 377 |
+
|
| 378 |
title: List[str] = []
|
| 379 |
if geom_type == "Homography":
|
| 380 |
rectified_image1 = cv2.warpPerspective(
|
|
|
|
| 383 |
result_matrix = H
|
| 384 |
title = ["Image 0", "Image 1 - warped"]
|
| 385 |
elif geom_type == "Fundamental":
|
| 386 |
+
if geom_type not in geo_info:
|
| 387 |
+
logger.warning(f"{geom_type} not exist, maybe too less matches")
|
| 388 |
+
return None, None
|
| 389 |
+
else:
|
| 390 |
+
H1, H2 = np.array(geo_info["H1"]), np.array(geo_info["H2"])
|
| 391 |
+
rectified_image0 = cv2.warpPerspective(img0, H1, (w1, h1))
|
| 392 |
+
rectified_image1 = cv2.warpPerspective(img1, H2, (w2, h2))
|
| 393 |
+
result_matrix = np.array(geo_info["Fundamental"])
|
| 394 |
+
title = ["Image 0 - warped", "Image 1 - warped"]
|
| 395 |
else:
|
| 396 |
print("Error: Unknown geometry type")
|
| 397 |
fig = plot_images(
|
|
|
|
| 399 |
title,
|
| 400 |
dpi=300,
|
| 401 |
)
|
| 402 |
+
dictionary = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
return fig2im(fig), dictionary
|
| 404 |
else:
|
| 405 |
return None, None
|