Approach for implementation, will post the code once its completely done
Collecting the training set
capture all the images on which you want to train and store them in your SDcard/external directory in android and have a xml/txt files which contains all the names of the images you have captured.
Feature extraction
capture the frames from camera ans pass it to a Mat object from there you can extract the features to get the query descriptor set. For extracting the features from the training set, you read the file from the storage location get the list of images in the file and pass all the images stored into a vector of Mat objects and extract the feature points to get training descriptor set.
Descriptor matching
same goes here, you need to pass query descriptor and vector of training descriptor and you get the output in terms of vector of Dmatches after obtaining the result of correct match you can draw matches between the images or use homography to draw a rectangle on the recognised object.
Skeleton code
static void detectKeypoints( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
const vector<Mat>& trainImages, vector<vector<KeyPoint> >& trainKeypoints,
Ptr<FeatureDetector>& featureDetector )
{
featureDetector->detect( queryImage, queryKeypoints );
featureDetector->detect( trainImages, trainKeypoints );
}
static void computeDescriptors( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, Mat& queryDescriptors,
const vector<Mat>& trainImages, vector<vector<KeyPoint> >& trainKeypoints, vector<Mat>& trainDescriptors,
Ptr<DescriptorExtractor>& descriptorExtractor )
{
descriptorExtractor->compute( queryImage, queryKeypoints, queryDescriptors );
descriptorExtractor->compute( trainImages, trainKeypoints, trainDescriptors );
}
static void matchDescriptors( const Mat& queryDescriptors, const vector<Mat>& trainDescriptors,
vector<DMatch>& matches, Ptr<DescriptorMatcher>& descriptorMatcher )
{
descriptorMatcher->add( trainDescriptors );
descriptorMatcher->train();
descriptorMatcher->match( queryDescriptors, matches );
CV_Assert( queryDescriptors.rows == (int)matches.size() || matches.empty() );
}