This commit is contained in:
glmdev 2019-02-09 18:31:26 -06:00
parent fb785dab53
commit 6f7b2c9ec6
3 changed files with 24 additions and 22 deletions

View File

@ -2,7 +2,8 @@
<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$/example.env" beforeDir="false" afterPath="$PROJECT_DIR$/example.env" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/camera.py" beforeDir="false" afterPath="$PROJECT_DIR$/camera.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" />
@ -13,11 +14,11 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<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="375"> <state relative-caret-position="540">
<caret line="25" column="56" selection-start-line="25" selection-start-column="56" selection-end-line="25" selection-end-column="56" /> <caret line="36" column="67" selection-start-line="36" selection-start-column="67" selection-end-line="36" selection-end-column="67" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
</folding> </folding>
@ -35,11 +36,11 @@
<provider selected="true" editor-type-id="images" /> <provider selected="true" editor-type-id="images" />
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/camera.py"> <entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105"> <state relative-caret-position="165">
<caret line="7" column="44" selection-start-line="7" selection-start-column="44" selection-end-line="7" selection-end-column="44" /> <caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
<folding> <folding>
<element signature="e#0#13#0" expanded="true" /> <element signature="e#0#13#0" expanded="true" />
</folding> </folding>
@ -115,11 +116,11 @@
<option value="$PROJECT_DIR$/image_diff_color.py" /> <option value="$PROJECT_DIR$/image_diff_color.py" />
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/config.py" /> <option value="$PROJECT_DIR$/config.py" />
<option value="$PROJECT_DIR$/camera.py" />
<option value="$PROJECT_DIR$/image_tools.py" /> <option value="$PROJECT_DIR$/image_tools.py" />
<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$/index.py" /> <option value="$PROJECT_DIR$/index.py" />
<option value="$PROJECT_DIR$/camera.py" />
</list> </list>
</option> </option>
</component> </component>
@ -186,7 +187,7 @@
<frame x="0" y="27" width="1920" height="1053" extended-state="6" /> <frame x="0" y="27" width="1920" height="1053" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.18133895" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18133895" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" /> <window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
@ -257,16 +258,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="44" selection-start-line="7" selection-start-column="44" selection-end-line="7" selection-end-column="44" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example.env"> <entry file="file://$PROJECT_DIR$/example.env">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75"> <state relative-caret-position="75">
@ -283,13 +274,23 @@
</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="375"> <state relative-caret-position="540">
<caret line="25" column="56" selection-start-line="25" selection-start-column="56" selection-end-line="25" selection-end-column="56" /> <caret line="36" column="67" selection-start-line="36" selection-start-column="67" selection-end-line="36" selection-end-column="67" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component> </component>
</project> </project>

View File

@ -9,6 +9,7 @@ def capture(camera_stream = "/dev/video4"):
cam.start() cam.start()
img = cam.get_image() img = cam.get_image()
pygame.image.save(img, './capture.jpg') pygame.image.save(img, './capture.jpg')
cam.stop()
return './capture.jpg' return './capture.jpg'

View File

@ -34,7 +34,7 @@ def poll():
for stall in doc_ref_stalls: for stall in doc_ref_stalls:
stall_obj = stall.to_dict() stall_obj = stall.to_dict()
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(75, 400, 50, 50, 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(os.getenv('E_HAT_TRIGGER_LEVEL'))) stall_occupied = image_tools.threshold(image_tools.differences(color_reference, color_compare), float(os.getenv('E_HAT_TRIGGER_LEVEL')))
stall_obj['open'] = not stall_occupied stall_obj['open'] = not stall_occupied