From 8a763c7591403ceca26f02d6265cd6e27e5fcd28 Mon Sep 17 00:00:00 2001 From: Julius Riegel Date: Sat, 13 Jan 2018 17:41:15 +0100 Subject: [PATCH] Fixing the camera 4 Trying to improve the performane --- .idea/workspace.xml | 8 ++++---- lib/graphiclib.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 16b22a8..1326bad 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -41,8 +41,8 @@ - - + + @@ -493,8 +493,8 @@ - - + + diff --git a/lib/graphiclib.py b/lib/graphiclib.py index 838550b..0882056 100644 --- a/lib/graphiclib.py +++ b/lib/graphiclib.py @@ -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)) \ No newline at end of file + 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)) \ No newline at end of file