SIFT struggles
This commit is contained in:
parent
e5029e6929
commit
8d52b96268
BIN
src/helpers/algorithms/__pycache__/pysift.cpython-311.pyc
Normal file
BIN
src/helpers/algorithms/__pycache__/pysift.cpython-311.pyc
Normal file
Binary file not shown.
BIN
src/helpers/algorithms/image/test.jpg
Normal file
BIN
src/helpers/algorithms/image/test.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
@ -2,23 +2,30 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import cv2
|
||||
import os
|
||||
import math
|
||||
|
||||
# references:
|
||||
# https://docs.opencv.org/4.x/da/df5/tutorial_py_sift_intro.html
|
||||
|
||||
def magnitude(vector):
|
||||
return math.sqrt(sum(pow(element, 2) for element in vector))
|
||||
|
||||
|
||||
path = os.path.join(os.getcwd(), './res/trees/accasia_sq1_original.png')
|
||||
|
||||
sift = cv2.SIFT.create(enable_precise_upscale=True)
|
||||
|
||||
results = np.zeros(0)
|
||||
mag = np.zeros(0)
|
||||
labels = []
|
||||
for filename in os.listdir(os.path.join(os.getcwd(), "./res/trees/")):
|
||||
directory = os.path.join(os.getcwd(), "./res/trees/")
|
||||
path = os.path.join(directory, filename)
|
||||
img = cv2.imread(path ,1)
|
||||
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
|
||||
kp = sift.detect(gray, None)
|
||||
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
|
||||
kp = sift.detect(gray, None) # deze bad
|
||||
(kp, des)= sift.compute(gray, kp)
|
||||
|
||||
img = cv2.drawKeypoints(
|
||||
gray,
|
||||
kp,
|
||||
@ -26,10 +33,10 @@ for filename in os.listdir(os.path.join(os.getcwd(), "./res/trees/")):
|
||||
flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
|
||||
results = np.append(results, len(kp))
|
||||
labels.append(filename.split('_', 1)[0])
|
||||
cv2.imshow(filename,img)
|
||||
break
|
||||
# cv2.imshow(filename,img)
|
||||
|
||||
plt.bar(labels, results)
|
||||
plt.show()
|
||||
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
|
Loading…
Reference in New Issue
Block a user