8 Commits

Author SHA1 Message Date
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
glmdev
5a8940da7b simplecv 2019-02-10 01:00:14 -06:00
glmdev
f0b35991e8 opencv cam 2019-02-10 00:38:47 -06:00
glmdev
a0ce12ba0b fix camera timing 2019-02-10 00:34:00 -06:00
glmdev
633e728141 fix camera resolution 2019-02-10 00:28:42 -06:00
4 changed files with 48 additions and 38 deletions

75
.idea/workspace.xml generated
View File

@@ -2,10 +2,7 @@
<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" />
<change beforePath="$PROJECT_DIR$/capture.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/capture.jpg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.py" beforeDir="false" afterPath="$PROJECT_DIR$/index.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ref-img.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/ref-img.jpg" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -15,11 +12,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" lean-forward="true" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
<state relative-caret-position="461">
<caret line="54" column="31" selection-start-line="54" selection-start-column="31" selection-end-line="54" selection-end-column="31" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
@@ -32,11 +29,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="165">
<caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
<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>
@@ -44,6 +41,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">
@@ -65,8 +67,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>
@@ -98,6 +100,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>
@@ -107,11 +114,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>
@@ -183,7 +190,7 @@
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
<editor active="true" />
<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="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
@@ -194,7 +201,7 @@
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Terminal" order="8" 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="Event Log" order="10" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
@@ -230,13 +237,6 @@
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg">
<provider selected="true" editor-type-id="images" />
</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$/config.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
@@ -261,16 +261,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" lean-forward="true" 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">
@@ -280,13 +270,30 @@
</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" />
<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="461">
<caret line="54" column="31" selection-start-line="54" selection-start-column="31" selection-end-line="54" selection-end-column="31" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@@ -1,12 +1,14 @@
import pygame
import pygame.camera
import time
def capture(camera_stream = "/dev/video4"):
def capture(camera_stream = "/dev/video0", camera_res = (640, 480)):
pygame.camera.init()
pygame.camera.list_cameras()
cam = pygame.camera.Camera(camera_stream, (640, 480))
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()

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,7 @@ 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)
poll_time = float(doc_conf['frequency'])
time.sleep(poll_time - ((time.time() - start_time) % poll_time))