Viola Jones method

from Wikipedia, the free encyclopedia
The Viola Jones Method recognized three of the four faces.

The Viola Jones method is a mathematical process for pattern recognition in digital images. It was suggested in a paper by Paul Viola and Michael Jones in 2001 and gained worldwide popularity for its efficiency. The Viola Jones method recognizes striking objects such as faces in an image in real time.

background

In the early 2000s, digital photo and video cameras became fashionable and slowly replaced analog cameras. The increasing flood of digital images created a demand for the technical face recognition that was difficult to do with analog media . There were two key uses for this:

  • Face detection to automatically adjust the focus;
  • Data analysis in order to be able to assign certain faces in databases to other data.
Viola-Jones basic pattern

Paul Viola and Michael Jones developed their method with the free program library OpenCV , which provides algorithms for image processing and computer vision . Your method can be found in OpenCV at CascadeClassifier::detectMultiScale(). The previously most common method (and in parts also used by Viola-Jones) are the hair wavelets developed by Alfréd Haar in 1909 .

Viola-Jones does not consist of a classic algorithm, but is based on controlled learning, so-called machine learning : the program looks at several images and trains itself to find out similarities. The learning cascades follow the AdaBoost meta-algorithm from 2003.

The main advantages of the method over other methods are its speed and robustness; not only faces can be recognized very efficiently. The picture size hardly plays a role either; the process does not scale the entire image, only the relevant content. The main disadvantage is that the faces must be seen from the front and be well lit. To evaluate half-profiles, Viola-Jones is usually coupled with the Kanade – Lucas – Tomasi-Tracker .

Program example in Python

The following short program example in the programming language Python requires the installation of opencv-python . This program code and the two required files must be in the same directory. The example program recognizes faces in the picture and marks them with colored frames. The file "haarcascade_frontalface_default.xml" generated by training comes from the source code of OpenCV, the image to be examined "Jimmy_answering_questions.jpg" is on Commons.

import cv2  # pip install opencv-python

# Erzeugen der haar cascade
faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")

# Bild einlesen
image = cv2.imread("800px-Jimmy_answering_questions.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Gesichter im Bild erkennen
faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30)
)

print("Anzahl gefundener Gesichter: {0} ".format(len(faces)))

# ein Rechteck um jedes gefundene Gesicht zeichnen
for (x, y, w, h) in faces:
    cv2.rectangle(image, (x, y), (x+w, y+h), (255, 0, 0), 2)

cv2.imshow("gefundene Gesichter", image)
cv2.waitKey(0)

Other objects can be found in images and films by using other hair cascades files. One application is the detection of moving automobiles. Working sample programs are available on GitHub.

Individual evidence

  1. Rapid object detection using a boosted cascade of simple features and Viola, Jones: Robust Real-time Object Detection , IJCV 2001
  2. Thorsten Ball: Train Your Own OpenCV Hair Classifier. In: Coding Robin. July 22, 2013, accessed November 2, 2018 .
  3. Naotoshi Seo: Tutorial: OpenCV hair training (Rapid Object Detection With A Cascade of Boosted Classifiers Based on Hair-like Features) - Naotoshi Seo. October 16, 2008, accessed November 2, 2018 .
  4. Shantnu Tiwari: Face Recognition with Python, in Under 25 Lines of Code . Ed .: Real Python. (English, realpython.com [accessed November 4, 2018]).
  5. ^ Rainer Lienhart: OpenCV data / haircascades /. In: GitHub , OpenCV. Intel, accessed November 4, 2018 .
  6. Wikimania2009 Beatrice Murch: Deutsch: Jimmy Wales answering questions at Wikimania 2009 press conference. August 25, 2009. Retrieved November 4, 2018 .
  7. ^ Tobias Weis: Training Cascades to detect cars. Accessed November 4, 2018 .
  8. Andrews Cordolino Sobral, Ph.D .: Vehicle Detection with Hair Cascades. Accessed November 4, 2018 .