This is my code for recognition of faces. I am getting the following error
Code:
align = openface.AlignDlib(dlibFacePredictor)
subject=input("Enter Subject:")
a=['BI','SIC','PGIS','SQA','ITSM']
path = 'C:/Users/ACER/Desktop/PROJECT ALL RESOURCE/Implementation/PYTHON FILES/images/'
if subject in a:
print("Success")
wbook = load_workbook(filename = "C:/Users/ACER/Desktop/PROJECT ALL RESOURCE/Implementation/PYTHON FILES/Attendance/"+subject+".xlsx")
sheet = wbook.get_sheet_by_name('TYBSCIT'+subject)
else:
print("Invalid")
def getDateColumns():
for i in range(1, len(sheet.rows[0]) + 1):
cols = get_column_letter(i)
if sheet.cell('%s%s'% (col,'1')).value == currentDate:
return cols
def getProfileId(Ids):
connect = sqlite3.connect("C:/Users/ACER/Desktop/PROJECT ALL RESOURCE/Implementation/PYTHON FILES/sqlite3/Studentdb.db")
cmd = "SELECT * FROM Students WHERE ID=" + str(Ids)
cursor = connect.execute(cmd)
profile = None
for row in cursor:
profile = row
connect.close()
return profile
attend = [0 for i in range(60)]
rec = cv2.face.LBPHFaceRecognizer_create() # Local Binary Patterns Histograms
rec.read('C:/Users/ACER/Desktop/PROJECT ALL RESOURCE/Implementation/PYTHON FILES/Training/trainingData.yml') # loading the trained data
picNumber = 2
image= cv2.imread('C:/Users/ACER/Desktop/PROJECT ALL RESOURCE/Implementation/PYTHON FILES/images/'+subject+currentDate+'.jpg')
font = cv2.FONT_HERSHEY_SIMPLEX # the font of text on face recognition
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # conveting the camera input into GrayScale
dets = detector(image, 1)
totalConf = 0.0
faceRec = 0
for i, d in enumerate(dets):
image2 = image[d.top():d.bottom(), d.left():d.right()]
rgbImg = cv2.cvtColor(image2, cv2.COLOR_BGR2RGB)
bb = align.getLargestFaceBoundingBox(rgbImg)
alignedFace = align.align(96, rgbImg, bb=None, landmarkIndices=openface.AlignDlib.OUTER_EYES_AND_NOSE)
alignedFace= cv2.cvtColor(alignedFace, cv2.COLOR_BGR2GRAY) # conveting the camera input into GrayScale
Ids, conf = rec.predict(alignFace) # Comparing from the trained data
Traceback (most recent call last): File "C:\Users\ACER\Desktop\PROJECT ALL RESOURCE\Implementation\PYTHON FILES\facerecognition.py", line 60, in <module> Ids, conf = rec.predict(alignFace) # Comparing from the trained data NameError: name 'alignFace' is not defined