Justin Pinkney

MATLAB Face Detection with MTCNN ๐Ÿ”Ž๐Ÿ˜„

Last touched June 06, 2020

Get a fast and accurate face and facial feature detector for MATLAB here


Everyone pretty much takes good quality face detection for granted these days, and itโ€™s essentially a solved problem in computer vision. Everyoneโ€™s photo app can detect all the face you care about and computer vision competition results are increasingly focussing on performance for difficult, small, or occluded faces.

Although MATLAB has a face detector built into the Computer Vision Toolbox Iโ€™m sure most who have had some reason to use it have come away disappointed. Honestly, itโ€™s pretty outdated as deep learning has totally revolutionised computer vision since that face detector was released.

MATLAB's face detection in yellow, MTCNN in teal.
MATLAB's face detection in yellow, MTCNN in teal.


There are now tons of deep learning based face detectors, each of them eeking out more and more performance on standard benchmarks. But sometimes you just want something that is pretty good and well tested in real life.

Image source: NASA
Image source: NASA

Multi-task Cascaded Convolutional Neural Network (MTCNN) is a little old but has a fairly simple architecture, is small and fast, and performs well. It also has the additional advantage of outputting the locations of facial features (eyes nose and mouth). Itโ€™s been widely used for a pre-processing step in lots of other applications and it works well and reliably.

Multitask Cascade CNN (MTCNN) was state of the art in 2016 and is still pretty good for most faces.
Multitask Cascade CNN (MTCNN) was state of the art in 2016 and is still pretty good for most faces.


Iโ€™ve ported the original MTCNN pre-trained weights into MATLAB, using some of the deep learning features introduced in R2019b. (Iโ€™ve also done some work to make sure that it still runs in R2019a, although itโ€™s a little slower.)

Iโ€™ve released this as an open source project, the code and toolbox (for simple install) is available on GitHub


One thing to note is that the current code doesnโ€™t support training a new model, although this would be perfectly possible to do. People donโ€™t seem particularly interested in training a new model, just using the standard pre-trained weights. If Iโ€™m wrong about this and youโ€™re desperate to train you own models please comment on this issue to let me know.

๐Ÿ’ฌ If you want to comment say hello on Twitter.
ยฉ 2022, Justin Pinkney