Wednesday, August 14, 2024

Face Recognition Project Using SQL Database and Python 2024

                


INTRODUCTION

Face recognition is a computer vision technology that focuses on identifying and verifying a person's face. It's utilized in various fields, including security systems, payments, and social media tagging. The process involves analyzing and comparing patterns based on facial features, such as the eyes, nose, and mouth.


DOWNLOAD LINK 


Watch on YOUTUBE 





DETECTOR.PY CODE 



import cv2
import numpy as np
import sqlite3

faceDetect=cv2.CascadeClassifier('haarcascade/haarcascade_frontalface_default.xml');
cam=cv2.VideoCapture(0);

def insertOrUpdate(Id,Name,Age,Gen):
    conn=sqlite3.connect("FaceBase.db")
    cmd="SELECT * FROM Peoples WHERE ID="+str(Id)
    cursor=conn.execute(cmd)
    isRecordExist=0
    for row in cursor:
        isRecordExist=1
    if(isRecordExist==1):
        # cmd="UPDATE Peoples SET Name="+str(Name)+"WHERE id="+str(Id)
        conn.execute("UPDATE Peoples SET Name=? WHERE id=?", (Name,Id,))
        conn.execute("UPDATE Peoples SET Age=? WHERE id=?",(Age, Id))
        conn.execute("UPDATE Peoples SET Gender=? WHERE id=?", (Gen,Id,))
    else:
        # cmd="INSERT INTO Peoples(id,Name,Age,Gender) Values("+str(Id)+","+str(Name)+","+str(Age)+","+str(Gen)+")"
        conn.execute("INSERT INTO Peoples(id,Name,Age,Gender) Values(?,?,?,?)", (Id, Name, Age, Gen))
        # cmd2=""
        # cmd3=""
    conn.commit()
    conn.close()

Id=input('Enter User Id:')
name=input('Enter User Name:')
age=input('Enter User Age:')
gen=input('Enter User Gender:')
insertOrUpdate(Id,name,age,gen)
sampleNum=0
while(True):
    ret,img=cam.read();
    gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    faces=faceDetect.detectMultiScale(gray,1.3,5);
    for(x,y,w,h) in faces:
        sampleNum=sampleNum+1;
        cv2.imwrite("dataSet/User."+str(Id)+"."+str(sampleNum)+".jpg",gray[y:y+h,x:x+w])
        cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)
        cv2.waitKey(400);
    cv2.imshow("Face",img);
    cv2.waitKey(1);
    if(sampleNum>20):
        break;
cam.release()
cv2.destroyAllWindows()


TRAINER.PY CODE

import os

import cv2

import numpy as np

from PIL import Image


recognizer = cv2.face.LBPHFaceRecognizer_create()

path = "dataset"


def get_images_with_ids(path):

    image_paths = [os.path.join(path,f) for f in os.listdir(path)]

    faces = []

    ids = []

    for single_image_path in image_paths:

        faceImg = Image.open(single_image_path).convert("L") #greyscale luminance

        faceNp = np.array(faceImg, np.uint8)

        id = int(os.path.split(single_image_path)[-1].split(".")[1])

        print(id)

        faces.append(faceNp)

        ids.append(id)

        cv2.imshow("training", faceNp)

        cv2.waitKey(10)


    return np.array(id


DETECTOR.PY CODE

import cv2

import numpy as np

import os

import sqlite3


facedetect = cv2.Cascade........

    


FULL CODE WITH SOURCES 😃👇

https://tvi.la/facesqliteesourcecode


FOLLOW US :

1.FREETECH YOUTUBE CHANNEL →

https://www.youtube.com/@FREETECH-xu1ob

SUPPORT ME 😟


FREE C++ SKILLSHARE COURSE

https://skl.sh/3AUpE4C

FREE C SKILLSHARE COURSE

https://skl.sh/3Ynolmw


All Courses 😃👇

https://linktr.ee/Freetech2024

All Products 😃👇

https://linktr.ee/rockstararun


HP Laptop 🤩👇

https://dir.indiamart.com/impcat/hp-laptop.html?utm_source=freetech-xu1ob&utm_medium=affiliate&utm_campaign=1024&utm_content=29&mTd=1

Asus Laptop 🤩👇

https://www.indiamart.com/proddetail/24957009948.html?utm_source=freetech-xu1ob&utm_medium=affiliate&utm_campaign=1024&utm_content=43&mTd=1



THANKS FOR READING 😁😁

No comments:

Post a Comment

SQL INJECTION DETECTION USING RANDOM FOREST CLASSIFIER

  SQL INJECTION DETECTION USING RANDOM FOREST CLASSIFIER