Object detection and tracking are important in many computer vision applications, including activity recognition, automotive safety and surveillance. Presented here is an face detection using MATLAB system that can detect not only a human face but also eyes and upper body.
Face detection is an easy and simple task for humans, but not so for computers. It has been regarded as the most complex and challenging problem in the field of computer vision due to large intra-class variations caused by the changes in facial appearance, lighting and expression. Such variations result in the face distribution to be highly nonlinear and complex in any space that is linear to the original image space.
Face detection is the process of identifying one or more human faces in images or videos. It plays an important part in many biometric, security and surveillance systems, as well as image and video indexing systems.
This face detection using MATLAB program can be used to detect a face, eyes and upper body on pressing the corresponding buttons. The program output screen is shown in Fig. 1.
Software program
This real-time face detection program is developed using MATLAB version R2012a. A graphic user interface (GUI) allows users to perform tasks interactively through controls like switches and sliders. You can easily create a GUI and run it in MATLAB or as a stand-alone application. The initial program output of this project is shown in Fig. 1.
Viola-Jones algorithm. There are different types of algorithms used in face detection. Here, we have used Viola-Jones algorithm for face detection using MATLAB program. This algorithm works in following steps:
1. Creates a detector object using Viola-Jones algorithm
2. Takes the image from the video
3. Detects 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, you have to find the format supported by the camera and its device ID using the command given below (also shown in Fig. 2):
imaqhwinfo(‘winvideo’)
After finding the device ID, you can change the device ID number in your source code.
The device ID here is {1}, so we have written ‘1’ in the code, as mentioned below:
vid = videoinput(‘winvideo’,1,’YUY2_
640×480’);
We also have other formats in MATLAB. You can check which format your camera supports by using the commands below (also shown in Fig. 3):
info.DeviceInfo (1)
info.DeviceInfo.SupportedFormats
In Fig. 3, you can see that format ‘YUY2_160x120’ is the one supported by the camera by default. But, there are other formats (resolutions) that your camera can support, as shown in the last line of this screenshot. If you select a different 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, use the following steps 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 Viola-Jones algorithm. Its classification model property controls the type of object to detect. By default, the detector is configured to detect faces.
Download Source Code for the face detection using MATLAB project:Â click here
2. Call the step method with input image I, cascade object detector, points PTS and any other optional properties.
Below is the syntax for using the step method. Use the step syntax with input image I, selected cascade object detector and other optional properties to perform detection.
BBOX = step (detector, I)
It returns BBOX, an M-by-4 matrix defining M-bounding boxes, containing detected objects. This method performs multi-scale object detection on input image I. Each row of 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 gray scale or true colour (RGB) image.
3. The third step is:
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). Elements x and y indicate the upper-left corner of the rectangle, and the width and height specify the size.
Face detection using MATLAB system testing
To test this program, follow the steps given below:
- Install MATLAB version R2012a or higher version in your system. Launch it from desktop shortcut. You will see a blank command window.
- Download the source folder.
- Check the device ID, as shown in Fig. 2, and write the device ID number in the source code.
- Run the program. A GUI will appear, as shown in Fig. 1.
- Click on Start button to initialise camera settings.
- Next, click on Face button and the camera will detect the face. Your face will be detected and displayed on the right side of the screen (Fig. 4). Similarly, you can also detect your eyes and upper body by clicking on the respective buttons. The output screenshots for the detected eyes and upper body are shown in Fig. 5 and Fig. 6, respectively. Remember to click Stop button first to stop the previous process in order to detect other two features.
- To stop, click Stop button.
The author is a B.Tech in electronics and communication from SRCEM, Gwalior.
Upload source code can please , because I can not download it
Dear caleb,
The article has been updated with correct source code.
dear Publisher
can i have your email address i need to buy the software from you if its possible.
Dear aras, we are not a software provider. But for reference you can check out these open source alternatives to MATLAB: https://www.electronicsforu.com/resources/4-free-open-source-alternatives-matlab
Where can i get the correct source code plzzz i need it
The source code is already present within the article.
Hi
I need to this project.
please mail to me.
thanks
[email protected]
All the information regarding this project is already present within the article.
it does not work , i have made all changes as you mentioned but still it does not work ! i’m using linux OS (Ubuntu) ??
Though we have not tested it on Ubuntu, it is working well in Windows.
Download the code from our website or DVD, make sure that you put all the files in one folder as it is. Then run the program again.
Plzz can any provide the code of this [email protected].i will buy it plsss
Dear Harish,
The source code is present on the second page of the article.
Hello .. I am an electronics student .. I am doing projects regarding security .. I just wanna come in contact with you . My mail id [email protected] ..
Plz send d code
I want to execute this project
[email protected]
hello….can suggest me code for multiple face detection.
Hi EFY. I had tried this project on my laptop. It worked well, but when i try to change from face to eyes when pressing stop button i am getting some errors.
after pressing face button,face gets detected. then i pressed stop. then the following errors occured.
Error using imaqdevice/trigger (line 48)
OBJ must be running before TRIGGER is used.
Error in testing>face_Callback (line 102)
trigger(handles.vid);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in testing (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)testing(‘face_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
did you got any solution for this??
hy, have you done it sucessfully ?
i got the same error help me if you have any solution…
hi i am doing project in matlab for fault detection in the railway track circuits. can i do in real time and how ? please help me.
You should upload the new code based on the r2017a model!!
Bro plz send me the code
Please refresh the page and download from the link given at the end of the article
can i get the source code
[email protected]
You can get source code at the end of the article.
Good source code with no problems with r2016a version . Thanks alot !
You are most welcome.
Bro plz contact me
Hi, can i get the source code
[email protected]
Source code is present at end of the article.
very nice work.. form your side….. i have run using matlab… Thnx
Thanks for your feedback.
salam dear can you help me i am felling troubles in runing this code?
Sir i cannot see any link to download the source code… can u just place it here in comments?
plz can you send me the source code ? on [email protected]
please can you send the source code to me? i am really interested in this [email protected]
Can you please let me know whether it is successful for multiple face detections?
the source code please
The source code is present at the end of the article.
Can I have the source code please..I’m interested in this project
The source code is present at the end of the article.
i want to change stop function into next function i tried but i can’t get the answer
can the matlab used for the real time video from drone?
Plz send code for this project
Hi, can i get the source code
[email protected]
The source code is present within the article.
can i use the camera on my laptop for this project
Hello guys how can i do the, using my inbuilt laptop camera..
First, you have to find the format supported by the camera and its device ID using the command given below (also shown in Fig. 2):
info = imaqhwinfo(‘winvideo’)
Can you send me the project
May have the sourcecode for the project on mail id [email protected]
hey what camera are u using?
Is it the one on the laptop like the webcam or something else
Testing was done using laptop inbuilt web camera.
Hello Am trying to run this program on Matlab R2018a but it display error can u plz guide me with the code used for 2018 version .
i have same probelm
sorry, can u helpme with the code, i need it for my proyect, i try to download but, isn’t vailable on the page
Hi Alexander,
Previously we were facing some technical issue, you can download the source code now.
can u send me coding of this program please
my [email protected]
The source code of this project is present at the end of the article.
Hi, can i get the source code
plzzz i really need for final year project
[email protected]
Hi Shilpa,
The source file is present at the end of the article.
this source code is not opening …mail me its code please @[email protected]
Hello, I tried the code but i’m getting the following error:
>> testing(varargin)
Attempt to execute SCRIPT varargin as a function:
C:\Program Files\MATLAB\MATLAB ProductionServer\R2015a\toolbox\matlab\lang\varargin.m
which language is the testing.m (source) file written in ? phyton or c++ or any other?
plz if some one found the code send it to me
[email protected]
The source code is present at the end of the article.
Hi
What classifier you used in this project?
Regards
How to check system id ,,where to execute that system id command
dear i need this project
i will pay please give some time and code
[email protected]
Hi Asad Ali, this project is free to read and try it yourself. The source code is present at the end of the article.
sir ,my project is based on matlab project title is facial expression recognition in humans using image processing
plz help me for matlab coding
hi I think you probably have issues with your link to the file, when download is clicked the total download size is only 7 kilobytes of corrupted text, i’v also noted that the majority of your communication response is ”The source code is present at the end of the article.” everyone visiting your sight is actually using valuable time trying to get somewhere in their life believe that this could be the right place to be, after a some time people get fed-up with how they get treated on a specific sight and probably find alternative ways but after numerous attempts by visiting your sight neither side besoms a winner and efforts from Bothe sides becomes a waist of time but more so from your prospective as you’ve actually taken time and effort to create this page. I hope you can actually convert this in to a wine for both sides if you understand what is that I’m ting to explain here
regards
Jessie
sir ,my project is based on matlab project title is facial expression recognition in humans using image processing
pleaze help me for matlab coding
You can use the same MATLAB code.
contact me. I will help you out. I developed facial expression recognition with 2 different methods.
mob no: 9175590898, mail:[email protected]
Sir,
I sent many letters regarding for many projects, but you have not replied so kindly send information for the MATLAB face detection and it may not be useful if you are going to publish the projects and moreover
a lay man like myself could not understand the above projects. So I may request you to send one complete CD and if possible one pen drive with four or five projects and you can charge for the same and kindly write down your opinion without fail.
With regards,
(Srinivasa rao kandoti)
Kindly send an email with all the required information on [email protected]
Share the source code of face spoofing detection. Because I want to execute it within one month. Please help me. My email ID is [email protected]
salam dear can you help me i am felling troubles in runing this code?
Kindly elaborate your query.
I am not able to download the source code. It says error opening file. Please help
Hi Pragyan Paramita Nanda, I have checked it, the source file is correct. The image file in the JPEG format should be blank as per the design.
will you send me the correct code at
[email protected]
Hi Balram, I have sent you the Source Code to your email ID.
I am not able to download the souce code ….Can u please send the code to my mail…
Kindly refresh the page and retry.
HI, Getting this error, kindly help;
Error in @(hObject,eventdata)testing(‘stop_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
its blank after downloading
Kindly turn off your PCs Antivirus. I think the antivirus is deleting the files after uncompressing the folder.