add freq control
This commit is contained in:
parent
ef1b979c53
commit
7cb728c807
@ -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="476">
|
||||||
<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="55" column="68" lean-forward="true" selection-start-line="55" selection-start-column="68" selection-end-line="55" selection-end-column="68" />
|
||||||
<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>
|
||||||
@ -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="476">
|
||||||
<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="55" column="68" lean-forward="true" selection-start-line="55" selection-start-column="68" selection-end-line="55" selection-end-column="68" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
3
index.py
3
index.py
@ -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,7 @@ 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)
|
||||||
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user