# Augmented Reality using a Neural Network

AR using SOM

This is the project that I have worked on for senior seminar at Ripon College. It is a simple augmented reality system using a neural network inspired by the biological vision system. It uses

1. Webcam as a visual sensor
2. OpenCV for feature detection and extraction,
3. A self-organizing map (SOM) for picture recognition, and
4. Microsoft WPF 3D for 3D rendering

For image recognition, the global representation of images are used as image features. The SOM, also known as Kohonen Map, is a two-layer artificial neural network comprising the input layer and the competition layer that is a grid of neurons. Each neuron is represented by a vector that has the same dimension as an input feature vector. During the training, the SOM groups the similar pictures together in the competition layer and chooses a neuron for each group.

Paper

Source Code

Prezi Slides

# Lazy Day, Busy Day Algorithm

```
void lazyDay(){
while(! TimeToSleep){
eat();
watchTV();
listenMusic(Psych mood);
nap();
surfInternet();
trySomeTweaksOnUbuntu();
}
sleep();
}

void busyDay(bool haveTest, Queue jobs){
if(haveTest()){
study();
}

Job current;
while(!jobs.empty()){
current = jobs.dequeue();
if(current == "class"){
try{
goToClass();
}
catch(NotFeelingWellException e){
writeLeaveLetter();
}
}
else if(current == "work"){
try{
goToWork();
}
catch(NotFeelingWellException e){
findSubstitute();
}
}
}
}

```

# Algorithm for Checking Solvability of 15-Tile Puzzle

``` bool isSolvable(string &str) { int pos = str.find('*'); //find the index of * in the string //step 1: move black to lower right corner for (; pos%4 < 3; pos++) str[pos] = str[pos+1]; //move blank right for (; pos < 15; pos+=4) str[pos] = str[pos+4]; //move blank down //step 2: count inversions int inv = 0; for (int i=0; i < 14; i++) for (int j=i+1; j str[j]) inv++; //step 3: check pivot if (inv%2==0) return true; //if even, solvable else return false; //otherwise, unsolvable } ```

# Algorithm for Making Friends (From Big Bang Theory)

``` placePhoneCall(); if(!isHome()) { leaveMessage(); waitForCallBack(); } bool response; if(askYesNo("Would you like to share a meal?")) { response = askYesNo("Dine Together?"); } else if(askYesNo("Do you enjoy a hot beverage?")) { string beverage = getBeverage(); switch(beverage) { case "tea": makeBeverage("tea"); break; case "coffee": makeBeverage("coffee"); break; case "cocoa": makeBeverage("cocoa"); break; } } else { do { string interest = ask("Recreational activities? Tell me one of your interest."); }while(interest != myInterest); Activity a1 = new Activity(interest); a1.doTogether(); partake(); } begin(FRIENDSHIP); ```