Can vision.cascadeObjectDetector calculate HOG, LBP features given a cascade.xml? - matlab

I have created a cascade.xml for detecting face images using the opencv_traincascade utility. I am using LBP or HOG feature based cascades since they are much faster. And I do all my testing on Matlab using vision.cascadeObjectDetector. But I am unsure if Matlab is capable of understanding and calculating LBP/ HOG features for a given cascade.xml file.
Is this the correct approach for testing a cascade detector? If not, what platform should I be using for testing?

Yes, vision.cascadeObjectDetector supports LBP and HOG, as well as Haar features, as of version R2013a.
Furthermore you can now train your detector using trainCascadeObjectDetector function, which is easier to use than opencv_traincascade. There is also a trainingImageLabeler app, which gives you a nice GUI to label objects of interest in your images.

Related

Face detection (viola-jones) in matlab

So I found the cascade object detector in matlab that use the Viola-Jones algorithm to detect faces. Very easy to use, and works great!
But got a few questions.
The viola-jones method got four stages:
Haar Feature Selection
Creating an Integral Image
Adaboost Training
Cascading Classifiers
In matlab I can use FrontalFace(CART) and FrontalFace(LBP). These are Trained cascade classification model, so they will be part of stage 4 right?
But what is the difference between stage 1 and stage 4 if I use FrontalFace(CART)? Both use Haaar features it says.
Can we say that FrontalFace(CART) and FrontalFace(LBP) are two different ways of detecting faces? Can I compare those two against each other to see which one is better?
Or should I find another method to compare against the viola-jones?
Are there other face detection methods that are easy to implement in matlab?
Found some on the internet (using skin color etc), but Matlab is quite new to me. So I felt that those codes where abit to complicated for me.
The main difference is that FrontalFace(CART) and FrontalFace(LBP) have been trained on different data sets. Also, from the name, I am guessing that FrontalFace(LBP) uses LBP feaures instead of Haar.
The original Viola-Jones algorithm used the Haar features. However, it has later been extended to use other types of features. vision.CascadeObjectDetector supports Haar, LBP, and HOG features.
To compare which one is better, you would need some ground truth images, which are images with faces labeled by hand. I am sure you can find a benchmark data set on the web. Alternatively, you can label you own images using trainingImageLabeler app.
Also, if you are not happy with the accuracy of the classifiers that come with vision.CascadeObjectDetctor, you can train your own using the trainCascadeObjectDetector function.

Why is SIFT not available in Matlab?

SIFT is an important and useful algorithm in computer vision but it seems that it is not part of Matlab or any of its toolboxes.
Why ? Does Matlab offer something better or equivalent ?
MATLAB has SURF available as part of the Computer Vision Toolbox but not SIFT: http://www.mathworks.com/help/vision/ref/surfpoints-class.html. However, both algorithms are pretty much the same with some minor (but crucial) differences, such as using integral images and a fast Hessian detector. I won't go into those differences in any further detail, but you can certainly read up on the work here: http://www.vision.ee.ethz.ch/~surf/eccv06.pdf. As to the reason why MathWorks decided to use SURF instead of SIFT... it could be any reason really. AFAIK, there is no official reason why one was chosen over the other as they are both subject to being patented.
However, if you want to use SIFT within MATLAB, one suggestion I have is to use the VLFeat toolbox where a C and MATLAB implementation of the keypoint, detection and matching framework has been made available and is open source. It also has a variety of other nice computer vision algorithms implemented, but VLFeat is one of the libraries that I know of that manages to compute SIFT as accurately as the original patented algorithm.
If you're dead set on using SIFT, check VLFeat out! Specifically, check out the official VLFeat tutorial on SIFT using the MATLAB wrappers: http://www.vlfeat.org/overview/sift.html

How to use Mikolajczyk's evaluation framework for feature detectors/descriptors?

I'm trying the assess the correctness of my SURF descriptor implementation with the de facto standard framework by Mikolajczyk et. al. I'm using OpenCV to detect and describe SURF features, and use the same feature positions as input to my descriptor implementation.
To evaluate descriptor performance, the framework requires to evaluate detector repeatability first. Unfortunately, the repeatability test expects a list of feature positions along with ellipse parameters defining the size and orientation of an image region around each feature. However, OpenCV's SURF detector only provides feature position, scale and orientation.
The related paper proposes to compute those ellipse parameters iteratively from the eigenvalues of the second moment matrix. Is this the only way? As far as I can see, this would require some fiddling with OpenCV. Is there no way to compute those ellipse parameters afterwards (e.g. in Matlab) from the feature list and the input image?
Has anyone ever worked with this framework and could assist me with some insights or pointers?
You can use the file evaluation.cpp from OpenCV. Is in the directory OpenCV/modules/features2d/src. In this file you could use the class "EllipticKeyPoint", this class has one function to convert "KeyPoint" to "ElipticKeyPoint"
Honestly I never worked with this framework., but I think you should see this paper about a performance evaluation of local descriptors.

SIFT and SURF feature extraction Implementation using MATLAB

I am doing an ancient coins recognition system using matlab. What I have done so far is:
convert to grayscale
remove noise using Gaussian filter
contrast enhancement
edge detection using canny edge detector.
Now I want to extract feature for classification. Features I thought to select are roundness, area, colour, SIFT and SURF. My problem is how I can apply SIFT and SURF algorithms to my project. I couldn't find built-in functions for both.
You can find SIFT as a C implementation with MATLAB bindings at: http://www.vlfeat.org/index.html
For anyone else coming across this thread as I did, I noticed the implementation at http://www.vlfeat.org/index.html was far more than I required and also fairly hard to adjust to my code.
The following link; http://robwhess.github.io/opensift/, has an implementation of just the SIFT algorithm accompanied with an example executable, with the source code available (unlike http://www.cs.ubc.ca/~lowe/keypoints/ which only has the sift binary executable).
you can find a matlab implementation of SIFT features here: http://www.cs.ubc.ca/~lowe/keypoints/

Feature Selection methods in MATLAB?

I am trying to do some text classification with SVMs in MATLAB and really would to know if MATLAB has any methods for feature selection(Chi Sq.,MI,....), For the reason that I wan to try various methods and keeping the best method, I don't have time to implement all of them. That's why I am looking for such methods in MATLAB.Does any one know?
svmtrain
MATLAB has other utilities for classification like cluster analysis, random forests, etc.
If you don't have the required toolbox for svmtrain, I recommend LIBSVM. It's free and I've used it a lot with good results.
The Statistics Toolbox has sequentialfs. See also the documentation on feature selection.
A similar approach is dimensionality reduction. In MATLAB you can easily perform PCA or Factor analysis.
Alternatively you can take a wrapper approach to feature selection. You would search through the space of features by taking a subset of features each time, and evaluating that subset using any classification algorithm you decide (LDA, Decision tree, SVM, ..). You can do this as an exhaustively or using some kind of heuristic to guide the search (greedy, GA, SA, ..)
If you have access to the Bioinformatics Toolbox, it has a randfeatures function that does a similar thing. There's even a couple of cool demos of actual use cases.
May be this might help:
There are two ways of selecting the features in the classification:
Using fselect.py from libsvm tool directory (http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#feature_selection_tool)
Using sequentialfs from statistics toolbox.
I would recommend using fselect.py as it provides more options - like automatic grid search for optimum parameters (using grid.py). It also provides an F-score based on the discrimination ability of the features (see http://www.csie.ntu.edu.tw/~cjlin/papers/features.pdf for details of F-score).
Since fselect.py is written in python, either you can use python interface or as I prefer, use matlab to perform a system call to python:
system('python fselect.py <training file name>')
Its important that you have python installed, libsvm compiled (and you are in the tools directory of libsvm which has grid.py and other files).
It is necessary to have the training file in libsvm format (sparse format). You can do that by using sparse function in matlab and then libsvmwrite.
xtrain_sparse = sparse(xtrain)
libsvmwrite('filename.txt',ytrain,xtrain_sparse)
Hope this helps.
For sequentialfs with libsvm, you can see this post:
Features selection with sequentialfs with libsvm