Fixing the camera 7

Camsize parameter
pull/1/head
Julius Riegel 7 years ago
parent ae22100db9
commit 167071ae6d

@ -41,8 +41,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="491"> <state relative-caret-position="389">
<caret line="87" column="70" lean-forward="false" selection-start-line="87" selection-start-column="70" selection-end-line="87" selection-end-column="70" /> <caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" />
<folding> <folding>
<element signature="e#0#28#0" expanded="true" /> <element signature="e#0#28#0" expanded="true" />
</folding> </folding>
@ -493,8 +493,8 @@
</entry> </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="491"> <state relative-caret-position="389">
<caret line="87" column="70" lean-forward="false" selection-start-line="87" selection-start-column="70" selection-end-line="87" selection-end-column="70" /> <caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" />
<folding> <folding>
<element signature="e#0#28#0" expanded="true" /> <element signature="e#0#28#0" expanded="true" />
</folding> </folding>

@ -73,9 +73,10 @@ class PiCamera(pygame.sprite.Sprite):
pygame.sprite.Sprite.__init__(self) pygame.sprite.Sprite.__init__(self)
pygame.camera.init() pygame.camera.init()
camera = picamera.PiCamera() camera = picamera.PiCamera()
camera.resolution = (1280/2, 720/2) self.camsize = (self.size[0], int(self.size[0]/2))
camera.resolution = self.camsize
self.camera = camera self.camera = camera
self.output = picamera.array.PiRGBArray(camera, size=(1280/2, 720/2)) self.output = picamera.array.PiRGBArray(camera, size=self.camsize)
self.size = size self.size = size
self.image = pygame.Surface(self.size) self.image = pygame.Surface(self.size)
self.image.fill((0, 0, 0)) self.image.fill((0, 0, 0))
@ -85,6 +86,6 @@ class PiCamera(pygame.sprite.Sprite):
def update(self, *args): def update(self, *args):
print('updating camera') print('updating camera')
self.output.truncate(0) self.output.truncate(0)
self.camera.capture(self.output, 'rgb', resize=(1280/2, 720/2)) self.camera.capture(self.output, 'rgb', resize=self.camsize)
s = pygame.transform.rotate(pygame.surfarray.make_surface(self.output.array), 90) s = pygame.transform.rotate(pygame.surfarray.make_surface(self.output.array), 90)
self.image.blit(s, (0, 0)) self.image.blit(s, (0, 0))
Loading…
Cancel
Save