This is the photo for the error when i am running the model
from php that running .py
i want open the camera and make face recogntion from website in laptop/pc and mobile devices
please help me
thanks
and this is the .py code:
import sys
import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime
import pandas as pd
classNames = ['094009', '072803', '089117']
content = np.loadtxt('/home/absenpmo.site/public_html/build/file1.txt')
encodeListKnown = content
faces_name = [ ]
capture = cv2.VideoCapture(0) # argument 0 means return video from the first webcam on your computer
while len(faces_name) != 10: #get 10 Frames from Camera
success, img = capture.read()
#imgS = cv2.resize(img,(0,0),None,0.25,0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
facesCurFrame = face_recognition.face_locations(imgS)
encodesCurFrame = face_recognition.face_encodings(imgS,facesCurFrame)
for encodeFace,faceLoc in zip(encodesCurFrame,facesCurFrame):
matches = face_recognition.compare_faces(encodeListKnown,encodeFace)
faceDis = face_recognition.face_distance(encodeListKnown,encodeFace)
matchIndex = np.argmin(faceDis)
if matches[matchIndex]:
name = classNames[matchIndex].upper()
y1,x2,y2,x1 = faceLoc
y1, x2, y2, x1 = y1*4,x2*4,y2*4,x1*4
cv2.rectangle(img,(x1,y1),(x2,y2),(255,127,0),3)
cv2.putText(img,name,(x1,y2+25),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,0),5)
cv2.putText(img,name,(x1,y2+25),cv2.FONT_HERSHEY_COMPLEX,1,(255,255,255),2)
#markAttendance(name)
faces_name.append(name)
cv2.imwrite('{}.jpg'.format(name), img)
capture.release()
faces_name =pd.DataFrame(faces_name)
faces_name['A'] = 1
faces_name = faces_name.groupby([0]).agg('sum').reset_index()
faces_name=faces_name.sort_values(by=['A'], ascending=False)
id = faces_name.iloc[0][0]
faces_name=[]
# return id
print(id)