From ef1b979c53aab8e8b01fd188a79ae707698b5355 Mon Sep 17 00:00:00 2001 From: glmdev Date: Sun, 10 Feb 2019 01:47:31 -0600 Subject: [PATCH] dynamic config --- .idea/workspace.xml | 51 +++++++++++++++++++++++---------------------- image_tools.py | 1 - index.py | 3 +++ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6e28112..3286bfb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,8 @@ - + + - + - - + + @@ -29,7 +30,7 @@ - + @@ -67,8 +68,8 @@ - - + + @@ -109,11 +110,11 @@ @@ -196,7 +197,7 @@ - + @@ -256,36 +257,36 @@ - + - - - - - + + - + - - + + + + + - - + + - + - - + + - + diff --git a/image_tools.py b/image_tools.py index 4c7f236..c06f812 100644 --- a/image_tools.py +++ b/image_tools.py @@ -1,7 +1,6 @@ def average_color(x, y, w, h, image): r, g, b = 0, 0, 0 count = 0 - print([x, y, w, h]) for s in range(x, x + w + 1): for t in range(y, y + h + 1): pixlr, pixlg, pixlb = image[s, t] diff --git a/index.py b/index.py index 774bceb..e36f24a 100644 --- a/index.py +++ b/index.py @@ -40,6 +40,7 @@ def poll(): color_reference = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['width'], stall_obj['height'], reference) color_compare = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['width'], stall_obj['height'], img) stall_occupied = image_tools.threshold(image_tools.differences(color_reference, color_compare), float(doc_conf['e_hat'])) + print(doc_conf['e_hat']) stall_obj['open'] = not stall_occupied print("Updated: "+stall.id) @@ -51,4 +52,6 @@ start_time = time.time() while True: poll() poll_time = float(os.getenv('POLL_FREQUENCY')) + doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict() + print(doc_conf) time.sleep(poll_time - ((time.time() - start_time) % poll_time))