Created
February 1, 2019 19:53
-
-
Save codebudo/c53135a3a38050db868de0943d62b778 to your computer and use it in GitHub Desktop.
RasPi camera video capture
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 | |
| # 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