Skip to content
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
86 changes: 86 additions & 0 deletions AI_Attendence_Program/Main (1).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime

path = 'Images'
Images = []
PersonName = []
mylist = os.listdir(path)
print(mylist)

# For separating the name from their extensions
for cu_img in mylist:
current_Img = cv2.imread(f'{path}/{cu_img}')
Images.append(current_Img)
PersonName.append(os.path.splitext(cu_img)[0])
print(PersonName)

def encodings(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

encode_list_Known = encodings(Images)
print("ALL ENCODING FOUND!!!")

def attendance(name):
with open('Attendence.csv', 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
time_now = datetime.now()
tStr = time_now.strftime('%H:%M:%S')
dStr = time_now.strftime('%d/%m/%Y')
f.writelines(f'\n{name},{tStr},{dStr}')

def check_camera_access(cap):
if not cap.isOpened():
print("Error: Unable to access the webcam.")
return False
return True

cap = cv2.VideoCapture(0)

if not check_camera_access(cap):
exit() # Exit if the camera is not accessible

while True:
ret, frame = cap.read()
if not ret:
print("Error: Unable to read from the webcam.")
break

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)

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)

if matches[matchIndex]:
name = PersonName[matchIndex].upper()
y1, x2, y2, x1 = faceLoc
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

cap.release()
cv2.destroyAllWindows()
5 changes: 5 additions & 0 deletions AI_Attendence_Program/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def attendance(name):

cap = cv2.VideoCapture(0)

# Check if the webcam is opened successfully
if not cap.isOpened():
print("Error: Could not access the camera.")
exit()

while True:
ret, frame = cap.read()
faces = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
Expand Down
81 changes: 81 additions & 0 deletions SNAKE/Main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime

path = 'Images'
Images = []
PersonName = []
mylist = os.listdir(path)
print(mylist)
# for separating the name from their extensions
for cu_img in mylist:
current_Img = cv2.imread(f'{path}/{cu_img}')
Images.append(current_Img)
PersonName.append(os.path.splitext(cu_img)[0])
print(PersonName)


def encodings(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


encode_list_Known = encodings(Images)
print("ALL ENCODING FOUND!!!")


def attendance(name):
with open('Attendence.csv', 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
time_now = datetime.now()
tStr = time_now.strftime('%H:%M:%S')
dStr = time_now.strftime('%d/%m/%Y')
f.writelines(f'\n{name},{tStr},{dStr}')


cap = cv2.VideoCapture(0)

# Check if the webcam is opened successfully
if not cap.isOpened():
print("Error: Could not access the camera.")
exit()

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)

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)

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
cap.release()
cv2.destroyAllWindows()
48 changes: 48 additions & 0 deletions Tic-Tac-Toe/ticreadme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Tic-Tac-Toe

This is a simple command-line Tic-Tac-Toe game built using Python. It allows two players to take turns and play the classic Tic-Tac-Toe game.

## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [How to Play](#how-to-play)
- [Game Rules](#game-rules)
- [Example](#example)
- [Contributing](#contributing)
- [License](#license)

## Features
- Command-line interface
- Supports two players (Player X and Player O)
- Simple and intuitive gameplay
- Detects win conditions and tie games
- Displays the game board after each move

## Installation

1. **Clone the repository**:
```bash
git clone https://github.com/your-username/tictactoe.git
cd tictactoe

nsure Python is installed: This game is written in Python, so you need to have Python installed. You can check by running:


python --version

Run the game: You can directly run the tictactoe.py file:

python tictactoe.py

How to Play
Player 1 (X) starts by choosing a position on the grid numbered 1 to 9.
Player 2 (O) takes the next turn by choosing an empty position.
The game continues until a player wins by placing three marks in a row (horizontal, vertical, or diagonal) or the game results in a tie.
Game Rules
The game is played on a 3x3 grid.
Players take turns choosing a spot (1-9) to place their mark (X or O).
The first player to get 3 of their marks in a row (either horizontally, vertically, or diagonally) wins.
If all 9 spaces are filled and no player has 3 marks in a row, the game ends in a draw.

License
This project is open-source and available under the MIT License.