• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    C++
  • Created over 13 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Bag of Visual Words food classifier for Media Lab's FoodCam
Foodcam Classifier
==================
A Bag Of Visual Words classifier for MIT Media Lab's Foodcam.
Built using OpenCV 2.3

Implementing BOVW method: Visual Categorization with Bags of Keypoints by Gabriella Csurka, Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004.
Using Opponent-Color SURF features (192 floats): Van de Sande et al., CGIV 2008 Color Descriptors for Object Category Recognition. (they used SIFT)
Radial Basis Function SVMs for classification.

This is basically a primer to BOVW methods using OpenCV, which are dead simple.
I tweaked the basic method by:
	- using background subtraction (since these are pictures from a still camera).
	- using a sliding window. This enables better multi-class decisions, and actually paves the path to image segmentation. 


Compiling
---------
Basically, just run:
cmake -D CMAKE_CXX_FLAGS=-fopenmp . ; make -j4

CMake should take you all the way, but I also have an .xcodeproj/ included.

Working it
----------
Get the dataset:
http://www.media.mit.edu/~roys/shared/foodcamimages.zip
Assume the dataset is now in the same directory, under foodcamimages/.


Manually classify training and test:
./manual-classifier foodcamimages/TRAIN/ train.txt
./manual-classifier foodcamimages/TEST/ test.txt
(or you can use my manual classification included... lazy)


Create a background image:
./make-test-background


Build the vocabulary: (this will take a very very long time, KMeans on 1.3Million 192-long vectors to find 1000 cluster-centers...)
./build-vocabulary

(you may also like to use ./kmeans-trainer, if you break the operation before KMeans finished, which may take more than 10 hours)


Train the classifiers:
./train-bovw vocabulary_color_1000.yml with_color

(you may also make use of './train-SVM-alone', if you just wanna tweak the SVM parameters)


Test your work:
./test-classifiers 
(it will output a whole lotta things, and then the confusion matrix in neighbors list form)


Put it to work!:
./foodcam-predict some_640x480_image_of_food.png
Will output either one or two found classes of food, based on how close the prediction is.


Notes
-----
Some of the computation is sped up on multi-core machines by using OpenMP, so it's recommended to use it.


Results
-------
This is the confusion matrix:
classified ->	cookies	indian	italian	pizza	veggie+fruit	sandwiches
cookies		56.3%	0.0%	4.3%	0.0%	13.5%		15.4%
indian		0.0%	71.4%	6.4%	3.8%	3.4%		7.7%
italian		0.0%	0.0%	63.8%	0.0%	14.6%		0.0%
pizza		6.3%	0.0%	12.8%	92.3%	5.6%		15.4%
veggie+fruit	0.0%	0.0%	2.1%	3.8%	49.4%		0.0%
sandwiches	25.0%	14.3%	6.4%	0.0%	7.9%		61.5%

Quick scan shows that it can classify Pizzas pretty good!
The downfall are the veggie+fruit class, with less than 50% accuracy.
Rest are lukewarm, but this can probably be attribued to the very small training set.

More Repositories

1

obs-backgroundremoval

An OBS plugin for removing background in portrait images (video), making it easy to replace the background when screen recording.
CMake
1,730
star
2

SfM-Toy-Library

A toy library for Structure from Motion using OpenCV
C++
529
star
3

HeadPosePnP

Head pose estimation using PnP
C++
128
star
4

CurveMatching

Matching 2D curves in OpenCV
CMake
75
star
5

CurveDeformationMLS

2D Shape/Curve deformation using Moving Least Sqaures
C++
51
star
6

HHParticleFilter

Heap&Hogg's hand curve tracking particle filter [OpenCV,c++]
C++
47
star
7

HeadReplacement

C++
44
star
8

OpenHPE

A hand pose estimator using model fitting by finding minimal energy, using OpenCV and tnc.c library.
C
42
star
9

ofxNaturalFeatureTracker

A natural features image tracker, detector and Augmented Reality engine
C++
18
star
10

morethantechnical

Automatically exported from code.google.com/p/morethantechnical
C++
17
star
11

ATmega88-bootloader

A bootloader for ATmega88 to use with Arduino software
C
14
star
12

obs-localvocal

OBS plugin for local speech and text AI processing routines
CMake
9
star
13

KinectPuppeteering

Animating 3D Meshes using the Kinect
C++
8
star
14

obs-cleanstream

CleanStream is an OBS plugin that uses AI to clean live audio streams from unwanted words and utterances
C++
6
star
15

wikilosophy

Tools for parsing wikipedia articles' linkage network
Python
4
star
16

ExercisesCollection

A collection of coding exercises
C++
4
star
17

HeadFollower

The source code for the PoCoMo project
Java
4
star
18

Docker4MLTutorial

A hands on tutorial on Docker and AWS Lambda for Machine Learning applications.
Jupyter Notebook
3
star
19

telegram-serverless-ts-bot-tutorial

Telegram Typescript Serverless Bot Tutorial
TypeScript
3
star
20

KinectPlugin

A browser plugin for Kinect
C++
3
star
21

audiograma

An open source Audiogram maker - audio for your eyes!
HTML
2
star
22

KinectAtHomeExtension

Browser extension part of the Kinect@Home project
C++
2
star
23

obs-plugin-workshop

A set of tutorials on authoring OBS plugins from the ground up
CMake
1
star
24

TabParser

A textual guitar tablature parser and convert tools
Java
1
star