OpenCV and Normal Bayes Classifier with custom features - c++

I'm doing a project right now for emotion recognition. What I'm doing is to detect key points in the face using an ASM model, that way I can detect points of the mouth, eyes, etc. What I want to do, is to manually define some features from these points and use them to train a Normal Bayes Classifier with OpenCV.
It's possible to do something like this with the OpenCV implementation instead using a feature extractor algorithm? Can I just create Mat objects with the features I defined? and add them to the bowTrainer? if possible, how?
I'm following this tutorial:
http://www.app-solut.com/blog/2011/07/using-the-normal-bayes-classifier-for-image-categorization-in-opencv/
thanks!!

Related

Real-time object tracking in OpenCV

I have written an object classification program using BoW clustering and SVM classification algorithms. The program runs successfully. Now that I can classify the objects, I want to track them in real time by drawing a bounding rectangle/circle around them. I have researched and came with the following ideas.
1) Use homography by using the train set images from the train data directory. But the problem with this approach is, the train image should be exactly same as the test image. Since I'm not detecting specific objects, the test images are closely related to the train images but not essentially an exact match. In homography we find a known object in a test scene. Please correct me if I am wrong about homography.
2) Use feature tracking. Im planning to extract the features computed by SIFT in the test images which are similar to the train images and then track them by drawing a bounding rectangle/circle. But the issue here is how do I know which features are from the object and which features are from the environment? Is there any member function in SVM class which can return the key points or region of interest used to classify the object?
Thank you

How to extract LBP features from a hand contour using opencv c++

I am currently working on a hand recognition system. I have been able to detect the hand and draw a contour for it. Now, I have to extract features from the hand region. What is the best feature extraction method that i can use?
I was thinking to use Local Binary Pattern, but since i am new to computer vision i don't know how to use it.
Perhaps you must look at histogram of gradients (HOG), which can be considered as a more general version of LBP. You can have multiple images of hands; by extracting HOG features from each image and using an SVM or neural network classifier, you can learn a statistical model of hand poses. This will help in recognizing an unseen hand. Look also at the current literature on deep learning.
A C++ implementation of HOG is available from vlfeat library [1], which can be called from OpenCV. HOG can be computer from OpenCV also [2].
[1] http://www.vlfeat.org/overview/hog.html
[2] http://goo.gl/8jTetR

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

Object Annotation in images with OpenCV

I am trying to develop an automatic(or semi-automatic) image annotator for my final year project with OpenCV. I have been studying many OpenCV resources and have come across cascade classification for training and detection purposes. I understood that part, and also tried the Face Detection tutorial provided with OpenCV. So, now I know how to train and detect objects.
However, I still cannot understand how can I annotate objects present in the image?
For example, the system will show that this is an object, but I want the system to show that it is a ball. How can i accomplish that?
Thanks in advance.
One binary classificator (detector) can separate objects by two classes:
positive - the object type classifier was trained for,
and negative - all others.
If you need detect several distinguished classes you should use one detector for each class, or you can train multiclass classifier ("one vs all" type of classifiers for example), but it usually works slower and with less accuracy (because detector better search for similar objects). You can also take a look at convolutional networks (by Yann LeCun).
This is a very hard task. I suggest simplifying it by using latent SVM detector and limiting yourself to the models it supplies:
http://docs.opencv.org/modules/objdetect/doc/latent_svm.html

What are good filters to use for feature generation with boosting

I'm trying to implement something like the method given here:
research.microsoft.com/en-us/um/people/viola/Pubs/MIT/tieuIJCV.pdf
Images "similar" to a query image are retrieved from a database by using AdaBoost on features generated from the images by repeatedly filtering and downsizing them.
The paper shows images of the filters it uses for detecting basic images features (vertical lines, diagonals, corners, etc.) and states that these are separable but doesn't say exactly what the matrices are for these features. Does anyone know which matrices were used for the filters, or in general what are good choices of filters for detecting simple geometric shapes for use with boosting.
Thanks
They seem to be similar to Haar features that's described by the same author in his first boosting paper.
click here
I've only used the haar features when implemented the AdaBoost in class. In general I guess you could make your own haar filters, some simple examples can be seen here.