21 lines
966 B
Python
21 lines
966 B
Python
|
|
from vismatch import get_matcher
|
|
from vismatch.viz import plot_matches,plot_keypoints
|
|
|
|
# Choose any of the 50+ matchers listed below
|
|
matcher = get_matcher("matchanything-roma", device="cuda")
|
|
img_size = 512 # optional
|
|
|
|
img0 = matcher.load_image(r"D:\汇报\水库项目资料\gif\屏幕截图 2026-02-28 140816.png", resize=img_size)
|
|
img1 = matcher.load_image(r"D:\汇报\水库项目资料\gif\屏幕截图 2026-02-28 140525.png", resize=img_size)
|
|
|
|
result = matcher(img0, img1)
|
|
# result.keys() = ["num_inliers", "H", "all_kpts0", "all_kpts1", "all_desc0", "all_desc1", "matched_kpts0", "matched_kpts1", "inlier_kpts0", "inlier_kpts1"]
|
|
|
|
# This will plot visualizations for matches as shown in the figures above
|
|
plot_matches(img0, img1, result, save_path="plot_matches.png")
|
|
|
|
# Or you can extract and visualize keypoints as easily as
|
|
result = matcher.extract(img0)
|
|
# result.keys() = ["all_kpts0", "all_desc0"]
|
|
plot_keypoints(img0, result, save_path="plot_kpts.png") |