Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0b35991e8 | ||
|
|
a0ce12ba0b | ||
|
|
633e728141 | ||
|
|
b39236bcb1 | ||
|
|
f7cf37dbf0 | ||
|
|
fb785dab53 | ||
|
|
8f3b2e1d0a | ||
|
|
ba00272bd3 | ||
|
|
f60af7a9cc | ||
|
|
2ffafa6719 | ||
|
|
31c6293576 |
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
### FIREBASE STUFF ###
|
### FIREBASE STUFF ###
|
||||||
hackku-*.json
|
hackku-*.json
|
||||||
|
|
||||||
|
.env
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/git,python,opencv,pycharm,visualstudio,visualstudiocode
|
# Created by https://www.gitignore.io/api/git,python,opencv,pycharm,visualstudio,visualstudiocode
|
||||||
# Edit at https://www.gitignore.io/?templates=git,python,opencv,pycharm,visualstudio,visualstudiocode
|
# Edit at https://www.gitignore.io/?templates=git,python,opencv,pycharm,visualstudio,visualstudiocode
|
||||||
|
|||||||
176
.idea/workspace.xml
generated
@@ -2,22 +2,21 @@
|
|||||||
<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$/.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_diff_color.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" />
|
|
||||||
</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="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="270">
|
<state relative-caret-position="450">
|
||||||
<caret line="18" column="46" selection-start-line="18" selection-start-column="46" selection-end-line="18" selection-end-column="46" />
|
<caret line="42" column="46" lean-forward="true" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@@ -30,11 +29,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="165">
|
<state relative-caret-position="150">
|
||||||
<caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
|
<caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@@ -45,8 +44,17 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<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="15">
|
<state relative-caret-position="45">
|
||||||
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
<caret line="3" column="4" selection-start-line="3" selection-start-column="4" selection-end-line="3" selection-end-column="4" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/example.env">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="75">
|
||||||
|
<caret line="5" column="45" selection-start-line="5" selection-start-column="45" selection-end-line="5" selection-end-column="45" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@@ -54,8 +62,26 @@
|
|||||||
<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="-379">
|
<state relative-caret-position="45">
|
||||||
<caret line="27" column="1" selection-start-line="27" selection-start-column="1" selection-end-line="27" selection-end-column="1" />
|
<caret line="3" column="23" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/.env">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="45">
|
||||||
|
<caret line="3" column="18" selection-start-line="3" selection-start-column="18" selection-end-line="3" selection-end-column="18" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/config.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="75">
|
||||||
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@@ -75,10 +101,14 @@
|
|||||||
<component name="IdeDocumentHistory">
|
<component name="IdeDocumentHistory">
|
||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/.gitignore" />
|
|
||||||
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
||||||
<option value="$PROJECT_DIR$/camera.py" />
|
<option value="$PROJECT_DIR$/.gitignore" />
|
||||||
|
<option value="$PROJECT_DIR$/config.py" />
|
||||||
|
<option value="$PROJECT_DIR$/image_tools.py" />
|
||||||
|
<option value="$PROJECT_DIR$/example.env" />
|
||||||
<option value="$PROJECT_DIR$/index.py" />
|
<option value="$PROJECT_DIR$/index.py" />
|
||||||
|
<option value="$PROJECT_DIR$/.env" />
|
||||||
|
<option value="$PROJECT_DIR$/camera.py" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@@ -103,13 +133,7 @@
|
|||||||
<path>
|
<path>
|
||||||
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
||||||
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
||||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
<item name="test-images-vert" type="462c0819:PsiDirectoryNode" />
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
|
||||||
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
|
||||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
|
||||||
<item name="test-images" type="462c0819:PsiDirectoryNode" />
|
|
||||||
</path>
|
</path>
|
||||||
</expand>
|
</expand>
|
||||||
<select />
|
<select />
|
||||||
@@ -122,6 +146,11 @@
|
|||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="RecentsManager">
|
||||||
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="$PROJECT_DIR$" />
|
||||||
|
</key>
|
||||||
|
</component>
|
||||||
<component name="RunDashboard">
|
<component name="RunDashboard">
|
||||||
<option name="ruleStates">
|
<option name="ruleStates">
|
||||||
<list>
|
<list>
|
||||||
@@ -139,7 +168,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" />
|
||||||
@@ -151,7 +180,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" />
|
||||||
@@ -162,7 +191,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" />
|
||||||
@@ -176,54 +205,85 @@
|
|||||||
<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$/lib/test-images/lot-3-cars.jpg">
|
<entry file="file://$PROJECT_DIR$/test.jpg" />
|
||||||
<provider selected="true" editor-type-id="images" />
|
|
||||||
</entry>
|
|
||||||
<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>
|
||||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="15">
|
|
||||||
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</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>
|
|
||||||
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="-379">
|
|
||||||
<caret line="27" column="1" selection-start-line="27" selection-start-column="1" selection-end-line="27" selection-end-column="1" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-1-car.jpg">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-1-car.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-2-cars.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</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$/lib/test-images/lot-4-cars.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-A.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
<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$/config.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="75">
|
||||||
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/ref-img.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="45">
|
||||||
|
<caret line="3" column="4" selection-start-line="3" selection-start-column="4" selection-end-line="3" selection-end-column="4" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/example.env">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="75">
|
||||||
|
<caret line="5" column="45" selection-start-line="5" selection-start-column="45" selection-end-line="5" selection-end-column="45" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</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="270">
|
<state relative-caret-position="450">
|
||||||
<caret line="18" column="46" selection-start-line="18" selection-start-column="46" selection-end-line="18" selection-end-column="46" />
|
<caret line="42" column="46" lean-forward="true" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
|
||||||
<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$/.env">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="45">
|
||||||
|
<caret line="3" column="18" selection-start-line="3" selection-start-column="18" selection-end-line="3" selection-end-column="18" />
|
||||||
|
</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" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/camera.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="150">
|
||||||
|
<caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
BIN
ai_image.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
ai_image.out.jpg
Normal file
|
After Width: | Height: | Size: 77 KiB |
23
camera.py
@@ -1,14 +1,23 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import pygame.camera
|
import pygame.camera
|
||||||
|
import time
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
|
||||||
def capture():
|
def capture(camera_stream = 0, camera_res = (1920, 1080)):
|
||||||
pygame.camera.init()
|
cam = cv2.VideoCapture(camera_stream)
|
||||||
pygame.camera.list_cameras()
|
s, img = cam.read()
|
||||||
cam = pygame.camera.Camera('/dev/video4', (640, 480))
|
|
||||||
cam.start()
|
if s:
|
||||||
img = cam.get_image()
|
cv2.imwrite('./capture.jpg', img)
|
||||||
pygame.image.save(img, './capture.jpg')
|
# pygame.camera.init()
|
||||||
|
# pygame.camera.list_cameras()
|
||||||
|
# cam = pygame.camera.Camera(camera_stream, camera_res)
|
||||||
|
# cam.start()
|
||||||
|
# time.sleep(5)
|
||||||
|
# img = cam.get_image()
|
||||||
|
# pygame.image.save(img, './capture.jpg')
|
||||||
|
# cam.stop()
|
||||||
return './capture.jpg'
|
return './capture.jpg'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
capture.jpg
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 29 KiB |
5
config.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
||||||
|
def bootstrap(envfile='./.env'):
|
||||||
|
load_dotenv(dotenv_path=envfile)
|
||||||
6
example.env
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
POLL_FREQUENCY=15
|
||||||
|
FIREBASE_CERT_FILE="hackku-272b6e79b2a9.json"
|
||||||
|
CAMERA_DEVICE="/dev/video0"
|
||||||
|
LOT_NAME="Lot26"
|
||||||
|
E_HAT_TRIGGER_LEVEL=4
|
||||||
|
BACKEND_URL="https://waitnomore.glmdev.tech/"
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
from PIL import Image
|
def average_color(x, y, w, h, image):
|
||||||
|
|
||||||
def average_color(x, y, n, 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
|
||||||
@@ -21,64 +20,3 @@ def differences(rgb_tuple1, rgb_tuple2):
|
|||||||
def threshold(diff_tuple, trigger=4):
|
def threshold(diff_tuple, trigger=4):
|
||||||
dr, dg, db = diff_tuple
|
dr, dg, db = diff_tuple
|
||||||
return (((( dr**4 + dg**4 + db**4 ) / 3)**0.25) > trigger) # Thanks to Thomas Atkins, math whiz
|
return (((( dr**4 + dg**4 + db**4 ) / 3)**0.25) > trigger) # Thanks to Thomas Atkins, math whiz
|
||||||
|
|
||||||
#
|
|
||||||
# reference_image = Image.open('./lib/test-images/lot-empty.jpg').load()
|
|
||||||
# compare_image = Image.open('./lib/test-images/lot-1-car.jpg').load()
|
|
||||||
#
|
|
||||||
# stall_1 = {
|
|
||||||
# 'location': (54, 79, 109),
|
|
||||||
# 'reference': average_color(54, 79, 109, reference_image),
|
|
||||||
# 'compare': average_color(54, 79, 109, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_2 = {
|
|
||||||
# 'location': (186, 81, 116),
|
|
||||||
# 'reference': average_color(186, 81, 116, reference_image),
|
|
||||||
# 'compare': average_color(186, 81, 116, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_3 = {
|
|
||||||
# 'location': (317, 71, 127),
|
|
||||||
# 'reference': average_color(317, 71, 127, reference_image),
|
|
||||||
# 'compare': average_color(317, 71, 127, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_4 = {
|
|
||||||
# 'location': (469, 76, 100),
|
|
||||||
# 'reference': average_color(469, 76, 100, reference_image),
|
|
||||||
# 'compare': average_color(469, 76, 100, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_5 = {
|
|
||||||
# 'location': (27, 237, 119),
|
|
||||||
# 'reference': average_color(27, 237, 119, reference_image),
|
|
||||||
# 'compare': average_color(27, 237, 119, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_6 = {
|
|
||||||
# 'location': (172, 240, 130),
|
|
||||||
# 'reference': average_color(172, 240, 130, reference_image),
|
|
||||||
# 'compare': average_color(172, 240, 130, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_7 = {
|
|
||||||
# 'location': (317, 234, 144),
|
|
||||||
# 'reference': average_color(317, 234, 144, reference_image),
|
|
||||||
# 'compare': average_color(317, 234, 144, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# stall_8 = {
|
|
||||||
# 'location': (481, 233, 112),
|
|
||||||
# 'reference': average_color(481, 233, 112, reference_image),
|
|
||||||
# 'compare': average_color(481, 233, 112, compare_image)
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# print(threshold(differences(stall_1['reference'], stall_1['compare'])))
|
|
||||||
# print(threshold(differences(stall_2['reference'], stall_2['compare'])))
|
|
||||||
# print(threshold(differences(stall_3['reference'], stall_3['compare'])))
|
|
||||||
# print(threshold(differences(stall_4['reference'], stall_4['compare'])))
|
|
||||||
# print(threshold(differences(stall_5['reference'], stall_5['compare'])))
|
|
||||||
# print(threshold(differences(stall_6['reference'], stall_6['compare'])))
|
|
||||||
# print(threshold(differences(stall_7['reference'], stall_7['compare'])))
|
|
||||||
# print(threshold(differences(stall_8['reference'], stall_8['compare'])))
|
|
||||||
|
|||||||
46
index.py
@@ -2,31 +2,53 @@ 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
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
import camera
|
import camera
|
||||||
import image_tools
|
import image_tools
|
||||||
|
import config
|
||||||
|
|
||||||
|
config.bootstrap()
|
||||||
|
|
||||||
# Use a service account
|
# Use a service account
|
||||||
cred = credentials.Certificate('./hackku-272b6e79b2a9.json')
|
cred = credentials.Certificate(os.getenv('FIREBASE_CERT_FILE'))
|
||||||
firebase_admin.initialize_app(cred)
|
firebase_admin.initialize_app(cred)
|
||||||
|
|
||||||
db = firestore.client()
|
db = firestore.client()
|
||||||
|
|
||||||
doc_ref_lot1 = db.collection(u'Lot1')
|
doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict()
|
||||||
|
print(doc_conf)
|
||||||
|
|
||||||
|
def poll():
|
||||||
|
doc_ref_lot = db.collection('lots').document(doc_conf['lot_id'])
|
||||||
|
|
||||||
|
# Get the reference image
|
||||||
|
lot_info = doc_ref_lot.collection('info').document('lotInfo').get().to_dict()
|
||||||
|
urllib.request.urlretrieve(os.getenv('BACKEND_URL')+'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()).load()
|
img = Image.open(camera.capture(doc_conf['stream'])).load()
|
||||||
img = Image.open('./lib/test-images/lot-3-cars.jpg').load()
|
#img = Image.open('./lib/test-images-vert/lot-3-cars.jpg').load()
|
||||||
reference = Image.open('./lib/test-images/lot-empty.jpg').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:
|
||||||
#print(u'{} => {}'.format(stall.id, stall.to_dict()))
|
|
||||||
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))
|
stall_occupied = image_tools.threshold(image_tools.differences(color_reference, color_compare), float(doc_conf['e_hat']))
|
||||||
stall_obj['open'] = not stall_occupied
|
stall_obj['open'] = not stall_occupied
|
||||||
|
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()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
poll()
|
||||||
|
poll_time = float(os.getenv('POLL_FREQUENCY'))
|
||||||
|
time.sleep(poll_time - ((time.time() - start_time) % poll_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: 35 KiB |
14
tensor.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from imageai.Detection import ObjectDetection
|
||||||
|
import os
|
||||||
|
|
||||||
|
execution_path = os.getcwd()
|
||||||
|
|
||||||
|
detector = ObjectDetection()
|
||||||
|
detector.setModelTypeAsRetinaNet()
|
||||||
|
detector.setModelPath(os.path.join(execution_path, "resnet50_coco_best_v2.0.1.h5"))
|
||||||
|
detector.loadModel()
|
||||||
|
|
||||||
|
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path, "ai_image.jpg"), output_image_path=os.path.join(execution_path , "ai_image.out.jpg"))
|
||||||
|
|
||||||
|
for eachObject in detections:
|
||||||
|
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )
|
||||||
BIN
test-images-vert/lot-1-car.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
test-images-vert/lot-2-cars.jpg
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
test-images-vert/lot-3-cars.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
test-images-vert/lot-4-cars.jpg
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
test-images-vert/lot-5-cars-A.jpg
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
test-images-vert/lot-5-cars-B.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
test-images-vert/lot-empty.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |