Face Recognition Using Opencv in Python
Face Recognition Using Opencv in Python
Face Recognition Using Opencv in Python
USING OPENCV
IN PYTHON
BY
import sys
imagePath = sys.argv[1]
cascPath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread(imagePath)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30)
cv2.waitKey(0)
Input:
Output:
Description:
OpenCV is the most popular library for computer vision. Originally written in
C/C++, it now provides bindings for Python.
OpenCV uses machine learning algorithms to search for faces within a picture.
Because faces are so complicated, there isn’t one simple test that will tell you if
it found a face or not. Instead, there are thousands of small patterns and
features that must be matched. The algorithms break the task of identifying the
face into thousands of smaller, bite-sized tasks, each of which is easy to solve.
These tasks are also called classifiers.
For something like a face, you might have 6,000 or more classifiers, all of which
must match for a face to be detected (within error limits, of course). But therein
lies the problem: for face detection, the algorithm starts at the top left of a
picture and moves down across small blocks of data, looking at each block,
constantly asking, “Is this a face? … Is this a face? … Is this a face?” Since there
are 6,000 or more tests per block, you might have millions of calculations to do,
which will grind your computer to a halt.
To get around this, OpenCV uses cascades. What’s a cascade? The best answer
can be found in the dictionary: “a waterfall or series of waterfalls.” Like a series
of waterfalls, the OpenCV cascade breaks the problem of detecting faces into
multiple stages. For each block, it does a very rough and quick test. If that
passes, it does a slightly more detailed test, and so on. The algorithm may have
30 to 50 of these stages or cascades, and it will only detect a face if all stages
pass.
The advantage is that the majority of the picture will return a negative during
the first few stages, which means the algorithm won’t waste time testing all
6,000 features on it. Instead of taking hours, face detection can now be done in
real time.
Since face detection is such a common case, OpenCV comes with a number of
built-in cascades for detecting everything from faces to eyes to hands to legs.
There are even cascades for non-human things
Future Aspects:
Over the past few years, we have seen major developments to facial recognition
technology. We now live in an age that our predecessors have only dreamed in
fiction and film. Face recognition is one of the newer developments of biometric
identifiers that doesn’t require as much time or intrude on the person its
verifying. Other biometric identifiers, such as fingerprint scanners and voice
recognition, requires many different pieces in order to function. Face recognition
is a highly effective biometric technology that holds a lot of potential.
Today, one of the fields that uses facial recognition the most is security.
Facial recognition is a very effective tool that can help law enforcers
recognize criminals and software companies are leveraging the technology
to help users access their technology. This technology can be further
developed to be used in other avenues such as ATMs, accessing
confidential files, or other sensitive materials. This can make other
security measures such as passwords and keys obsolete.