When I run the code it says this:
2024-03-06 10:34:40.990786: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable
TF_ENABLE_ONEDNN_OPTS=0. WARNING:tensorflow:From C:\Users\Basti\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
Well it opens the webcam but it's not taking up any matches, even though my face is on the camera.
This is the source code for the Face Attend program:
import threading
import cv2
from deepface import DeepFace
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
counter = 0
face_match = False
reference_img = cv2.imread("basti.jpg")
def check_face(frame):
global face_match
try:
if DeepFace.verify(frame, reference_img.copy())['verified']:
face_match = True
else:
face_match = False
except ValueError:
face_match = False
while True:
ret, frame = cap.read()
if ret:
if counter % 30 == 0:
try:
threading.Thread(target=check_face, args=(frame.copy()),).start()
except ValueError:
pass
counter += 1
if face_match:
cv2.putText(frame, "MATCH", (20, 450), cv2.FONT_HERSHEY_SIMPLEX, 2,(0,255, 0), 3)
else:
cv2.putText(frame, "NO MATCH", (20, 450), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 0, 255), 3)
cv2.imshow("video", frame)
key = cv2.waitKey(1)
if key == ord("q"):
break
cv2.destroyAllWindows()
This is the code I used, as the tutorial had shown. I'm a beginner when it comes to Python programming and stuff, but we need a face-recognition program as a project for school if you guys have better suggestion how to create one, I would also like to know how to do it.
For a face-recognition program to work, or to have a face-recognition program