This face counter using MATLAB program helps count the number of persons present in a meeting hall or classroom at a time. The program logic can also be used in other applications, such as automatic temperature control which depends on the number of persons in a room. Video camera plays a very important role in this project.
If you try to count a large number of people in a hall, you may take time to count them and probably also make a mistake. With the help of this program, you can get the number of people instantly and more accurately using a camera and image processing.


Software program

A graphic user interface (GUI) allows users to perform tasks interactively through such controls as switches and sliders. You can create GUI and run it in MAT LAB or as standalone application. The initial program output of this project is shown in Fig. 1 and its output after face detection is shown in Fig. 2.
Face detection algorithm
There are different types of algorithms used in face detection. Here, we used Viola-Jones algorithm for face detection with MATLAB program.
The algorithm actually works in following steps:
1. Creates a detector object using Viola-Jones algorithm
2. Takes the image from the video
3. Detects the features
4. Annotates the detected features
MATLAB functions
The program (testing.m) has many functions. Do not edit the functions as these are linkers and non-executable codes. First of all, you have to find the format supported by the camera and its device ID using the command given below (also shown in Fig. 3):
info = imaqhwinfo(‘winvideo’)
After knowing the device ID, you can change the device ID number in your source code.
We are having device ID as {1}, so have written ‘1’ in the code, as mentioned below:
vid = videoinput(‘winvideo’,1,’YUY2
_640x480’);
We also have other formats in MATLAB. You can check which format your camera supports by using commands below (also shown in Fig. 4):
info.DeviceInfo(1)
info.DeviceInfo.SupportedFormats
In Fig. 4, you can see that format ‘YUY2_160x120’ is the one which is supported by the camera by default. But there are also other formats (resolutions) which your camera can support, as shown in last line in this screenshot. If you select another format and device number, you should make changes in the source code accordingly.

To detect a face or a particular feature on the faces of people, following steps are used in MATLAB program (testing.m):
1. Define and set up your cascade object detector using the constructor.
detector=vision.CascadeObjectDetector
It creates a system object detector that detects objects using the Viola-Jones algorithm. Its Classification Model property controls the type of object to detect. By default, the detector is configured to detect faces.
2. Call the step method with the input image I, the cascade object detector object, detector, points PTS and any optional properties. See the syntax below for using the step method. Use the step syntax with input image I, the selected cascade object detector object, and any optional properties to perform detection.
BBOX = step (detector, I)
It returns BBOX, an M-by-4 matrix defining M bounding boxes containing the detected objects. This method performs multi-scale object detection on the input image I. Each row of the output matrix BBOX contains a four-element vector (x, y, width and height) that specifies in pixels, the upper-left corner and size of a bounding box. Input image I must be a grayscale or true colour (RGB) image.
3. insertObjectAnnotation(I,’rectangle’,Position,Label)
It inserts rectangles and corresponding labels at the location indicated by the position matrix. The position input must be an M-by-4 matrix, where each row (M) specifies a rectangle as a four-element vector (x, y, width and height). The elements x and y indicate the upper-left corner of the rectangle, and the width and height specify the size.
Testing
To test this program, follow the steps below:
1. Install MATLAB R2012a or higher version in your system. Launch it from desktop shortcut. You will see a blank command window.
2. Download the source folder given below.
3. Check the device ID, as shown in Fig. 3, and write that device ID number in the source code.
4. Run the program (count.m). A graphic user interface will appear, as shown in Fig. 1.
5. Click on Start Camera button to initialise camera settings.
6. Next click on Count Face button and the camera will start counting the faces.
7. To stop, click Stop button.
Download source folder: click here
sorry ,
i am gettng many errors while running the program
Kindly elaborate your query.
hello friend can u tell me project is working or not
Dear Ravi Kumar, this project is fully verified and in working condition.
can u send me coding of this program please
my email-ravinigam41@gmail.com
The source code is been sent to your email id.
can u send me the code venkataramanachitta5@gmail.com
if it is a working code then my matlab software requires some update to run it.Can you send me the code to venkataramanachitta5@gmail.com
sir i doing this project. so i m in need of the source codes.
can u send the source code to
srivalsan25@gmail.com
could you send the cod e to me. hongouya@yahoo.fr
can u please mail me so that i can run the program successfullly
Already sent.
can you please send the code to dhruvrana600@gmail.com
Hi, we were facing some issues earlier with the Source page. Kindly refresh the page and retry.
please send me ppt of this project.
and also code because it is not working. It take an issue after running program.
can u send a videos also with running program and also one ppt on this project.
Dear Balchand Saini, all the required information are present within the article.
send me ppt on this mail
balchand.saini@gmail.com
The source code is been sent to your email id.
hello sir i am ravi kumar sir mene face counter project par work kiya use matlab me code kiya but error aa rha hia me error ko yaha copy kar deta hu aap check kar please mujhe solution bta de
ERROR
>> count
Maximum recursion limit of 500 reached. Use set(0,’RecursionLimit’,N)
to change the limit. Be aware that exceeding your available stack
space can
crash MATLAB and/or your computer.
Error in count
hello sir please reply me fast mujhe project dena hai 29 jan ko my email is ravinigam41@gmail.com
Dear Ravi Kumar, Please write your query in English please.
i am not getting my device id sir it is saying like this sir
Error using imaqhwinfo (line 109)
Invalid ADAPTOR specified. Type ‘imaqhwinfo’ for a list of installed ADAPTORs. Image acquisition adaptors may be
available as downloadable support packages. Open Support Package Installer to install additional vendors.
can you please help sir??
Seems your webcam is not supported. You need either an inbuilt-camera or an external webcam to test the project. If you dont have camera it wont work. After connecting external camera you need to note the camera device ID.
sir please send me code of this project using mobile phone camera.
and i also send a code to interface code with matlab to cell phone camera. sir please send it to my mail.
main id-balchand.saini@gmail.com
can u send me coding of this program please
email: rezanasiripour@hotmail.com
The code is already present within the article.
Sir can u send the code for this project
rajkumar.v1999@gmail.com
The Source Code is present at end of the article.
can u send me source code of this program please npmscare@gmail.com
While running of i am getting following errors
Error event occurred at 16:55:25 for video input object: YUY2_640x480-winvideo-1.
GETDATA timed out before FRAMES were available.
Error using imaqdevice/getdata (line 149)
GETDATA timed out before FRAMES were available.
Error in count>count_Callback (line 108)
image = getdata(vid); %store that frame
in ‘image’
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in count (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)count(‘count_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Did you got solved with this error,
even I’m facing same Error,
please help
Good evening pls can u send me the code and the article write up through my mail? monforttelecom@gmail.com
Dear, the source code is already present within the article.
could you please provide the source code in any other format excep win rar as my license period is over…pls mail me to
sindhujasenapati16@gmail.com
i want a unique idea for my final year project..plz help
Hi saam, Is there any specific requirement for your final year project?
can you send me the code for this program please
my email is simonislee@gmail.com
Can you pls mail me the code
can u send me the source code to anvesh31197@gmail.com
Sent, please check your email
plz snd me source code of this project on my email address plzzzz
i really need this
The source code can be downloaded from the article itself.
Please send me source code at yasmeenqureshi363@gmail.com
The source code can be downloaded from the article itself.
can you please send me the function file of this code??
inshal.syed96@gmail.com
m getting the following error..
??? function varargout = count(varargin)
|
Error: Function definitions are not permitted in this context
can you please send the sourse code to my email id
email: nistalasushanth@gmail.com
Hello Sir;
I am sumair saeed,kindly send me the code of this project and please send some details like Requirements for this project etc.
Email:Summairsaeed123@gmail.com
Good day!
This article is a big help as a reference for my project. In line with that, I’d like to talk with you through e-mail regarding face recognition and face tracking, if possible. This is my e-mail: japitanj@gmail.com
Looking forward to talk with you soon!
can you pls send the source code for this mail id soumiyaganesan@gmail.com
can you send me the source code to ww.sairamya@gmail.com
i’m getting many errors
The source code is present on the last page of the article.
Very interesting. Please can you send me the code to ebotsmith@yahoo.com
The source code is present at the end of the article.
Can you send me the source code Sir
The source code is present at the end of the article.
please inbox the source code to bitiportal@gmail.com
The source code is present on the last page of the project.
Can you please send me the code on warkealisha@gmail.com
The source code is present on the last page of the project.
Hello Can you please me the coding it is too much pretty project I am impressed I want to learn it.
alimurtaxa2015@hotmail.com
Can you please send the full code to mkabirpulak@gmail.com?
The source code is already present at the end of the article.
can u send me coding of this program please
my email-jaypawar@yahool.com
The source code is present within the article.
Please send me the source code to ebotsmith@yahoo.com
sir can you send me the code at amitrajput.chauhan@gmail.com
Sir can you tell it’s applications or how this project can be enhaced so that I use it for my minor project?
can u please mail me the source code
can you send me the code
The source code is present on the last page of the article.
Please mail me source code…
shivamjaggi173@gmail.com
Could you please send me this code
rthappa777@gmail.com
The source code is present at the end of the article.
Hi
Kindly send the report and source code of the program on my email-id
dimple.bansal.mail@gmail.com
can you send me the source code of this article.???
Please
i am not able to open the source code of this article will you plzz send me the source code and report on my e mail id
coolab46@gmail.com
Please send source code to my email
mehranbhai475@gmail.com
Can u mail this source code to my mail. I’d classicprakash8899@gmail.com
Please send source code to my email
ramanarao0707@gmail.com
Hello EFY Team,
I am very impressed with your project. I had downloaded the source code and also run the program , but unfortunetly got many errors can please send me your source code my email id as soon as posssible. It will be very kind of you..
aamirshariff2013@gmail.com this is my email Id…
can u pls send me the code ?
can you plz send me code on my mail Muskankhan6565@gmail.com
Hi sir can you please send me the code cfaesteron@donbosco.edu.ph
can you please send me the codes. tabaneramichaelaeron@yahoo.com thanks and God bless
The source is present in the article itself.
can you please send the codes in my email? gjadera@gmail.com
The source code is present within the article.
info = imaqhwinfo(‘winvideo’)
when i do this it’s showing like this errors
Error using imaqhwinfo (line 109)
Invalid ADAPTOR specified. Type ‘imaqhwinfo’ for a list of installed ADAPTORs.
Image acquisition adaptors may be available as downloadable support packages.
Open Support Package Installer to install additional vendors.
can u help me??
can u send the source code to my mail???
my mail is—>kodurprashanth@gmail.com
could you please mail me the source code …
sowjanyareddy1997@gmail.com
can u plz send me the code ? s.ayonbd62@gmail.com
Hi, the source code is present in the article itself.
Hello! Can u please mail me the source code of this project. I tried to download it present at the end of the article but i couldn’t open it. My email is machhhume@gmail.com
Please retry downloading on a different browser.
hello sir ,I have gone through the codes but finding some errors ,please send the codes at rohitkv431@gmail.com
Hi Rohit, the source code is present in the article itself.
Hello there, could you please send me the source code
email address: gamil5005@gmail.com
Hi, the source code is present in the article itself.
kindly send me the code on my email.I will be really thankful to you!!
rajputhamza15@gmail.com
sir please snd the code at riomaster71@gmail.com
sir please snd the code at varun.risbud14@gmail.com
The source code is present in the article itself.
can you please send me the source code for this project
The source code is present in the article itself.
can u send me coding of this program please
my email-amanshah0224@gmail.com
The source code of this project is present at the end of the article.
sir send me source code of this project at harshas380@gmail.com
Hi Harsha,
Source code can be downloaded at the end of the article.
please send to me Matlab code of this project
Hi Rakesh, the MATLAB code is present at the end of the article.
this is very nice project for beginers.
thank to efy team
You are most welcome.
hai, can I have the source code for this project? Email me at shafiqahyusoff96@gmail.com. thank you
Sir can you send me code to this email address,
and also, can you plz explain its method with video..!
Hi, the source code is available at end of the article.
For the video, I have forwarded your request to the concerned person.
please can you send me the source code to run on my pc
HI Jay, the source code can be downloaded from the last page of the article.
Sir can you send me code,
larteyjason123@gmail.com
and also, can you plz explain its method with video..!
can u send me this code pls adteja52@gmail.com
Can you please send me the code?
The source code is present at the end of the article.
Can yo please send me the code
adil.redaoui28@gmail.com
can you send me the code for this program please
my email is aeinthmu2397@gmail.com
Hey Sir, can you send me source code,
sabarao081@gmail.com
and can you please explain its method with video..!
Sir can you send me code,
bhuvana16198@gmail.com
and also, can you plz explain its method with video..!
Hi sir…!
i am not getting the overall count
sir…!please help with this
this is my mini project…!
Sir, first of all, thank you for sharing such a helpful project article. Sir, I’m working on this project and need a bit of help.
I execute your given source code, after executing GUI gets starts but when I press the start camera button nothing happens. I can also share the video recording of what happening when I’m going through the process.
Need your Assistance, because I’ve to submit this project.
Sir need your help, I followed all the procedure but when I execute the program and after that Gui got open. But when I press the start camera button nothing comes up although I’ve selected the device Id ‘1’ following the testing procedure mentioned above.
Sir need your help as soon as possible.
Can uhh please send this project ??
Sir can you send me this project details and source code on my mail:
abdulnoiman16@gmail.com
Hi Abdul Noman, you can download the Source Code from the article itself.
sir can you send me the code: sowndharyam8@gmail.com
You can download the source code from here: https://www.efymag.com/admin/issuepdf/Face_counter_in_matlab.rar
Hi
Can you send me the code for this program.
hello, I download the source code but it’s appearing in weird characters that my Matlab doesn’t recognize can you send me the code plesase
What was the actual error message? Please note that the project was tested using MATLAB R2012a and you need a blank .jpg file in the main source code folder. Try again by downloading the source code from here: https://www.efymag.com/admin/issuepdf/Face_counter_in_matlab.rar
Hi sir..!will u please send me this project source code as i have to submit it by this saturday.My email address is javeriajadoon093@gmail.com please reply me.I will be very thankful to you for this kind favour.
The source code is present at the end of article.
I want full source code and also for picture 1&2 please send to my email.
My email is gavendrapal001@gmail.com
Can anyone send me the full coding program for this project …pleases
Sir can u send me the matlab program of this project … I like the idea and wanna try once .
My email is gavendrapal001@gmail.com
The Matlab program is present at the end of the article.
Source code is not opening
Please refresh the page and download.
can you send me the source code to my email id?
Hi Marimuthu, you can download the source code from the end of the article.
Hii! Can you please send me the program code of this project?
Hi Manoj, the Source Code of the project is present at the end of the article.
sir please send me the source code to my mail because its my term project when i run project they got many errors
wardahaide0@gmail.com
The source code is present at the end of the article.
Can u please send me the code at savegodrout@gmail.com
Hi Shreya, you can download the source code from the end of the article.
can you please send the source code to my mail , as the bottom link is not working
dhruvrana600@gmail.com
Hi, we were facing some issues earlier with the Source page. Kindly refresh the page and retry.
Can you please share me the source code on the below email id
shreyrathod45@gmail.com
it would be a great help
thank you
Hi, we were facing some issues earlier with the Source page. Kindly refresh the page and retry.
Can you please send the source code to my mail
dhruvrana600@gmail.com
thank you.
Hi, we were facing some issues earlier with the Source page. Kindly refresh the page and retry.
Error using StringSet.checkValues (line 115)
The empty string is not a valid StringSet string.
Error in C:\Program
Files\MATLAB\R2013a\toolbox\matlab\system\+matlab\+system\StringSet.p>StringSet.setValues (line 101)
Error in C:\Program
Files\MATLAB\R2013a\toolbox\matlab\system\+matlab\+system\StringSet.p>StringSet.StringSet (line 32)
Error in insertObjectAnnotation>getSystemObjects (line 538)
textInserter = vision.TextInserter( …
Error in insertObjectAnnotation (line 109)
[textInserter, boxInserter, cache] = getSystemObjects(shape, …
Error in testing>face_Callback (line 105)
hello = insertObjectAnnotation(handles.im,’rectangle’,bbox,’Face’);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in testing (line 42)
gui_mainfcn(gui_State, varargin{:});
facing these errors please help
actually i wirriten the code correctly but it was facing some issues can you plz send the source suryakolla11@gmail.com