Beyond Face Detection-OpenCV - opengl

I used the information provided in the OpenCV wiki to make a face detection program which identifies the presence of a face in the Camera feed. The source code that I used was provided in the link given below
http://docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html
Now I wanted to take it to another level so that it can actually identify the ears also. Thus I would want to place a mask on the users face which shows the presence of face and also the ears, something like
http://code.google.com/p/ehci/wiki/6dofhead
How to do this without using OpenGL, and using some kind of cascade classifier?

There HaarCascades available for ears, eyes, nose, mouth, etc. You can use them in the same way as you used Face cascades to detect faces. The cascades are provided with the source.
OpenCV-version/data/haarcascades

There is a facedetector example in the OpenCV distribution that shows how to detect the face and some other face features. All you have to do is to send the cascades names to the executable. The cascades are located in the openCV_install/data/cascades/
Here is the latest tutorial
and there is a bit older one, compatible with the older cascades.

Related

dlib vs opencv which one to use when

I am currently learning OpenCV API with Python and its all good. I am making decent progress. Part of it comes from Python syntax's simplicity as against using it with C++ which I haven't attempted yet. I have come to realize that I have to get dirty with C++ bindings for OpenCV at some point if I intend to do anything production quality.
Just recently I came across dlib which also claims to do all the things OpenCV does and more. Its written in C++ and offers Python API too (surprise). Can anybody vouch for dlib based on their own implementation experience?
I have used both OpenCV and dlib extensively for face detection and face recognition and dlib is much accurate as compared to OpenCV Haar based face detector. ( Note that OpenCV now has a DNN module where we get Deep Learning based Face Detector and Face Recognizer models. )
I'm in the middle of comparing the OpenCV-DNN vs Dlib for face detection / recognition. Will post the results once I'm done with it.
There are many useful functions available in dlib, but I prefer OpenCV for any other CV tasks.
EDIT : As promised, I have made a detailed comparison of OpenCV vs Dlib Face Detection methods.
Here is my conclusion :
General Case
In most applications, we won’t know the size of the face in the image before-hand. Thus, it is better to use OpenCV – DNN method as it is pretty fast and very accurate, even for small sized faces. It also detects faces at various angles. We recommend to use OpenCV-DNN in most
For medium to large image sizes
Dlib HoG is the fastest method on CPU. But it does not detect small sized faces ( < 70x70 ). So, if you know that your application will not be dealing with very small sized faces ( for example a selfie app ), then HoG based Face detector is a better option. Also, If you can use a GPU, then MMOD face detector is the best option as it is very fast on GPU and also provides detection at various angles.
For more details, you can have a look at this blog

Is Face Detection needed before doing annotation - Image Processing

I need to annotate frontal (or near frontal) images using openCV. I'm currently going through the OpenCV manual and the book "Mastering OpenCV". This is the first time I'm using OpenCV and due to that I'm little bit confused with annotation and face detection.
I need to mark about 25 points in the human face. The required points are there in eyes, mouth, nose, eyes, ears .My question is :
Is it necessary to detect the face first, and then eyes, eyebrows, mouth, nose, ears. Is it the case that then only I can proceed with annotation. The reason why I'm asking this is that I'll be doing the annotation manually. So that, obviously I can see where the face is and then eyes, nose etc. I don't see the point of detecting the face first.
Can someone explain whether face detection is really needed in this case ?
According to the book "Mastering openCV" , I need to do the following step-by-step.
(1) Loading Haar Detector for face Detection
(2) Grayscale colour conversion
(3) Shrinking the image
(4) Histogram Equalization
(5) Detecting the face
(6) Face preprocessing to detect eyes, mouth, nose etc.
(7) Annotation
Face detection allows a computer algorithm to search an image much much faster for the features like eyes & mouth.
If you are annotating the image yourself then it is of course much quicker just to annotate the wanted features and ignore unwanted ones.
No, You don't need to annotate landmarks for face detection, Opencv provide you by some functions to detect faces, using some already trained models using Haar Cascades classifiers, prepared in opencv package as xml files, you just need to call them as explained here
Annotation of images by some predefined landmarks is used to detect facial expression, and some facial details as estimation of head pose in the space, for these purposes AAM, ASM models are used.
As well, annotating images is a step to train a model, for that you may use a lot of universal annotated databases, available on internet, whereas your test images don't need to be annotated

Feature detection in profile face images

I am using opencv 2.4.2 and c++. I am trying to detect the eyes,nose and mouth of a profile face using haarcascade xml files.The eyes are most of the time detected correctly using haarcascade_mcs_righteye and haarcascade_mcs_lefteye. However,the nose and mouth xml are mostly failures with profile faces[as shown below]. I understand that those were made for frontal face,but is there any other "not-so-complicated" open source method which I can use to detect the tip of the nose and corner of mouth in profile images?Basically,I will need their coordinates,but first I will need to detect them. Anybody please?
Recently, Zhu and Ramanan CVPR 2012 had intoduced Face detection, pose estimation and landmark localization, this is by far the best I've seen, OpenCV Is Great By All means, but it's not state of the art for all applications out there nowadays.
I hope this helps

Detect and extract face from an image

I have been trying to do the following -
When a user uploads an Image in my web app, I'd like to detect his/her face in it and extract face (from forehead to chin and cheek to cheek) from it.
I tried OpenCV/C++ face detection using Haar Cascade but problem with it is that it gives a probability of where the face would be because of which either background of image comes inside the ROI or even the complete face doesn't come in the ROI.
I also want to detect eye inside the face and while using the above technique, the eye detection isn't that accurate.
I've read up on a new technique called Active Appearance Model (AAM). The blogs where I read up about this show that this is exactly what I want but I am lost on how to implement this.
My queries are -
Is using AAM a good idea for face detection and face feature detection.
Are there any other techniques for doing the same.
Any help on any of these is much appreciated.
Thanks !
As you noticed OpenCV's implementation of face detection is not state-of-the-art. It is a very good and robust implementation but you can do better.
Recently, Zhu and Ramanan (CVPR 2012) had intoduced Face detection, pose estimation and landmark localization in the wild which is considered to be one of the leading algorithms for face detection in recent years.
Their algorithm is capable of detecting faces both frontal and profile views AND identifying keypoints on the detected face such as eyes nose and mouth.
The authors were kind enough to publish their code along with learned models, it is a Matlab implementation but the main computations are done in C++, so it should not be too difficult to make a standalone C++ implementation of thier method.

Facial Feature Points Detection using OpenCV

I want to detect the points on a face as shown in the picture
I am using OpenCV CascadeClassifier::detectMultiScale.
I am using the haarcascade_frontalface_alt, haarcascade_eye, haarcascade_mcs_mouth xml files.
I am satisfied with the face detection but not with the facial feature points detection.
I want the feature points detection to work for the images upto a distance of 8 feet.
I am looking for more accuracy and robustness wrt pose(15 degrees) and opening of mouth, without compromising speed.
I am looking for speed of 25fps on an i5 processor.
Can anyone suggest/refer me any libraries/open source codes for my problem.
C++ platform.
Try Flandmarks http://cmp.felk.cvut.cz/~uricamic/flandmark/
It extracts 7 feature points but you will not be able to get the feature points for upperlip and the lower lip.
You can try using an ASM mesh to fit the face. There are several implementations that use ASM/AAM.
https://code.google.com/p/asmlib-opencv/ is an open source library which has built in dataset for face images. Do look into it.
Cheers