<jupyter_start><jupyter_text>Facedetection for Escape Game<jupyter_code>import cv2
from matplotlib import pyplot as plt
import numpy as np

image1='/Users/stijnvanhulle/GitHub/EscapePlan/python/test_data/schilderij_1.jpg'
image2='/Users/stijnvanhulle/GitHub/EscapePlan/python/test_data/schilderij_1_small.jpg'

sift= cv2.xfeatures2d.SIFT_create()
surf= cv2.xfeatures2d.SURF_create()
orb = cv2.ORB_create()
img1 = cv2.imread(image1,0)        # queryImage
img2 = cv2.imread(image2,0) 		# trainImage

def readPercent(matches):
    good = []
    for m,n in matches:
        if m.distance < 0.25*n.distance:
            good.append([m])

    amount=len(good)      
    percent=amount/len(matches)
    return percent *100

def getGood(matches):
    good = []
    for m,n in matches:
        if m.distance < 0.25*n.distance:
            good.append([m])
    return good<jupyter_output><empty_output><jupyter_text>Trainen aan de hand van orb<jupyter_code>kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)

bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)

good=getGood(matches)
print('ORB:', readPercent(matches))

img_plt = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,None,flags=2)
plt.imshow(img_plt)
plt.show()<jupyter_output><empty_output><jupyter_text>Trainen aan de hand van SIFT<jupyter_code>kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)

bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)


good=getGood(matches)
print('SIFT:', readPercent(matches))
img_plt = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,None,flags=2)
plt.imshow(img_plt)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13261648745519714, 'fraction_numerical': 0.03524492234169654, 'mean_word_length': 5.273408239700374, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '509548', 'license': 'MIT', 'n_tokens_mistral': 710, 'n_tokens_neox': 684, 'n_words': 102, 'path': 'python/faceDetection.ipynb', 'repo_name': 'stijnvanhulle/EscapeGame', 'size': '1674'}