Created
February 23, 2019 20:03
-
-
Save codebudo/8158adf0836d26619896e7218635954d to your computer and use it in GitHub Desktop.
Capture a series of images from the raspberry pi camera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from picamera.array import PiRGBArray | |
from picamera import PiCamera | |
import cv2 | |
import time | |
# 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 | |
# delay to wait for camera to warm up | |
time.sleep(3) | |
# capture frames from the camera | |
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): | |
image = frame.array | |
if frame_num < 30: | |
cv2.imwrite('output'+str(frame_num)+'.jpg', image) | |
frame_num += 1 | |
else: | |
break | |
rawCapture.truncate(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment