Fixing the camera 10

Images now only refresh when taken
pull/1/head
Julius Riegel 7 years ago
parent f166d26a4a
commit a798353933

@ -2,6 +2,7 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="49388e57-2b9e-468a-b880-1d7fb243112d" name="Default" comment=""> <list default="true" id="49388e57-2b9e-468a-b880-1d7fb243112d" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/controllib.py" afterPath="$PROJECT_DIR$/lib/controllib.py" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/graphiclib.py" afterPath="$PROJECT_DIR$/lib/graphiclib.py" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/graphiclib.py" afterPath="$PROJECT_DIR$/lib/graphiclib.py" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -29,7 +30,7 @@
<file leaf-file-name="main.py" pinned="false" current-in-tab="false"> <file leaf-file-name="main.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py"> <entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304"> <state relative-caret-position="697">
<caret line="41" column="28" lean-forward="true" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="28" /> <caret line="41" column="28" lean-forward="true" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="28" />
<folding> <folding>
<element signature="e#0#19#0" expanded="true" /> <element signature="e#0#19#0" expanded="true" />
@ -41,8 +42,8 @@
<file leaf-file-name="graphiclib.py" pinned="false" current-in-tab="true"> <file leaf-file-name="graphiclib.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py"> <entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="253"> <state relative-caret-position="389">
<caret line="76" column="70" lean-forward="false" selection-start-line="76" selection-start-column="70" selection-end-line="76" selection-end-column="70" /> <caret line="86" column="12" lean-forward="false" selection-start-line="86" selection-start-column="12" selection-end-line="86" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#28#0" expanded="true" /> <element signature="e#0#28#0" expanded="true" />
</folding> </folding>
@ -50,6 +51,16 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="controllib.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/controllib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="678">
<caret line="95" column="19" lean-forward="true" selection-start-line="95" selection-start-column="19" selection-end-line="95" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="update.sh" pinned="false" current-in-tab="false"> <file leaf-file-name="update.sh" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/update.sh"> <entry file="file://$PROJECT_DIR$/update.sh">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
@ -99,6 +110,7 @@
<option value="$PROJECT_DIR$/thermo.py" /> <option value="$PROJECT_DIR$/thermo.py" />
<option value="$PROJECT_DIR$/update.sh" /> <option value="$PROJECT_DIR$/update.sh" />
<option value="$PROJECT_DIR$/main.py" /> <option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/lib/controllib.py" />
<option value="$PROJECT_DIR$/lib/graphiclib.py" /> <option value="$PROJECT_DIR$/lib/graphiclib.py" />
</list> </list>
</option> </option>
@ -305,7 +317,6 @@
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/gyro.py" />
<entry file="file://$PROJECT_DIR$/install.sh"> <entry file="file://$PROJECT_DIR$/install.sh">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
@ -483,7 +494,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/main.py"> <entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304"> <state relative-caret-position="697">
<caret line="41" column="28" lean-forward="true" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="28" /> <caret line="41" column="28" lean-forward="true" selection-start-line="41" selection-start-column="28" selection-end-line="41" selection-end-column="28" />
<folding> <folding>
<element signature="e#0#19#0" expanded="true" /> <element signature="e#0#19#0" expanded="true" />
@ -491,10 +502,18 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/controllib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="678">
<caret line="95" column="19" lean-forward="true" selection-start-line="95" selection-start-column="19" selection-end-line="95" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py"> <entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="253"> <state relative-caret-position="389">
<caret line="76" column="70" lean-forward="false" selection-start-line="76" selection-start-column="70" selection-end-line="76" selection-end-column="70" /> <caret line="86" column="12" lean-forward="false" selection-start-line="86" selection-start-column="12" selection-end-line="86" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#28#0" expanded="true" /> <element signature="e#0#28#0" expanded="true" />
</folding> </folding>

@ -90,6 +90,7 @@ class Joystick():
def _save_camimg(self): def _save_camimg(self):
self.camera.new_frame()
img = self.camera.image img = self.camera.image
if os.path.isfile('image.jpg'): if os.path.isfile('image.jpg'):
count=0 count=0

@ -74,7 +74,7 @@ class PiCamera(pygame.sprite.Sprite):
pygame.camera.init() pygame.camera.init()
camera = picamera.PiCamera() camera = picamera.PiCamera()
self.camsize = (size[0], int(size[0]/2)) self.camsize = (size[0], int(size[0]/2))
camera.resolution = int(self.camsize[0]/2), int(self.camsize[1]/2) camera.resolution = self.camsize
self.camera = camera self.camera = camera
self.output = picamera.array.PiRGBArray(camera, size=self.camsize) self.output = picamera.array.PiRGBArray(camera, size=self.camsize)
self.size = size self.size = size
@ -84,7 +84,9 @@ class PiCamera(pygame.sprite.Sprite):
self.rect.topleft = position self.rect.topleft = position
def update(self, *args): def update(self, *args):
print('updating camera') pass
def new_frame(self):
self.output.truncate(0) self.output.truncate(0)
self.camera.capture(self.output, 'rgb', resize=self.camsize) self.camera.capture(self.output, 'rgb', resize=self.camsize)
s = pygame.transform.rotate(pygame.surfarray.make_surface(self.output.array), 270) s = pygame.transform.rotate(pygame.surfarray.make_surface(self.output.array), 270)

Loading…
Cancel
Save