Skip to content

Commit

Permalink
hacky fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nchiappari committed Apr 23, 2017
1 parent e1531c3 commit 0d2ba84
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 16 deletions.
21 changes: 18 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from flask_socketio import SocketIO, emit
import sys
import time
import urllib2
import requests, json
import os
sys.path.append("/scripts/")
app = Flask(__name__)
Expand All @@ -28,16 +30,29 @@ def getData(filename):

@app.route('/dashboard/', methods=['GET'])
def dashboard():
if "command" in request.args:
command = request.args['command']
sendCommand(command)
print "IN DASHBOARD"
if "command" in request.args or "api" in request.args:
print "COMMAND TRUE"
if "api" in request.args:
print "API TRUE"
sendCommand("image_match_"+request.args['person'])
return "success"
else:
print "API FALSE"
command = request.args['command']
sendCommand(command)
return render_template('dashboard.html')

@socketio.on('channel-a')
def sendCommand(message):
print "SENDING COMMAND"
socketio.emit("channel-a", message)

def sendCommandAPI(person, output):
print "API - SENDING COMMAND"
# message = json.dumps({"command":"new_bank", "data":(person, output + person + "Banked.jpg")})
r = requests.get("http://127.0.0.1:5000/dashboard?api=True&person="+person)

if __name__ == '__main__':
app.debug = True
socketio.run(app, port=5000)
Expand Down
2 changes: 1 addition & 1 deletion scripts/imageProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def processImage():
banked = still.crop((topLeftX, topLeftY, topLeftX + width, topLeftY + height))
#scaled = banked.thumbnail(100, Image.ANTIALIAS)
banked.save(output + person + "Banked.jpg")
app.sendCommand(json.loads(json.dumps({"command":"new_bank", "data":(person, output + person + "Banked.jpg")})))
app.sendCommandAPI(person, output)
print data
print "Recognized " + person + ". Hi " + person + "!"
except Exception as e:
Expand Down
Binary file modified static/data/facebank/AndrewBanked.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/data/facebank/MarkBanked.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/data/facebank/NickBanked.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/data/facebank/PaulBanked.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions static/js/notificationEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ function handleNotification(message) {
recMarkerList = []
} else if (message == "removeFacebank") {
wipeFacebank();
} else {// is a facedata from message!
jsonstuff = JSON.parse(message);
addToFacebank(jsonstuff["data"][0], "", jsonstuff["data"][1])
} else if (message.substring(0, 12) == "image_match_") {// is a facedata from message!
console.log("ELSE CASE: " + message)
// jsonstuff = JSON.parse(message);
// addToFacebank(jsonstuff["data"][0], "", jsonstuff["data"][1])
addToFacebank(message.substring(12))
displayFacebank()
}
}
Expand All @@ -72,7 +74,7 @@ function deactivateNotif(id) {
document.getElementById(id).innerHTML = "";
}

/*
/*
* A notification is a
* {
* title:<string>,
Expand All @@ -84,25 +86,27 @@ function deactivateNotif(id) {
/*
* Adds/updates a person to the faceBank
*/
function addToFacebank(name, descripion, url) {
function addToFacebank(name) {
var url = "../data/facebank/" + name + "Banked.jpg";
description = "";
switch (name) {
case "Andrew":
descripion = "Northeastern Student"
description = "Northeastern Student"
break;
case "Mark":
descripion = "Northeastern Student"
description = "Northeastern Student"
break;
case "Paul":
descripion = "Northeastern Student"
description = "Northeastern Student"
break;
case "Nick":
descripion = "Northeastern Student"
description = "Northeastern Student"
break;
case "Meg":
descripion = "MIT Design student and Mentor"
description = "MIT Design student and Mentor"
break;
case "Federico":
descripion = "Director of MIT Media Labs"
description = "Director of MIT Media Labs"
break;
default:
descripion = "New Challenger!"
Expand Down Expand Up @@ -157,4 +161,4 @@ function viewNotif(notifModel) {
console.log(notifView)
return notifView

}
}
Binary file modified static/resources/latestStill.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d2ba84

Please sign in to comment.