Skip to content

Instantly share code, notes, and snippets.

@codebudo
Created February 1, 2019 19:53
Show Gist options
  • Select an option

  • Save codebudo/c53135a3a38050db868de0943d62b778 to your computer and use it in GitHub Desktop.

Select an option

Save codebudo/c53135a3a38050db868de0943d62b778 to your computer and use it in GitHub Desktop.
RasPi camera video capture
from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (1280, 720)
camera.framerate = 10
rawCapture = PiRGBArray(camera, size=(1280, 720))
frame_num = 0
# capture frames from the camera. Write to sequential filenames.
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
rawCapture.truncate(0)
image = frame.array
if frame_num < 10:
cv2.imwrite('output'+str(frame_num)+'.jpg', image)
frame_num += 1
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment