This is a simple system for detecting and tracking multiple faces from live video. It uses the Computer Vision System Toolbox and the Webcam Support Package. The system detects faces using the Viola-Jones algorithm, detects min-eigen corners within each face's bounding box, and tracks the corners using the Kanade-Lucas-Tomasi (KLT) algorithm. It re-detects the faces every 10 frames in order to correct the tracker and replenish the points.
Dima Lisin (2021). Detect and Track Multiple Faces (https://www.mathworks.com/matlabcentral/fileexchange/47105-detect-and-track-multiple-faces), MATLAB Central File Exchange. Retrieved .
it's working, but it will stop if it's no face. not good for surveillance
hi ... how can i use computer vision toolbox ,thnx
hai, this function is an error when there is no face
Error in detectAndTrackFaces (line 58)
displayFrame = insertObjectAnnotation (framergb, 'rectangle', ...
how to fix it?
Dear Dima Lisin
based on which article references that you are used to developed this algorithm?
Hi Dima..i had these errors when run the code;
Attempt to reference field of non-structure array.
Error in MultiObjectTracker/addDetections (line 109)
Error in MultiObjectTracker2 (line 29)
How to overcome this errors? I hope you can reply asap, thanks :)
please, i need to modify pointTracker.m
I have error writing pointTracker.m
Hi, I have tried for multiple people detection in a video but the problem I'm facing while detection is that the bounding box is not making for a specific number of people and also it continues to make bounding box again and again for the same number of people.could you please provide the steps where the loop should stop.
Undefined function 'thingSpeakRead' for input arguments of type
Error in main_modv3 (line 16)
It breaks when there is no face in the frame.
Error using insertObjectAnnotation
Expected LABEL to be nonempty.
Error in detectAndTrackFaces (line 58)
displayFrame = insertObjectAnnotation(framergb, 'rectangle',...
it is giving an error in the line
tracker = MultiObjectTrackerKLT;
if there is no object,it will break.
Hi,if I want to count how many faces in the video I had detected,what should I do?Could you provide me some good ideas?
Hi Dima, please write the steps to be followed to run this program...
how to make the program play the video before detect the face?
(since this code only display the sequence after detect the face).
How can i estimate the change in position eye by using this code?
How to input images sequence?
Can the class file(MultiObjectTrackerKLT) be put in a matlab directory so that the script can be executed without keeping the both in same directory?
Or, is it possible to set the path for the class in the script?
Thanks & regards
Wonderful work is done Sir. Thanks a lot.
You have to install the Webcam Support Package for this to work:
Undefined function or variable 'webcam'.
Error in detectAndTrackFaces (line 10)
vidObj = webcam;
Can u tell me whats wrong??
I am from computer science background..
Thanks for uploading the codes.
After running the program, I am getting the below error:
Error using matlab.webcam.internal.WebcamController/getCurrentFrame
Time out occured while trying to get a frame from the webcam.
Error in webcam/snapshot (line 227)
[image, timestamp] = obj.CamController.getCurrentFrame();
Error in face_prac (line 16)
frame = snapshot(vidObj);
Can u please help me to debug this.
Thanks in advance.
Of course, there is. You would have to modify the code to crop each bounding box using imcrop(), and save it using imwrite().
please is there a way to detect and track the face and save it into a folder for a trainning images
I am not sure what you mean. What you download is a .zip file. You then have to extract the .m files from it. On Windows, you should be able to do that from the Windows Explorer. On Linux, you can use the unzip command on the command prompt.
Alternatively, you can simply click on the links to the .m files on the right, and save them to your local machine one by one.
can somebode please tell me how to get the code from this file ? it seems encrypted
Thanks lot. It is very useful.
very usefull work, thank so much...
Hi! Thank you so much for this amazing file. Would there be any additional documentation or code on how to train your algorithm further? That is, would it be possible for us to cross-validate all the frames that are rendered to see how many of them belong to the same face?
It sounds like you may be running an older version of MATLAB. This example requires R2014a or later, and it also requires the Computer Vision System Toolbox.
It sounds like the directory containing the files needed for this example is not on your path. The easiest thing is to change your working directory to the one where you have downloaded the files.
To use webcam you have to install the Webcam Support Package, which is a type of plugin. The error message should contain a link, which will take you to the Support Package Installer.
hii this code not running at all in my system showing some line 100 annotation error what should i do
i am running but there is error saying
"Undefined function or variable 'MultiObjectTrackerKLT'."
Please help me
i am try to run, but getting some ERROR >
Error using webcam (line 13)
MATLAB Support Package for Webcams has not been installed. Open Support Package Installer to install the Webcam
i am use MATLAB 2014a
@Carnie, all you have to do is use vision.VideoFileReader to read the video one frame at a time. The step() method of vision.VideoReader would replace the calls to snapshot().
Hello, can anyone tell me what modifications should we make to this code to make it work on a video rather than webcam?
I'm not proficient at the MATLAB, and don't know how to add the code to turned off the camera. Could you help?
@Ben, cool! Thanks for the tip.
I found a way to handle this by using the onCleanup function as below:
%% Setup a clean up function to deal with Ctrl-C
fnCleanup = onCleanup(@() cleanup(videoPlayer, vidObj));
And then simply write a function like this:
function cleanup(videoPlayer, vidObj)
%% Clean up
This works fine on my Mac.
Hi Ben. Thank you for trying it out! Unfortunately Ctrl-C cannot turn off the camera. To turn it off, you would have to clear vidObj. As of R2014b, you can use the isOpen() method of vision.VideoPlayer to exit gracefully when the player window is closed.
One minor issue: the camera was not turned off after pressed "Ctrl+C" to exit.
Thanks a lot for sharing! It ran very well on my first trial.
Hi Lee. Unfortunately that will not work. The code uses features from R2014a. The key component here is vision.PointTracker, which was introduced in R2012b. So, with some work, you can probably make it run on R2012b or later.
How to do this code run on matlab r2007b version ?
Unfortunately, this code will not work in 2012a. With some tweaking you can probably make it work in 2012b, which is when vision.PointTracker was added.
Hi, I am kind of started for video analytic. Actually I am unable to run the code. Can i run this code on MATLAB 2012a?
@txrxmo, detectAndTrackFaces.m is a script, which you can run from the command prompt. It uses vision.VideoPlayer to display the video.
Hi. This system can be used for a matlab GUI editor? Or its for command window?
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!