Raspberry Pi Camera

  • Connect de Raspberry Pi camera met de Raspberry Pi.
  • Als je nog niet in de virtualenv zit, voer dan het volgende in de terminal in:
$ source ~/.profile
$ workon rr
  • installeer de picamera module met de volgende commando’s:
$ pip install "picamera[array]"
  • Om te testen of je camera functioneert kun je het volgende script gebruiken:
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2

# initialize the camera and grab a reference to the raw camera
camera = PiCamera()
raw_capture = PiRGBArray(camera)

# allow the camera to warmup
time.sleep(0.1)

# grab and image from the camera
camera.capture(raw_capture, format="bgr")
image = raw_capture.array

# display the image on screen and wait for a keypress
cv2.imshow("Image", image)
cv2.waitKey(0)
  • mocht deze code crashen probeer:
$ sudo rpi-update

hierdoor zullen alle raspberry pi drivers and firmware worden geupdated