update
@ -2,24 +2,29 @@
|
|||||||
<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$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/image_tools.py" beforeDir="false" afterPath="$PROJECT_DIR$/image_tools.py" afterDir="false" />
|
<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" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-1-car.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-1-car.jpg" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-2-cars.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-2-cars.jpg" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-4-cars.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-4-cars.jpg" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-5-cars-A.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-5-cars-A.jpg" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="FileEditorManager">
|
<component name="FileEditorManager">
|
||||||
<leaf>
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||||
<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="225">
|
<state relative-caret-position="161">
|
||||||
<caret line="24" column="5" selection-start-line="24" selection-start-column="5" selection-end-line="24" selection-end-column="5" />
|
<caret line="30" column="54" selection-start-line="30" selection-start-column="54" selection-end-line="30" selection-end-column="54" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -61,8 +66,8 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="270">
|
<state relative-caret-position="45">
|
||||||
<caret line="18" column="35" lean-forward="true" selection-start-line="18" selection-start-column="35" selection-end-line="18" selection-end-column="35" />
|
<caret line="3" column="23" lean-forward="true" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -79,8 +84,8 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/.env">
|
<entry file="file://$PROJECT_DIR$/.env">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state relative-caret-position="45">
|
||||||
<caret column="16" selection-start-column="16" selection-end-column="16" />
|
<caret line="3" column="15" selection-start-line="3" selection-start-column="15" selection-end-line="3" selection-end-column="15" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -89,7 +94,7 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/config.py">
|
<entry file="file://$PROJECT_DIR$/config.py">
|
||||||
<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">
|
||||||
<caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -110,12 +115,12 @@
|
|||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
||||||
<option value="$PROJECT_DIR$/image_tools.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$/example.env" />
|
<option value="$PROJECT_DIR$/example.env" />
|
||||||
<option value="$PROJECT_DIR$/.env" />
|
|
||||||
<option value="$PROJECT_DIR$/camera.py" />
|
<option value="$PROJECT_DIR$/camera.py" />
|
||||||
|
<option value="$PROJECT_DIR$/.env" />
|
||||||
|
<option value="$PROJECT_DIR$/image_tools.py" />
|
||||||
<option value="$PROJECT_DIR$/index.py" />
|
<option value="$PROJECT_DIR$/index.py" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
@ -177,7 +182,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
<task active="true" id="Default" summary="Default task">
|
<task active="true" id="Default" summary="Default task">
|
||||||
<changelist id="57f4d31d-2726-4888-8d46-d2583bdc9c3d" name="Default Changelist" comment="" />
|
<changelist id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="" />
|
||||||
<created>1549681542752</created>
|
<created>1549681542752</created>
|
||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
@ -189,7 +194,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" />
|
||||||
@ -200,7 +205,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 anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32972974" />
|
<window_info active="true" anchor="bottom" id="Terminal" order="8" visible="true" 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" />
|
||||||
@ -214,9 +219,7 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-empty.jpg">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-empty.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/test.jpg">
|
<entry file="file://$PROJECT_DIR$/test.jpg" />
|
||||||
<provider selected="true" editor-type-id="images" />
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/capture.jpg">
|
<entry file="file://$PROJECT_DIR$/capture.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
@ -226,9 +229,6 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg">
|
|
||||||
<provider selected="true" editor-type-id="images" />
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="45">
|
<state relative-caret-position="45">
|
||||||
@ -236,26 +236,25 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/example.env">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="30">
|
||||||
|
<caret line="2" column="13" selection-start-line="2" selection-end-line="2" selection-end-column="13" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/config.py">
|
<entry file="file://$PROJECT_DIR$/config.py">
|
||||||
<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">
|
||||||
<caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/.env">
|
<entry file="file://$PROJECT_DIR$/ref-img.jpg">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="images" />
|
||||||
<state>
|
|
||||||
<caret column="16" selection-start-column="16" selection-end-column="16" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="images" />
|
||||||
<state relative-caret-position="270">
|
|
||||||
<caret line="18" column="35" lean-forward="true" selection-start-line="18" selection-start-column="35" selection-end-line="18" selection-end-column="35" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
</entry>
|
||||||
<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">
|
||||||
@ -267,17 +266,24 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/example.env">
|
<entry file="file://$PROJECT_DIR$/.env">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="30">
|
<state relative-caret-position="45">
|
||||||
<caret line="2" column="13" selection-start-line="2" selection-end-line="2" selection-end-column="13" />
|
<caret line="3" column="15" selection-start-line="3" selection-start-column="15" selection-end-line="3" selection-end-column="15" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="45">
|
||||||
|
<caret line="3" column="23" lean-forward="true" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</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="225">
|
<state relative-caret-position="161">
|
||||||
<caret line="24" column="5" selection-start-line="24" selection-start-column="5" selection-end-line="24" selection-end-column="5" />
|
<caret line="30" column="54" selection-start-line="30" selection-start-column="54" selection-end-line="30" selection-end-column="54" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
def average_color(x, y, n, image):
|
def average_color(x, y, w, h, image):
|
||||||
r, g, b = 0, 0, 0
|
r, g, b = 0, 0, 0
|
||||||
count = 0
|
count = 0
|
||||||
for s in range(x, x + n + 1):
|
print([x, y, w, h])
|
||||||
for t in range(y, y + n + 1):
|
for s in range(x, x + w + 1):
|
||||||
|
for t in range(y, y + h + 1):
|
||||||
pixlr, pixlg, pixlb = image[s, t]
|
pixlr, pixlg, pixlb = image[s, t]
|
||||||
r += pixlr
|
r += pixlr
|
||||||
g += pixlg
|
g += pixlg
|
||||||
|
32
index.py
@ -2,7 +2,9 @@ import firebase_admin
|
|||||||
from firebase_admin import credentials
|
from firebase_admin import credentials
|
||||||
from firebase_admin import firestore
|
from firebase_admin import firestore
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import time, os
|
import time
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
import camera
|
import camera
|
||||||
import image_tools
|
import image_tools
|
||||||
@ -16,25 +18,29 @@ firebase_admin.initialize_app(cred)
|
|||||||
|
|
||||||
db = firestore.client()
|
db = firestore.client()
|
||||||
|
|
||||||
doc_ref_lot1 = db.collection(os.getenv('LOT_NAME'))
|
|
||||||
|
|
||||||
|
|
||||||
def poll():
|
def poll():
|
||||||
|
doc_ref_lot = db.collection('lots').document(os.getenv('LOT_NAME'))
|
||||||
|
|
||||||
|
# Get the reference image
|
||||||
|
lot_info = doc_ref_lot.collection('info').document('lotInfo').get().to_dict()
|
||||||
|
urllib.request.urlretrieve('http://localhost:8000/img/references/'+lot_info['refImage'], './ref-img.jpg')
|
||||||
|
reference = Image.open('./ref-img.jpg').load()
|
||||||
|
|
||||||
# Take the picture
|
# Take the picture
|
||||||
img = Image.open(camera.capture(os.getenv('CAMERA_DEVICE'))).load()
|
#img = Image.open(camera.capture(os.getenv('CAMERA_DEVICE'))).load()
|
||||||
#img = Image.open('./lib/test-images/lot-empty.jpg').load()
|
img = Image.open('./lib/test-images-vert/lot-1-car.jpg').load()
|
||||||
reference = Image.open(os.getenv('REFERENCE_IMAGE')).load()
|
|
||||||
|
|
||||||
stalls = doc_ref_lot1.get()
|
doc_ref_stalls = doc_ref_lot.collection('stalls').get()
|
||||||
|
|
||||||
for stall in 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['sideN'], 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['sideN'], 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
|
||||||
print(stall.id)
|
print("Updated: "+stall.id)
|
||||||
db.collection(u'Lot1').document(stall.id).set( stall_obj )
|
|
||||||
|
doc_ref_lot.collection('stalls').document(stall.id).set(stall_obj)
|
||||||
|
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 51 KiB |
BIN
ref-img.jpg
Normal file
After Width: | Height: | Size: 38 KiB |