How many people in a FaceBook Profile Picture? - opencv

So I want to count how many people appear in a facebook profile picture.
Typically there are 0-2 people (sometimes there are 4-5+ but that's more rare).
A sample dataset (and a few tries using python) can be found here:
https://github.com/yoniker/FaceDetect
I've tried different methods, none of them give reasonable results (all of those methods are wrong most of the time),I've tried the following:
-Face detection- http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html
It usually doesn't find anyone (that happens at around 75% of the pictures)- and I have tried different Haar filters and parameters.
-Pedestrian Detection http://www.pyimagesearch.com/2015/11/09/pedestrian-detection-opencv/
Again it doesn't find people most of the time.
OpenFace:Probably this face recognition algo doesn't truly help with face detection (see https://groups.google.com/forum/#!topic/cmu-openface/X6erXKckk0Q).
And finally I've looked at different StackOverflow questions such as
Count the number of people in the video but none of them are relevant!
I've tried for half a day now- so help will be super appreciated!!

For me, dlib has given better results than using OpenCV's haar face detector. It has python bindings too. You can find quick-start code to do face detection here.
It would be possible to help better if you post an Image in which faces are not detected properly.
Having said that, to improve face detection apart from using dlib, you can experiment with these ideas:
Use histogram equalisation(equalizeHist on opencv) on gray scale image before passing it to face detector. (i.e preprocess your images)
If faces are tilted to left or right, more often face detection fails. To solve this rotate the images in steps of 5 degrees upto 30 degrees and apply face detection. At each rotation you might detect new faces.
Most face detectors which are not using deep learning detect mostly frontal faces. Not much could be done about this apart from using deep learning or train your own side profile face detector using HOG or HAAR features.
Hope this helps you to improve your face detection.

There's always the cascade classifier in OpenCV for all your face detection needs. If you could feed it with some nice features it would give you all the results.

Related

Different ways of detecting smile

I would like to know more about different ways of detecting smile on image. As far as I know, there are many libraries that are allowing to detect face and smile. The ones that I've tried are:
FaceSDK from Luxand
OpenCV
OpenIMAJ
Instead of just using them, I'm curious about how they are working. I know that OpenCV and OpenIMAJ are working based on Haar classifiers. I don't really follow, how FaceSDK is doing face and smile detection though.
I can imagine, that you can get two different ways of smile detection:
Perform fully emotional detection. You can find eyes, nose, mouth and other features on face and then compute emotion based on those informations. If you get "happy" emotion, you can assume, that there is smile (or something like that, just finding mouth and checking curve on lower lip?).
Similiar to Haar cascades, search image and try to find object that is similiar to the one that you are searching (having many negative and positive samples). This one seems to be faster, but less trustworthy if not used with some "helpers".
Is there any other way? Do you guys have some articles on one of those ways?

Detect symbols written on a whiteboard using OpenCV

I'm trying to detect shapes written on a whiteboard with a black/blue/red/green marker. The shapes can be circles, rectangles or triangles. The image can be found at the bottom of this post.
I'm using OpenCV as the framework for the image recognition.
My first task is to research and list the different strategies that could be used for the detection. So far I have found the following:
1) Grayscale, Blur, Canny Edge, Contour detection, and then some logic to determine if the contours detected are shapes?
2) Haar training with different features for shapes
3) SVM classification
4) Grayscale, Blur, Canny Edge, Hough transformation and some sort of color segmentation?
Are there any other strategies that I have missed? Any newer articles or tested approaches? How would you do it?
One of the test pictures: https://drive.google.com/file/d/0B6Fm7aj1SzBlZWJFZm04czlmWWc/view?usp=sharing
UPDATE:
The first strategy seems to work the best, but is far from perfect. Issues arise when boxes are not closed, or when the whiteboard has a lot of noise. Haar training does not seems very effective because of the simple shapes to detect without many specific features. I have not tried CNN yet, but it seems most appropriate to image classification, and not so much to detect shapes in a larger image (but I'm not sure)
I think that the first option should work. You can use fourier descriptors in order to classify the segmented shapes.
http://www.isy.liu.se/cvl/edu/TSBB08/lectures/DBgrkX1.pdf
Also, maybe you can find something useful here:
http://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/
If you want to try a more challenging but modern approach, consider deep learning approach (I would start with CNN). There are many implementations available on the internet. Although it is probably an overkill for this specific project, it might help you in the future...

OpenCV: Refine Cascade Face Detection

I'm making system for emotion detection on Android mobile phone. I'm using OpenCV's Cascades (LBP's or Haars) to find face, eyes, mouth areas etc. What I have observed till now that accuracy isn't stable. There are situations where I can't find eye or I have "additional faces" in the background due to very slight change of light. What I wanted to ask is:
1) Is Haar Cascade more Accurate than LBP?
2) Is there any good method for increasing accuracy of detection? Like find face/eyes etc on binarized image, or use some edge detection filter, saturation, anything else?
you can try Microsoft API for face emotion detection ..i am trying in my project so..result is best..try this link
https://www.microsoft.com/cognitive-services/en-us/emotion-api
sometimes HAAR or LBP will not get a good enough result for a face detection system. if you want to get more good acc. i think you can try to using STASM
it base on opencv and using Haar to detect face and landmark. something others you can also try YOLO Face detection
if you want to build your own face detection system just base on Haar or LBP and make them get a good result, maybe you will need to using the LBP to find out the face faster and train a CNN model to get the last good result, it can make your system to detect faces in realtime. as i know, the SEETAFACE is using this way to make a realtime faces detection.

Free Face Detection Algorithm for Video

I'm working on an application which needs to detect the location of a face in a video stream, using a web cam placed at desk height (and slightly off to the side of the user).
I've already implemented a version of OpenCV (using their Haar detection) and it works ok... the problem is that it tends to lose the position of the face if the user turns their head to the side (or looks up).
Since the webcam is sitting on the desk, it is tilted up at a 30 degree angle. The OpenCV detection algorithm is trained using fully frontal images, but not up-angle images like the ones I'm using. I know OpenCV also has a profile Haar file that can be used.. but from my research it seems that the results are quite mixed on profile detection. In addition, I don't really have control over the background or lighting of the image... so this sometimes also effects the efficacy of the OpenCV detection algorithm.
So, I guess what I'm asking is... are there other face detection algorithms (that are hopefully free, as this is part of my university research) that are better for detecting faces for this type of setup? It seems like some of the built-in webcams (for Macs and PCs) actually have fairly robust algorithms for detecting faces (and then overlaying cheesy cartoon images over the faces)... but they seem to work well regardless of background or lighting. Do you have any recommendations?
Thanks.
For research purposes, you can use the Haar cascades in OpenCV, things are different if you want to go commercial (in which case you need to consider LBP cascades instead). Just be sure to quote the Viola-Jones paper in your references.
To improve the results of face detection, you have several paths:
individual image detection: you can send rotated images to a frontal cascade to account for some variability without training your own cascade
individual image detection but more work) : train your own cascade in operating conditions closer to the ones of your app
stability in video streams (as in webcams & co.) : this is achieved by adding a layer of tracking around the face detection. Depending on your knowledge about this topic, you can use your own filter, have fun with OpenCV's particle or Kalman filter, implement a simple first or second order low pass filter on the face position or a PID tracker on the detected face...
Any of these tracking filters will enhance a lot your results when processing video streams.
Use CLM-framework for accurate realtime face detection and face landmark detection.
Example of the system in action: http://youtu.be/V7rV0uy7heQ
You may find it useful.

fingertip detection and tracking

i am working on a project detecting and tracking fingers. Though i find there is quiet a lot resource on this task, i haven't found a effective one yet :(.
So far i have thought of methods to detect hands as follow:
Haar training. But firstly we don't have a trained set(xml) as that in the face detection. Secondly, if we do the training ourselves, we don't have enough samples (i am still a college student)
skin color detection in HSV space. I have tried this one but the result has a lot of noises so cannot helps me continue the further detection on fingertip.
3.use Handvu. But i have heart that this lib is hard to set up and used in windows...
So in a word, can anyone give me any suggestions on how to detect hands effectively? (After that i may consider about detecting fingertips..)
Thanks!!
Here is a pretty in-depth paper on finger segmentation using Zernike moments. Here is a good paper on using Zernike moments for image recognition as a basis for the first paper.
Can you explain more about your experimental setup? Are you trying to track fingers against a cluttered background, or a plain cardboard sheet?
Haar like features perform very well for face recognition (the Viola Jones paper being a classic example) however I would not recommend them for your task. Although they can be computed fast using the integral image, they work well using a CASCADED Adaboost classification framework.
For skin colour detection, it depends on your setup. As a first step you could try doing background subtraction: simply learn the distribution (histogram) of pixels for foreground (ie. the hand) and the background and use these to do image segmentation.
I don't know what Handvu is
Zernike moments are also very good shape descriptors that are rotation invariant and can be made to be both scale and translation invariant.
I hope this helps!

Resources