This code is implementation of the paper : Suriya Singh, Shushman Choudhury, Kumar Vishal and C.V. Jawahar. "Currency Recognition on Mobile Phones". Proceedings of the 22nd International Conference on Pattern Recognition, 24-28 Aug 2014, Stockholm, Sweden.
Project Page : http://researchweb.iiit.ac.in/~suriya.singh/Currency2014ICPR/Currency2014ICPR.html
Code contributors :
The code is divided into 2 parts
Training code - This code can be used to obtain necessary files for instance retrieval : (a) vocabulary and vocabulary size used (b) inverted index and size of each entry in inverted index (c) annotation for each training image and number of training images used (d) location and vocabulary assignment information for keypoints in each training image
Test code - This code perform (a) read files obtained from training step into memory. (b) predict labels of images.
(provided script assume JPEG image. For other type of image the user is required to properly modify the scripy 'run.sh' for training as well as test code.)
'directory conatining training images' should have directory structure base_directory
How to run the code - $ sh run.sh 'path to directory conatining training images'
e.g. $ sh run.sh /home/bond/currency_dataset/train/
Once the code finishes, it create a directory 'currency_train_output' with following files and directory 'currency_train_output'
NOTE - the script is used for predicting the labels in batch.
'directory conatining test images' should have directory structure base_directory
How to run the code - $ sh run.sh 'path to directory containing training output' 'path to directory conatining test images'
e.g. $ sh run.sh ../currency_train/currency_train_output/ /home/bond/currency_dataset/test_images/
The code output label for each test image, time taken to detect keypoints, assign vocabulary, do inverted index search , perform geometric verification as well as total time. Once, every image has been processed, it output the classification accuracy.
NOTE - In order to predict label one by onem the user need to make changes in test code. Call testCurrency() function with path to image as argument. Compile and run to get the predicted label.
To manually compile the train code
$ g++ pkg-config --cflags --libs opencv
currency.cpp -o currency-train -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect -lopencv_nonfree -lopencv_features2d -lopencv_flann;
To manually run the train code, the user has to create classwise text files which contains list of training images. And run by using $ ./currency-train train_files/ $vocabSize $numImagesToTrain
where train_files/ is path to text files which contains list of training images.
To manually compile the test code
g++ pkg-config --cflags --libs opencv
testCurrency.cpp -o currency-test -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect -lopencv_nonfree -lopencv_features2d -lopencv_flann -lopencv_calib3d;
To manually run the train code, the user has to create classwise text files which contains list of training images. And run by using $ ./currency-test PATH/dataFile.txt PATH/vocabulary.bin PATH/labels.txt PATH/indicesSize.txt PATH/allIndex.bin $topKValue PATH/keypoints/ train_files/
where train_files/ is path to text files which contains list of training images and PATH is path to 'currency_train_output' or path to directory containing training output.