Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pygats/recog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import cv2 as cv
from Levenshtein import ratio
from PIL import Image
from pygats.pygats import step, passed, failed
from pygats import step, passed, failed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for myself

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later will remove it


@dataclass
Expand Down
46 changes: 46 additions & 0 deletions src/pygats/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from PIL import Image
import hdbscan
import numpy as np
import recog as rec
import cv2 as cv

query_image = Image.open("./tests/find/background/test-01.jpg")
train_image = Image.open("./tests/find/background/test-02.jpg")

keypoints_1, descriptors_1, coord_list_1 = rec.find_keypoints(query_image)
keypoints_2, descriptors_2, coord_list_2 = rec.find_keypoints(train_image)

unique_keypoints1 = []
unique_keypoints2 = []

for kp1 in keypoints_1:
x1, y1 = kp1.pt
uniq = True
for kp2 in keypoints_2:
x2, y2 = kp2.pt
if abs(x1-x2) < 1 and abs(y1-y2)<1:
uniq = False
break
if uniq:
unique_keypoints1.append(kp1)

for kp2 in keypoints_2:
x2, y2 = kp2.pt
uniq = True
for kp1 in keypoints_1:
x1, y1 = kp1.pt
if abs(x2-x1) < 1 and abs(y2-y1)<1:
uniq = False
break
if uniq:
unique_keypoints2.append(kp2)

query_image = np.array(query_image)
train_image = np.array(train_image)
query_image = cv.drawKeypoints(query_image, unique_keypoints1, query_image,(255, 0, 0) )
query_image = cv.drawKeypoints(query_image, unique_keypoints2, query_image,(0, 0, 255) )


result_h = cv.hconcat([query_image, train_image])
cv.imshow('Horizontal Concatenation', result_h)
cv.waitKey(0)
Loading