diff --git a/locaudio/db.py b/locaudio/db.py index 6383385..53eb5a4 100644 --- a/locaudio/db.py +++ b/locaudio/db.py @@ -32,6 +32,7 @@ SAMPLE_R_REF = 1 SAMPLE_L_REF = 65 SAMPLE_NAME = "Cock" +SAMPLE_CLASS = "Chicken" # Table Names @@ -42,6 +43,10 @@ FINGERPRINT_PRIMARY_KEY = "name" +# Secondary Keys +FINGERPRINT_SECONDARY_KEY = "class" + + def create(conn): """ @@ -59,6 +64,10 @@ def create(conn): primary_key=FINGERPRINT_PRIMARY_KEY ).run(conn) + r.db(DB).table(FINGERPRINT_TABLE).index_create( + FINGERPRINT_SECONDARY_KEY + ).run(conn) + def init(): """ @@ -73,7 +82,13 @@ def init(): if not DB in r.db_list().run(conn): create(conn) f_print = fingerprint.get_fingerprint(SAMPLE_PATH) - insert_reference(SAMPLE_NAME, f_print, SAMPLE_R_REF, SAMPLE_L_REF) + insert_reference( + SAMPLE_NAME, + f_print, + SAMPLE_R_REF, + SAMPLE_L_REF, + SAMPLE_CLASS + ) return True else: return False @@ -144,7 +159,7 @@ def get_list_of_names(): return list(names) -def insert_reference(name, f_ref, r_ref, l_ref): +def insert_reference(name, f_ref, r_ref, l_ref, class_ref): """ Inserts a reference into the database @@ -166,7 +181,8 @@ def insert_reference(name, f_ref, r_ref, l_ref): "name": name, "fingerprint": f_ref, "distance": r_ref, - "spl": l_ref + "spl": l_ref, + "class": class_ref } ).run(conn) diff --git a/locaudio/detectionserver.py b/locaudio/detectionserver.py index 4c1842d..430aa1f 100644 --- a/locaudio/detectionserver.py +++ b/locaudio/detectionserver.py @@ -189,7 +189,8 @@ def get_post_upload(): request.form["sound_name"], fingerprint.get_fingerprint(file_path), float(request.form["r_ref"]), - float(request.form["l_ref"]) + float(request.form["l_ref"]), + request.form["class"] ) return render_template("upload.html") diff --git a/locaudio/localization.py b/locaudio/localization.py index f2be068..7d0e95b 100644 --- a/locaudio/localization.py +++ b/locaudio/localization.py @@ -21,7 +21,6 @@ from point import Point from location import Location -from functools import partial from collections import namedtuple import math diff --git a/locaudio/templates/upload.html b/locaudio/templates/upload.html index 47723cf..24b83d0 100644 --- a/locaudio/templates/upload.html +++ b/locaudio/templates/upload.html @@ -53,6 +53,10 @@

Upload

Sound name: + + Sound class: + + Reference distance: