face recognition source code
face recognition source code
SOURCE CODE:
PROJECT STRUCTURE
face_voting_system
Requirements.txt
INSTALLING PACKAGES:
cap = cv2.VideoCapture(0)
count = 0
while True:
k = cv2.waitKey(1)
if k % 256 == ord('s'):
img_path = f"{folder}/{name}_{count}.jpg"
cv2.imwrite(img_path, frame)
break
cap.release()
cv2.destroyAllWindows()
import face_recognition
import os
import pickle
encodings = []
names = []
image = face_recognition.load_image_file(img_path)
face_locations = face_recognition.face_locations(image)
if face_locations:
encodings.append(face_encoding)
names.append(user_folder)
pickle.dump(data, f)
import cv2
import face_recognition
import pickle
import datetime
data = pickle.load(f)
conn = sqlite3.connect('db/votes.db')
cursor = conn.cursor()
cap = cv2.VideoCapture(0)
print("[INFO] Scanning face...")
while True:
boxes = face_recognition.face_locations(rgb)
cap.release()
cv2.destroyAllWindows()
conn.close()
VIEW RESULTS (RESULT.PY)
import sqlite3
conn = sqlite3.connect('db/votes.db')
cursor = conn.cursor()
results = cursor.fetchall()
SAMPLE OUTPUT:
1. During Registration
Output:
Console Output:
What Happens:
3. Voting (vote.py)
Output Behavior:
• Webcam starts.
• It scans your face live.
GUI Window:
OUTPUT:
Alice: 1 vote(s)
Bob: 1 vote(s)
This pulls data from votes.db and counts the votes per person.