Fixing the camera 4

Trying to improve the performane
pull/1/head
Julius Riegel 7 years ago
parent 29f3ebb70e
commit 8a763c7591

@ -41,8 +41,8 @@
<file leaf-file-name="graphiclib.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="474">
<caret line="86" column="87" lean-forward="false" selection-start-line="86" selection-start-column="87" selection-end-line="86" selection-end-column="87" />
<state relative-caret-position="457">
<caret line="85" column="30" lean-forward="false" selection-start-line="85" selection-start-column="30" selection-end-line="85" selection-end-column="30" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
@ -493,8 +493,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="474">
<caret line="86" column="87" lean-forward="false" selection-start-line="86" selection-start-column="87" selection-end-line="86" selection-end-column="87" />
<state relative-caret-position="457">
<caret line="85" column="30" lean-forward="false" selection-start-line="85" selection-start-column="30" selection-end-line="85" selection-end-column="30" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>

@ -74,6 +74,7 @@ class PiCamera(pygame.sprite.Sprite):
pygame.camera.init()
camera = picamera.PiCamera()
self.camera = camera
self.output = picamera.array.PiRGBArray(camera, size=size)
self.size = size
self.image = pygame.Surface(self.size)
self.image.fill((0, 0, 0))
@ -82,7 +83,7 @@ class PiCamera(pygame.sprite.Sprite):
def update(self, *args):
print('updating camera')
with picamera.array.PiRGBArray(self.camera, size=self.size) as output:
self.camera.capture(output, 'rgb')
s = pygame.transform.rotate(pygame.surfarray.make_surface(output.array), 90)
self.image.blit(s, (0, 0))
self.output.truncate(0)
self.camera.capture(self.output, 'rgb')
s = pygame.transform.rotate(pygame.surfarray.make_surface(self.output.array), 90)
self.image.blit(s, (0, 0))
Loading…
Cancel
Save