Skip to content

Added Necessary changes to TicTacToe game #302

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
46 changes: 25 additions & 21 deletions AI_Attendence_Program/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,35 @@ def attendance(name):

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
faces = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
faces = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
#check if Video camera is accessed or not
if not cap.isOpened():
print("Error: Could not access the webcam")
else:
while True:
ret, frame = cap.read()
faces = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
faces = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

faces_currentframe = face_recognition.face_locations(faces)
encode_currentframe = face_recognition.face_encodings(faces, faces_currentframe)
faces_currentframe = face_recognition.face_locations(faces)
encode_currentframe = face_recognition.face_encodings(faces, faces_currentframe)

for encodeFace, faceLoc in zip(encode_currentframe, faces_currentframe):
matches = face_recognition.compare_faces(encode_list_Known, encodeFace)
faceDistance = face_recognition.face_distance(encode_list_Known, encodeFace)
for encodeFace, faceLoc in zip(encode_currentframe, faces_currentframe):
matches = face_recognition.compare_faces(encode_list_Known, encodeFace)
faceDistance = face_recognition.face_distance(encode_list_Known, encodeFace)

matchIndex = np.argmin(faceDistance)
matchIndex = np.argmin(faceDistance)

if matches[matchIndex]:
name = PersonName[matchIndex].upper()
y1, x2, y2, x1 = faceLoc
#y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 2)
cv2.rectangle(frame, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(frame, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
attendance(name)
if matches[matchIndex]:
name = PersonName[matchIndex].upper()
y1, x2, y2, x1 = faceLoc
#y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 2)
cv2.rectangle(frame, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(frame, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
attendance(name)

cv2.imshow("camera", frame)
if cv2.waitKey(10) == 13:
break
cv2.imshow("camera", frame)
if cv2.waitKey(10) == 13:
break
cap.release()
cv2.destroyAllWindows()
9 changes: 6 additions & 3 deletions Tic-Tac-Toe/TicTacToe.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ def main():
print("Tie game")

else:
insertLetter("O", move)
print(f"Computer place O on position {move}")
printBoard(board)
if move == 0 or move is None:
print("Tie game")
else:
insertLetter("O", move)
print(f"Computer place O on position {move}")
printBoard(board)

else:
print("You win! ")
Expand Down