3 Commits

Author SHA1 Message Date
glmdev
4444e26c08 add stop control 2019-02-10 02:11:21 -06:00
glmdev
3032389846 typo 2019-02-10 02:01:58 -06:00
glmdev
7cb728c807 add freq control 2019-02-10 02:00:51 -06:00
2 changed files with 14 additions and 9 deletions

18
.idea/workspace.xml generated
View File

@@ -2,7 +2,6 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment=""> <list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/image_tools.py" beforeDir="false" afterPath="$PROJECT_DIR$/image_tools.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.py" beforeDir="false" afterPath="$PROJECT_DIR$/index.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/index.py" beforeDir="false" afterPath="$PROJECT_DIR$/index.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -16,8 +15,8 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/index.py"> <entry file="file://$PROJECT_DIR$/index.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="326"> <state relative-caret-position="751">
<caret line="24" column="68" lean-forward="true" selection-start-line="24" selection-start-column="68" selection-end-line="24" selection-end-column="68" /> <caret line="54" column="24" lean-forward="true" selection-start-line="54" selection-start-column="24" selection-end-line="54" selection-end-column="24" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
</folding> </folding>
@@ -101,6 +100,11 @@
</list> </list>
</option> </option>
</component> </component>
<component name="FindInProjectRecents">
<findStrings>
<find>poll_t</find>
</findStrings>
</component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
@@ -113,8 +117,8 @@
<option value="$PROJECT_DIR$/example.env" /> <option value="$PROJECT_DIR$/example.env" />
<option value="$PROJECT_DIR$/.env" /> <option value="$PROJECT_DIR$/.env" />
<option value="$PROJECT_DIR$/camera.py" /> <option value="$PROJECT_DIR$/camera.py" />
<option value="$PROJECT_DIR$/index.py" />
<option value="$PROJECT_DIR$/image_tools.py" /> <option value="$PROJECT_DIR$/image_tools.py" />
<option value="$PROJECT_DIR$/index.py" />
</list> </list>
</option> </option>
</component> </component>
@@ -197,7 +201,7 @@
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" /> <window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" /> <window_info anchor="bottom" id="Version Control" order="7" />
<window_info active="true" anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32972974" /> <window_info anchor="bottom" id="Terminal" order="8" weight="0.32972974" />
<window_info anchor="bottom" id="Python Console" order="9" /> <window_info anchor="bottom" id="Python Console" order="9" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" /> <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
@@ -283,8 +287,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/index.py"> <entry file="file://$PROJECT_DIR$/index.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="326"> <state relative-caret-position="751">
<caret line="24" column="68" lean-forward="true" selection-start-line="24" selection-start-column="68" selection-end-line="24" selection-end-column="68" /> <caret line="54" column="24" lean-forward="true" selection-start-line="54" selection-start-column="24" selection-end-line="54" selection-end-column="24" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
</folding> </folding>

View File

@@ -40,7 +40,6 @@ def poll():
color_reference = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['width'], stall_obj['height'], reference) 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) 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'])) 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 stall_obj['open'] = not stall_occupied
print("Updated: "+stall.id) print("Updated: "+stall.id)
@@ -51,7 +50,9 @@ start_time = time.time()
while True: while True:
poll() poll()
poll_time = float(os.getenv('POLL_FREQUENCY'))
doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict() doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict()
print(doc_conf) print(doc_conf)
if doc_conf['stop']:
break
poll_time = float(doc_conf['frequency'])
time.sleep(poll_time - ((time.time() - start_time) % poll_time)) time.sleep(poll_time - ((time.time() - start_time) % poll_time))