Conversions between kornia and other computer vision libraries formats
Maintained. Last release 4 months ago, commits in 2 of the last 26 weeks. Weaker on commit activity and release cadence.
$
pip install kornia-moonskornia_moons
Conversions between kornia and other computer vision libraries formats, mainly OpenCV.
Documentation: https://ducha-aiki.github.io/kornia_moons/
What's inside
- Keypoint / LAF conversions — OpenCV
cv2.KeyPoint↔ kornia local affine frames (LAFs), handling the differing scale and orientation conventions (mrSize=6.0for SIFT,1.0for ORB):laf_from_opencv_SIFT_kpts,opencv_ORB_kpts_from_laf, … - Match conversions — kornia match tensors ↔
cv2.DMatchlists:cv2_matches_from_kornia,kornia_matches_from_cv2 - OpenCV detectors as kornia modules —
OpenCVDetectorKornia,OpenCVFeatureKornia,OpenCVDetectorWithAffNetKornia(with kornia AffNet shape refinement) - Visualization — LAFs (
visualize_LAF), matches with inliers/epipolar lines/reprojected corners (draw_LAF_matches), plain point matches from LoFTR-style matchers (draw_point_matches), epipolar errors, and SOLD2 line segments (plot_lines,plot_color_line_matches)
Install
pip install kornia_moons
Quick start: keypoint conversion
import matplotlib.pyplot as plt
import cv2
from kornia.image import image_to_tensor
from kornia_moons.feature import laf_from_opencv_ORB_kpts, opencv_ORB_kpts_from_laf
from kornia_moons.viz import visualize_LAF
img = cv2.cvtColor(cv2.imread('data/strahov.png'), cv2.COLOR_BGR2RGB)
det = cv2.ORB_create(500)
kps, descs = det.detectAndCompute(img, None)
out_img = cv2.drawKeypoints(img, kps, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
plt.imshow(out_img)
lafs = laf_from_opencv_ORB_kpts(kps)
visualize_LAF(image_to_tensor(img, False), lafs, 0)
kps_back = opencv_ORB_kpts_from_laf(lafs)
out_img2 = cv2.drawKeypoints(img, kps_back, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
plt.imshow(out_img2)



