Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from apollo-1845/main
Browse files Browse the repository at this point in the history
Update the release version
  • Loading branch information
micnekr authored Feb 20, 2022
2 parents a6f8504 + c6b02c8 commit 4f41b07
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sensors/camera/camera.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
from project_types import Sensor
from sensors.camera.base_camera import CameraData

from settings import PREFERRED_RESOLUTION, PREFERRED_RES_NP

from picamera import PiCamera
import numpy as np

OUTPUT_RES_NP = PREFERRED_RES_NP + (3,) # With 3-byte colour depth

class Camera(Sensor):
"""A physical camera using the Raspberry Pi's PiCamera API."""

def __init__(self):
"""Initialize camera."""
self.camera = PiCamera()
self.camera.resolution = (640, 480)
self.camera.resolution = PREFERRED_RESOLUTION
self.camera.start_preview()

def capture_data(self):
"""Capture frames from self.camera."""
output = np.empty((480, 640, 3), dtype=np.uint8)
self.camera.capture(output, 'rgb')
output = np.empty(OUTPUT_RES_NP, dtype=np.uint8)
self.camera.capture(output, 'bgr')

return CameraData.from_color_image(output)

0 comments on commit 4f41b07

Please sign in to comment.