Tuesday, February 28, 2017

raspberry pi camera

python3
sudo apt-get install python3-picamera
https://www.raspberrypi.org/documentation/usage/camera/python/README.md


allow cv2.VideoCapture(0)
sudo modprobe bcm2835-v4l2

allow user access camera
sudo usermod XXXX -a -G video

single image display
import cv2
im = cv2.imread('test.jpg')
cv2.imshow('image', im)
cv2.waitKey()

video display
import cv2
ca = cv2.VideoCapture(0)
cv2.startWindowThread()
cv2.namedWindow('preview')
while True:
  _,  im = ca.read()
  cv2.imshow('preview', im)
  key = cv2.waitKey(1) & 0xFF
  if key == ord('q'):
    break

No comments:

Post a Comment