diff --git a/backend/__pycache__/main.cpython-313.pyc b/backend/__pycache__/main.cpython-313.pyc new file mode 100644 index 0000000..351b466 Binary files /dev/null and b/backend/__pycache__/main.cpython-313.pyc differ diff --git a/backend/__pycache__/test.cpython-313.pyc b/backend/__pycache__/test.cpython-313.pyc new file mode 100644 index 0000000..9d9c8ed Binary files /dev/null and b/backend/__pycache__/test.cpython-313.pyc differ diff --git a/backend/__pycache__/train.cpython-313.pyc b/backend/__pycache__/train.cpython-313.pyc new file mode 100644 index 0000000..040d345 Binary files /dev/null and b/backend/__pycache__/train.cpython-313.pyc differ diff --git a/backend/main.py b/backend/main.py new file mode 100644 index 0000000..ab00ff2 --- /dev/null +++ b/backend/main.py @@ -0,0 +1,10 @@ +import test,train + +train_folder_dir="C:/Users/Sanjay/OneDrive/Documents/pixel-peep/test_cases/train_images" +test_folder_dir="C:/Users/Sanjay/OneDrive/Documents/pixel-peep/test_cases/test_images" + +des_list=train.train_images(folder_dir=train_folder_dir) +is_Match=test.test_images(folder_dir=test_folder_dir,des_from_train=des_list) + +for matches in is_Match: + print(matches,sep="\n") \ No newline at end of file diff --git a/backend/test.py b/backend/test.py new file mode 100644 index 0000000..4523064 --- /dev/null +++ b/backend/test.py @@ -0,0 +1,33 @@ +import train +import cv2 +import glob +import os + + + +def test_images(folder_dir,des_from_train): + match_list=[] + sift=cv2.SIFT_create() + bf=cv2.BFMatcher() + for test_img_path in glob.iglob(f"{folder_dir}/*"): + image=cv2.imread(test_img_path) + gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) + kp=sift.detect(gray,None) + kp,des_test=sift.compute(gray,kp) + + for train_img_path,des_train in des_from_train.items(): + matches=bf.knnMatch(des_train,des_test,k=2) + good=[] + for m,n in matches: + if m.distance<0.75*n.distance: + good.append(m) + + # print(good) + if(len(good)>=30): + match_list.append(f"{os.path.basename(train_img_path)} matches with {os.path.basename(test_img_path)}") + else: + match_list.append(f"{os.path.basename(train_img_path)} doesn't match with {os.path.basename(test_img_path)}") + + + + return match_list \ No newline at end of file diff --git a/backend/train.py b/backend/train.py new file mode 100644 index 0000000..fc64ad0 --- /dev/null +++ b/backend/train.py @@ -0,0 +1,44 @@ +import cv2 +import glob + + + +def train_images(folder_dir): + des_list={} + sift=cv2.SIFT_create() + for train_img_path in glob.iglob(f'{folder_dir}/*'): + image=cv2.imread(train_img_path) + gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) + + kp=sift.detect(gray,None) + kp,des_train=sift.compute(gray,kp) + des_list[train_img_path]=des_train + + return des_list + + + + + + + + + + + + + + + + + + + + + + + +#This is to show the image in a separate window. +# cv2.imshow("gray image",gray) +# cv2.waitKey(0) +# cv2.destroyAllWindows() \ No newline at end of file diff --git a/test_cases/test_images/CR7 b&w.jpg b/test_cases/test_images/CR7 b&w.jpg new file mode 100644 index 0000000..c0cb0f1 Binary files /dev/null and b/test_cases/test_images/CR7 b&w.jpg differ diff --git a/test_cases/test_images/CR7 cropped.webp b/test_cases/test_images/CR7 cropped.webp new file mode 100644 index 0000000..123f643 Binary files /dev/null and b/test_cases/test_images/CR7 cropped.webp differ diff --git a/test_cases/test_images/CR7 rotated.jpg b/test_cases/test_images/CR7 rotated.jpg new file mode 100644 index 0000000..7c256aa Binary files /dev/null and b/test_cases/test_images/CR7 rotated.jpg differ diff --git a/test_cases/test_images/cr7 2.webp b/test_cases/test_images/cr7 2.webp new file mode 100644 index 0000000..fbc2ed4 Binary files /dev/null and b/test_cases/test_images/cr7 2.webp differ diff --git a/test_cases/test_images/cr7 diff.webp b/test_cases/test_images/cr7 diff.webp new file mode 100644 index 0000000..511bffd Binary files /dev/null and b/test_cases/test_images/cr7 diff.webp differ diff --git a/test_cases/train_images/CR7.webp b/test_cases/train_images/CR7.webp new file mode 100644 index 0000000..e4edfea Binary files /dev/null and b/test_cases/train_images/CR7.webp differ diff --git a/test_cases/train_images/ML1.webp b/test_cases/train_images/ML1.webp new file mode 100644 index 0000000..478c0eb Binary files /dev/null and b/test_cases/train_images/ML1.webp differ diff --git a/test_cases/train_images/ML2.webp b/test_cases/train_images/ML2.webp new file mode 100644 index 0000000..468d0e9 Binary files /dev/null and b/test_cases/train_images/ML2.webp differ