Simple face detection package for MLHUB
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Simple Face Detection

This is a simple face detection example of using machine learning algorithms to search faces within a picture. It originates from Shantnu Tiwari's tutorial -- Face Recognition with Python, in Under 25 Lines of Code and Face Detection in Python Using a Webcam. It uses OpenCV cascade to break the problem of detecting faces into multiple stages. The algorithm starts at the top left of a picture and moves down across small blocks of data. During the moves, a series of coarse-to-fine quick tests are carried out on each block. And it will only detect a face if all stages pass.

See the github repository for examples of its usage:


  • To install and demostrate the algorithm:

    $ pip3 install mlhub
    $ ml install   facedetect
    $ ml configure facedetect
    $ ml demo      facedetect


To detect faces:

  • From a local image file:

    $ ml score facedetect ~/.mlhub/facedetect/images/abba.png
  • From an image on the web:

    $ ml score facedetect
  • From your camera:

    $ ml live facedetect

Sometimes the algorithm will fail to detect real faces, then you need to fine-tune the parameters to get the ideal results:

$ ml score facedetect
$ ml score facedetect --scaleFactor 1.3
$ ml live facedetect --scaleFactor 1.3 --minSize 7 --minNeighbors 40