Nishu Project
Nishu Project
Nishu Project
FACE RECOGNITION:
FACE DETECTION:
1. Pre-Processing:
To reduce the variability in the faces, the images are
processed before they are fed into the network. All
positive examples that is the face images are obtained by
cropping the input images. All the cropped images are
then corrected for lighting through standard algorithms.
2. Classification:
Neural networks are implemented to classify the
images as faces or nonfaces by training on these
examples. We use both our implementation of the neural
network and the OpenCV for this task. Different network
configurations are experimented with to optimize the
results.
3. Localization:
The trained neural network is then used to search
for faces in an image and if present localize them in a
bounding box.
CHAPTER 2
(OpenCV)
# Store images in a numpy format and ids of the user on the same index in imageNp and id
lists
for image in path:
img = Image.open(image).convert('L')
imageNp = np.array(img, 'uint8')
id = int(os.path.split(image)[1].split(".")[1])
faces.append(imageNp)
ids.append(id)
ids = np.array(ids)
# Capturing real time video stream. 0 for built-in web-cams, 0 or -1 for external web-cams
video_capture = cv2.VideoCapture(-1)
while True:
if img_id % 50 == 0:
print("Collected ", img_id," images")
_, img = video_capture.read()
img = detect(img, faceCascade, img_id)
cv2.imshow("face detection", img)
img_id += 1
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
# Destroying output window
cv2.destroyAllWindows()
face_detection.py
import cv2
# Loading classifiers
faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eyesCascade = cv2.CascadeClassifier('haarcascade_eye.xml')
noseCascade = cv2.CascadeClassifier('Nariz.xml')
mouthCascade = cv2.CascadeClassifier('Mouth.xml')
# Capturing real time video stream. 0 for built-in web-cams, 0 or -1 for external web-cams
video_capture = cv2.VideoCapture(-1)
while True:
# Reading image from video stream
_, img = video_capture.read()
img = detect(img, faceCascade, eyesCascade, noseCascade, mouthCascade)
# Writing processed image in a new window
cv2.imshow("face detection", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
# Destroying output window
cv2.destroyAllWindows()
recognize.py
import cv2
# Loading classifier
faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Loading custom classifier to recognize
clf = cv2.face.LBPHFaceRecognizer_create()
clf.read("classifier.yml")
# Capturing real time video stream. 0 for built-in web-cams, 0 or -1 for external web-cams
video_capture = cv2.VideoCapture(-1)
while True:
_, img = video_capture.read()
# Call method we defined above
img = recognize(img, clf, faceCascade)
# Writing processed image in a new window
cv2.imshow("face detection", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
# Destroying output window
cv2.destroyAllWindows()
OUTPUT SCREENSHOTS
CONCLUSION
The implemented fully automated face detection and recognition system (with an
eye detection system) could be used for simple surveillance applications such as
ATM user security, while the implemented manual face detection and automated
recognition system is ideal of mugshot matching. Since controlled conditions are
present when mugshots are gathered, the frontal view face recognition scheme
should display a recognition accuracy far better than the results, which were
obtained in this study, which was conducted under adverse conditions.
The automated vision systems implemented in this thesis did not even approach
the performance, nor were they as robust as a human's innate face recognition
system. However, they give an insight into what the future may hold in computer
vision.
REFERENCES
Resources
1. Link to source code, pre-trained classifiers:
https://github.com/chethan1999/Face-Recognition-using-
ML.git
2. Online resource to understand OpenCV:
https://docs.opencv.org/2.4/doc/tutorials/tutorials.html
https://www.tutorialspoint.com/opencv/index.htm
https://www.youtube.com/watch?v=kdLM6AOd2vc