Skip to content

Instantly share code, notes, and snippets.

@charlsagente
Last active August 11, 2019 02:09
Show Gist options
  • Save charlsagente/b4191581c33fb69ee6a9d8361c4409a2 to your computer and use it in GitHub Desktop.
Save charlsagente/b4191581c33fb69ee6a9d8361c4409a2 to your computer and use it in GitHub Desktop.
Raspberry Pi Camera
# Take still pictures with Python
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 180 # You can rotate the image by 90, 180 or 270 degrees
camera.start_preview() # Make the camera preview
for i in range(5):
sleep(5) # The camera should take one picture every five seconds.
camera.capture('/home/pi/Desktop/image%s.jpg' % i)
camera.stop_preview()
# Recording video with Python
camera.start_preview()
camera.start_recording('/home/pi/Desktop/video.h264')
sleep(5)
camera.stop_recording()
camera.stop_preview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment