Compare commits

...

6 Commits

Author SHA1 Message Date
glmdev
36a6e53dd9 finalize for demo 2019-02-10 03:46:41 -06:00
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
glmdev
ef1b979c53 dynamic config 2019-02-10 01:47:31 -06:00
glmdev
0a76d0099e default res 2019-02-10 01:44:46 -06:00
4 changed files with 54 additions and 54 deletions

View File

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/camera.py" beforeDir="false" afterPath="$PROJECT_DIR$/camera.py" afterDir="false" />
</list>
<list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -12,11 +10,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="42" column="46" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
<state relative-caret-position="721">
<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>
<element signature="e#0#21#0" expanded="true" />
</folding>
@ -29,11 +27,11 @@
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/camera.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="16" column="29" selection-start-line="16" selection-start-column="29" selection-end-line="16" selection-end-column="29" />
<state relative-caret-position="75">
<caret line="5" column="65" selection-start-line="5" selection-start-column="65" selection-end-line="5" selection-end-column="65" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -41,6 +39,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/capture.jpg">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
@ -62,8 +65,8 @@
<file pinned="false" current-in-tab="false">
<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 relative-caret-position="30">
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
</state>
</provider>
</entry>
@ -95,6 +98,11 @@
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>poll_t</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@ -104,11 +112,11 @@
<option value="$PROJECT_DIR$/image_diff_color.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$/.env" />
<option value="$PROJECT_DIR$/camera.py" />
<option value="$PROJECT_DIR$/image_tools.py" />
<option value="$PROJECT_DIR$/index.py" />
</list>
</option>
</component>
@ -251,16 +259,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="42" column="46" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.env">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
@ -268,22 +266,32 @@
</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="240">
<caret line="16" column="29" selection-start-line="16" selection-start-column="29" selection-end-line="16" selection-end-column="29" />
<state relative-caret-position="75">
<caret line="5" column="65" selection-start-line="5" selection-start-column="65" selection-end-line="5" selection-end-column="65" />
<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="30">
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="721">
<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>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@ -2,27 +2,16 @@ import pygame
import pygame.camera
import time
import cv2
from SimpleCV import Image, Camera
def capture(camera_stream = 0, camera_res = (1920, 1080)):
# cam = cv2.VideoCapture(camera_stream)
# s, img = cam.read()
#
# if s:
# cv2.imwrite('./capture.jpg', img)
cam = Camera()
img = cam.getImage()
img.save('./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()
def capture(camera_stream = "/dev/video0", camera_res = (640, 480)):
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'

View File

@ -1,7 +1,6 @@
def average_color(x, y, w, h, image):
r, g, b = 0, 0, 0
count = 0
print([x, y, w, h])
for s in range(x, x + w + 1):
for t in range(y, y + h + 1):
pixlr, pixlg, pixlb = image[s, t]

View File

@ -50,5 +50,9 @@ start_time = time.time()
while True:
poll()
poll_time = float(os.getenv('POLL_FREQUENCY'))
doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict()
print(doc_conf)
if doc_conf['stop']:
break
poll_time = float(doc_conf['frequency'])
time.sleep(poll_time - ((time.time() - start_time) % poll_time))