Compare commits

...

2 Commits

Author SHA1 Message Date
louiscklaw
7f5473a2bc update, 2025-02-01 00:54:29 +08:00
louiscklaw
22675373c9 update, 2025-02-01 00:54:11 +08:00
2 changed files with 29 additions and 1 deletions

View File

@@ -2,7 +2,8 @@
set -ex
git config lfs.allowincompletepush true
git config --global lfs.allowincompletepush true
git config --global http.postBuffer 5368709120
git add .

View File

@@ -0,0 +1,27 @@
import cv2
import numpy as np
# Load the image
img = cv2.imread("beach.jpg")
# Convert the image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Detect corners using the Harris corner detector
corners = cv2.goodFeaturesToTrack(gray, 100, 0.3, 10)
# Calculate the feature vectors using the SIFT descriptor
sift = cv2.xfeatures2d.SIFT_create()
kp, des = sift.detectAndCompute(gray, None)
# Match the feature vectors using the FLANN matcher
matcher = cv2.DescriptorMatcher_create(cv2.DESCRIPTOR_MATCHER_FLANNBASED)
matches = matcher.knnMatch(des, des, k=2)
# Draw the matched keypoints
cv2.drawMatches(img, kp, img, kp, matches, None, flags=cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
# Display the image
cv2.imshow("Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()