Sunday, January 31, 2021

Face recognition using Histogram and Python

Hi, in this blog we are implementing face detection with face identification using histogram and python.


First is input images and second is our output image which is fetch our database and return the name of person in this images. for label i have used some split function.

You can check script.

Note :- You need to save our database images with name of labels. you can check our Database folder.

Histogram is most common use in machine learning projects. we cant use this implementation on actual face recognition projects. i have tried to using histogram. it provide sufficient accuracy. but not excellent.

You can use it for learning purpose and how to use histogram in python. how to use haar cascade model for face detection. harsecade is not provide good accuracy. you can use MTCNN, YOLO FACE.

Upcoming blog we will implement face recognition project with good accuracy.

Now you can try with this project. this project also provides good accuracy for beginner learning machine learning.

In this project we are not using any third party api for face identification. we are using histogram.  

Also we do not use any other python libraries. we are using opencv and some basic python libraries for implement this project.

I will providing codes and some testing images and harsecade model for face detection which is used to return cropped images from our input image and Database images

you need to clone this project and install some opencv-python 

cmd :- git clone https://github.com/Manishsinghrajput98/Face_recognition_histogram.git

after that

cmd :- cd Face_Histogram

after that

cmd :- python Face.py --input input.jpg 

where --input indicate the command line arguments for taking input images from user

We don't use any model training for this project

Dataset folder contain the images of person. i have used 5 person in this project you can use more i have already try with 1000 classes. it will provide 70 accuracy.

but for this blog i have used only 5 classes.

Don't worry if you see the structure of project. so you definitely understood what happened here 

After run Face.py script the you can see the output will display. 

You need to pass the input images. which is you want to detect which person in your input image also i have add print statement you can check label name in your terminal.

Input image pass our program first this images pass our face detect method. and after this method. this method return the face cropped images by using harsecade opencv model. this process pass our both like input images and our Database folder.

After this cropped input image and Database images cropped pass our histogram calculation. this method will return some values. for both condition like input image and our Database folder.

After this input image calculation and Database image value passed our histogram matching method, this method returns the match values.

After this match values check.

This process we follow input image match our Dataset images one by one using histogram and return the values.

If values greater then 75 so it will identify person. or values is less than 75 so it will not detect.

now end of this project. upcoming blog we will implement next project.

File structure and result 



If you have any doubt so please comment.

Thanks 







3 comments:

If you have any doubts. Please let me know