Commit 070cfa3f by Mairo Leier

Add readme.md

parents
Showing with 0 additions and 0 deletions

  • Face recognition Based home alarm system


    The Face Recognition process in this tutorial is divided into three steps.

    #Prepare training data: In this step we will read training images for each person/subject along with their labels, detect faces from each image and assign each detected face an integer label of the person it belongs to.

    #Train Face Recognizer: In this step we will train OpenCV's LBPH face recognizer by feeding it the data we prepared in step 1.

    #Testing: In this step we will pass some test images to face recognizer and see if it predicts them correctly.

    Requirements

    You need Python 3.6 64bit to run facerecognition Dlib libraries as these are not available in version latest then 3.6.


    Installations Quick start

    Import Required Modules #import OpenCV module import cv2 #import os module for reading training data directories and paths import os #import numpy to convert python lists to numpy arrays as #it is needed by OpenCV face recognizers import numpy as np

    #matplotlib for display our images

    import matplotlib.pyplot as plt

    %matplotlib inline py -m pip install numpy py -m pip install opencv-python py -m pip install matplotib py -m pip install pytesseract

    For Alarm use

    pip install py-notifier

    For example

    from pynotifier import Notification

    Notification( title='Notification Title', description='Notification Description', icon_path='path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png duration=5, # Duration in seconds urgency=Notification.URGENCY_CRITICAL ).send()

    #Detector

    Loading Recognizer Lets start the main loop and do the following basic steps Starts capturing frames from the camera object Convert it to Gray Scale Detect and extract faces from the images Use the recognizer to recognize the Id of the user Put predicted Id/Name and Rectangle on detected face.

    #function to detect face using OpenCV

    def detect_face(img): #convert the test image to gray image as opencv face detector expects gray images gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    #return only the face part of the image
    return gray[y:y+w, x:x+h], faces[0]

    #Main Code for continuous face recognition

    face_rec.zip

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment