0% found this document useful (0 votes)
15 views1 page

Facedetetion

Uploaded by

AEC OFFICIAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Facedetetion

Uploaded by

AEC OFFICIAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import face_recognition

import cv2.cv2

img=cv2.cv2.imread('img/elon musk.jpg')
rgb_img=cv2.cv2.cvtColor(img,cv2.cv2.COLOR_BGR2RGB)
img_encoding=face_recognition.face_encodings(rgb_img)[0]

img2 = cv2.imread("img/0x0.jpg")
rgb_img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
img_encoding2 = face_recognition.face_encodings(rgb_img2)[0]

result = face_recognition.compare_faces([img_encoding], img_encoding2)


print("Result: ", result)

cv2.cv2.imshow('result',img)
cv2.cv2.imshow('resulta',img2)
cv2.cv2.waitKey(0)
cv2.cv2.destroyAllWindows()

import cv2.cv2
from simple_facerec import SimpleFacerec
sfr=SimpleFacerec()
sfr.load_encoding_images("img/")
cap=cv2.cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
face_locations,face_names=sfr.detect_known_faces(frame)
for face_loc,name in zip(face_locations,face_names):
y1, x2, y2, x1 = face_loc[0], face_loc[1], face_loc[2], face_loc[3]
cv2.putText(frame, name, (x1, y1 - 10), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0,
200), 2)
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 200), 4)

frame=cv2.cv2.resize(frame,(800,600))
cv2.cv2.imshow('frame',frame)
key=cv2.cv2.waitKey(1)
if key==27:
break
cap.release()
cv2.cv2.destroyAllWindows()

You might also like