<< Chapter < Page Chapter >> Page >

Application of classsifier to facial recognition

The final output of the cascade classifier training is a classifier XML file that contains the results of the training.OpenCV then provides an easy module to apply that XML file to real time face detection. We just need to import the file, pre-process our images (or frames from real-time videostream), and then run the OpenCV object detection functions.

Fig. 22. cascade training framework

Cascade training framework

We load the trained classifier, load our image, and then the object detect functions returns the position of any foundfaces as a Rectangle with identifiers (x, y, width, height). With the returned positions, we can draw a basic rectangle of thedetected facial regions or even perhaps take it a step further and apply Daft Punk masks to any detected faces.

Fig. 23. sample input image to the classification

Sample input image to the classification

Fig. 24. detected faces from the image of figure 23 using the trained frontal face haar classifier

Detected faces from the image of Figure 23 using the trained Frontal Face HAAR classifier

Fig. 25. sample application of facial recognition: scale-invariant daft punk masks applied to detected facial regions in real-time

Sample application of facial recognition: scale-invariant Daft Punk masks applied to detected facial regions in real-time

Gpu parallelization and cuda implementation

The CUDA implementation in OpenCV’s object detection framework takes advantage of the inherent parallelizationavailable in pre-processing the images and traversing all of the image sub-windows.

Unlike previously with the edge detection and motion detection, where there is no singularly accepted CUDA implementationof the aforementioned algorithms, with facial recognition, OpenCV’s library has been heavily optimized over the yearsto provide that functionality

It would an interesting case study then to abstract the functionalities of their object detection libraries, and comparethe speedups attained from using a heavily optimized 3rd party library against the speedups which we obtained from programswritten by us from scratch.

OpenCV’s CUDA implementation is similar to its serialCPU implementation, except that the cascade classifier is loaded in a CUDA optimized format, and the images are loadedand processed in CUDA-optimized matrices formats created by OpenCV.

High-level python implementation

We again provide sample Python code to demonstrate how the facial recognition algorithm would be implemented ona high level, with the details of implementation abstracted out. The Python OpenCV library exposes an API for facialrecognition via a cascade classifier, as shown in Listing 10.

Listing 10. python implementation of facial recognition with opencv

import cv2 IMAGE = 'richb.jpg'CASCADE_DATA = 'haarcascade_frontalface_default.xml' face_cascade = cv2.CascadeClassifier(CASCADE_DATA)faces = face_cascade.detectMultiScale( cv2.imread(IMAGE, cv2.IMREAD_GRAYSCALE),scaleFactor=1.1, minNeighbors=5,minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE,) # faces now contains tuples indicating the location and size of each detected face in the image

Gpu speedup results

Our code for separable convolution, computation of the image’s gradient magnitude and angle, non-maximum suppressionand selective thresholding, and computation of the thresholded difference and spatial difference density matriceshas both serial CPU and parallel CUDA implementations. Both the CPU and GPU implementations of the entire facialrecognition algorithm are encapsulated in an OpenCV library internally implemented with CUDA. Here, we present speedupresults for each of these procedures on various image sizes obtained on a system with the following hardware:

Questions & Answers

I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
How can I make nanorobot?
Lily
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Berger describes sociologists as concerned with
Mueller Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Elec 301 projects fall 2015. OpenStax CNX. Jan 04, 2016 Download for free at https://legacy.cnx.org/content/col11950/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Elec 301 projects fall 2015' conversation and receive update notifications?

Ask