Skip to content

Commit

Permalink
intial
Browse files Browse the repository at this point in the history
  • Loading branch information
Maveric-k07 committed Dec 18, 2021
0 parents commit ec359cf
Show file tree
Hide file tree
Showing 59 changed files with 1,967 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/FaceRecognitionAttendance.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AI/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions AI/.idea/FaceRecognitionAttendance.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AI/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions AI/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions AI/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AI/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions AI/Attendance.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Name,Time
73 changes: 73 additions & 0 deletions AI/AttendanceProject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

import numpy as np
import face_recognition
import os
from datetime import datetime
import cv2

path = 'ImagesBasic'
images = []
personName = []
myList = os.listdir(path)

for curImg in myList:
currentImage = cv2.imread(f'{path}/{curImg}')
images.append(currentImage)
personName.append(os.path.splitext(curImg)[0])
print(personName)


def faceEncodings(images):
encodeList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
return encodeList


def markAttendance(name):
with open('Attendance.csv', 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
now = datetime.now()
dtString = now.strftime('%H:%M:%S')
f.writelines(f'\n{name}, {dtString}')


encodeListKnown = faceEncodings(images)
print("Encoding complete")

cap = cv2.VideoCapture(0)

while True:
success, img = cap.read()
imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)

facesCurrent = face_recognition.face_locations(imgS)
encodeCurrent = face_recognition.face_encodings(imgS, facesCurrent)

for encodeFace, faceLoc in zip(encodeCurrent, facesCurrent):
matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
faceDistance = face_recognition.face_distance(
encodeListKnown, encodeFace)
# print(faceDistance)
matchIndex = np.argmin(faceDistance)

if matches[matchIndex]:
name = personName[matchIndex].upper()
# print(name)
y1, x2, y2, x1 = faceLoc
y1, x2, y2, x1 = y1*4, x2*4, y2*4, x1*4
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(img, (x1, y2-35), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(img, name, (x1+6, y2-6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance(name)
cv2.imshow('Webcam', img)
cv2.waitKey(1)
Binary file added AI/ImagesBasic/Akhileshwar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/ImagesBasic/Elon Musk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/ImagesBasic/Elon Test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/ImagesBasic/Naveen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/ImagesBasic/Obama.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/ImagesBasic/samuel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Attendance links/2021-12-102021-12-30.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Unnamed: 0,Unnamed: 0.1,name,roll_number,2021-12-10(1),2021-12-10(2),2021-12-10(3),2021-12-10(4),2021-12-11(1),2021-12-11(2),2021-12-11(3),2021-12-11(4),2021-12-13(1),2021-12-13(2),2021-12-13(3),2021-12-13(4),2021-12-14(1),2021-12-14(2),2021-12-14(3),2021-12-14(4),2021-12-15(1),2021-12-15(2),2021-12-15(3),2021-12-15(4),2021-12-16(1),2021-12-16(2),2021-12-16(3),2021-12-16(4),2021-12-17(1),2021-12-17(2),2021-12-17(3),2021-12-17(4),2021-12-18(1),2021-12-18(2),2021-12-18(3),2021-12-18(4),2021-12-20(1),2021-12-20(2),2021-12-20(3),2021-12-20(4),2021-12-21(1),2021-12-21(2),2021-12-21(3),2021-12-21(4),2021-12-22(1),2021-12-22(2),2021-12-22(3),2021-12-22(4),2021-12-23(1),2021-12-23(2),2021-12-23(3),2021-12-23(4),2021-12-24(1),2021-12-24(2),2021-12-24(3),2021-12-24(4),2021-12-25(1),2021-12-25(2),2021-12-25(3),2021-12-25(4),2021-12-27(1),2021-12-27(2),2021-12-27(3),2021-12-27(4),2021-12-28(1),2021-12-28(2),2021-12-28(3),2021-12-28(4),2021-12-29(1),2021-12-29(2),2021-12-29(3),2021-12-29(4),2021-12-30(1),2021-12-30(2),2021-12-30(3),2021-12-30(4),total_days
0,0,Vincent Samuel,121, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
1,1,Matrix,1285285, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
2,2,fafafafa,fafafafefew, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
3,3,fafafaf232, db27676, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
4,4,faf2d1,31rf31ff, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
5,5,badrinath,fafafafefewaa, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
6,6,gfuafvgjahgfb auhjf,fnjafn aikjfjnakf, , , , , , , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
7,7,NAVEEN LINGALA,19dadadada, , , , ,p, , , , , , , , , , , ,H,H,H,H,H,H,H,H, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,71
10 changes: 10 additions & 0 deletions Attendance links/2021-12-142022-01-01.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
,name,roll_number,2021-12-14(1),2021-12-14(2),2021-12-14(3),2021-12-15(1),2021-12-15(2),2021-12-15(3),2021-12-16(1),2021-12-16(2),2021-12-16(3),2021-12-17(1),2021-12-17(2),2021-12-17(3),2021-12-18(1),2021-12-18(2),2021-12-18(3),2021-12-20(1),2021-12-20(2),2021-12-20(3),2021-12-21(1),2021-12-21(2),2021-12-21(3),2021-12-22(1),2021-12-22(2),2021-12-22(3),2021-12-23(1),2021-12-23(2),2021-12-23(3),2021-12-24(1),2021-12-24(2),2021-12-24(3),2021-12-25(1),2021-12-25(2),2021-12-25(3),2021-12-27(1),2021-12-27(2),2021-12-27(3),2021-12-28(1),2021-12-28(2),2021-12-28(3),2021-12-29(1),2021-12-29(2),2021-12-29(3),2021-12-30(1),2021-12-30(2),2021-12-30(3),2021-12-31(1),2021-12-31(2),2021-12-31(3),2022-01-01(1),2022-01-01(2),2022-01-01(3),total_days
0,Vincent Samuel,121, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
1,Matrix,1285285, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
2,fafafafa,fafafafefew, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
3,fafafaf232, db27676, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
4,faf2d1,31rf31ff, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
5,badrinath,fafafafefewaa, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
6,gfuafvgjahgfb auhjf,fnjafn aikjfjnakf, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
7,NAVEEN LINGALA,19dadadada, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
8,AKHIL,19D01A0540, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,51
Binary file added DataBase.db
Binary file not shown.
Binary file added ImagesBasic/AKHIL.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImagesBasic/NAVEEN LINGALA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImagesBasic/dkb.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added THE Mavericks.pdf
Binary file not shown.
Binary file added __pycache__/ai.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/ai.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/ai_img.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/ai_liv.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/ai_liv.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/ai_vid.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/ai_vid.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/ai_web_cam.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/ai_web_cam.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/forms.cpython-310.pyc
Binary file not shown.
78 changes: 78 additions & 0 deletions ai_img.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import numpy as np
import face_recognition
import os
from datetime import datetime
import cv2
import pandas as pd
pd.options.mode.chained_assignment = None


def gen_frames_photo(file_name, csv_path, class_no):
####
path = 'ImagesBasic'
###
images = []
personName = []
myList = os.listdir(path)

for curImg in myList:
currentImage = cv2.imread(f'{path}/{curImg}')
images.append(currentImage)
personName.append(os.path.splitext(curImg)[0])
print(personName)

def faceEncodings(images):
encodeList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
return encodeList

def markAttendance(name, csv_path):
#####
with open(csv_path, 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
now = datetime.now()
dtString = now.strftime('%H:%M:%S')
print(f'\n{name}, {dtString}')
attendance = pd.read_csv(csv_path)
idx = attendance["name"].tolist().index(name)
attendance[f'{datetime.now().date()}({class_no})'][idx] = 'p'
attendance.to_csv(path_or_buf=csv_path, index=False)

encodeListKnown = faceEncodings(images)
print("Encoding complete")

img = cv2.imread(file_name)
print(img)
imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)

facesCurrent = face_recognition.face_locations(imgS)
encodeCurrent = face_recognition.face_encodings(imgS, facesCurrent)

for encodeFace, faceLoc in zip(encodeCurrent, facesCurrent):
matches = face_recognition.compare_faces(
encodeListKnown, encodeFace)
faceDistance = face_recognition.face_distance(
encodeListKnown, encodeFace)
# print(faceDistance)
matchIndex = np.argmin(faceDistance)

if matches[matchIndex]:
name = personName[matchIndex].upper()
# print(name)
y1, x2, y2, x1 = faceLoc
y1, x2, y2, x1 = y1*4, x2*4, y2*4, x1*4
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(img, (x1, y2-35), (x2, y2),
(0, 255, 0), cv2.FILLED)
cv2.putText(img, name, (x1+6, y2-6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance(name, csv_path)
87 changes: 87 additions & 0 deletions ai_vid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import numpy as np
import face_recognition
import os
from datetime import datetime
import cv2
import pandas as pd
pd.options.mode.chained_assignment = None


def gen_frames_video(vid_name, csv_path, class_no):
####
path = 'ImagesBasic'
###
images = []
personName = []
myList = os.listdir(path)

for curImg in myList:
currentImage = cv2.imread(f'{path}/{curImg}')
images.append(currentImage)
personName.append(os.path.splitext(curImg)[0])
print(personName)

def faceEncodings(images):
encodeList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
return encodeList

def markAttendance(name, csv_path):
#####
with open(csv_path, 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
now = datetime.now()
dtString = now.strftime('%H:%M:%S')
print(f'\n{name}, {dtString}')
attendance = pd.read_csv(csv_path)
idx = attendance["name"].tolist().index(name)
attendance[f'{datetime.now().date()}({class_no})'][idx] = 'p'
attendance.to_csv(path_or_buf=csv_path, index=False)

encodeListKnown = faceEncodings(images)
print("Encoding complete")

cap = cv2.VideoCapture(vid_name)

if (cap.isOpened() == False):
print("Error opening video stream or file")

while True:
try:
success, img = cap.read()
print(success)
imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)

facesCurrent = face_recognition.face_locations(imgS)
encodeCurrent = face_recognition.face_encodings(imgS, facesCurrent)

for encodeFace, faceLoc in zip(encodeCurrent, facesCurrent):
matches = face_recognition.compare_faces(
encodeListKnown, encodeFace)
faceDistance = face_recognition.face_distance(
encodeListKnown, encodeFace)
# print(faceDistance)
matchIndex = np.argmin(faceDistance)

if matches[matchIndex]:
name = personName[matchIndex].upper()
# print(name)
y1, x2, y2, x1 = faceLoc
y1, x2, y2, x1 = y1*4, x2*4, y2*4, x1*4
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(img, (x1, y2-35), (x2, y2),
(0, 255, 0), cv2.FILLED)
cv2.putText(img, name, (x1+6, y2-6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance(name, csv_path)
except:
break
Loading

0 comments on commit ec359cf

Please sign in to comment.