Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Picademy 5 Picamera Intro Workshop

2,327 views

Published on

Introducing the Raspberry Pi camera module and Python picamera library

Published in: Education
  • Be the first to comment

Picademy 5 Picamera Intro Workshop

  1. 1. PYTHON PICAMERA Introducing the camera board and Python module
  2. 2. WHO'S THIS GUY? Ben Nuttall Development & Outreach Raspberry Pi Education Team @ben_nuttall ben@raspberrypi.org github.com/bennuttall
  3. 3. CONNECT THE CAMERA
  4. 4. COMMAND LINE
  5. 5. RASPI CONFIG $ sudo raspi­config
  6. 6. ENABLE CAMERA
  7. 7. ENABLE CAMERA
  8. 8. REBOOT
  9. 9. COMMAND LINE $ ls
  10. 10. COMMAND LINE $ raspistill ­o image1.jpg
  11. 11. COMMAND LINE $ ls
  12. 12. BOOT TO DESKTOP $ startx
  13. 13. OPEN FILE MANAGER
  14. 14. OPEN LXTERMINAL
  15. 15. OPEN IDLE AS ROOT USER $ sudo idle3 & FILE > NEW WINDOW SAVE WITH Ctrl + S
  16. 16. TAKE A PICTURE WITH PYTHON from picamera import PiCamera from time import sleep with PiCamera() as camera: camera.start_preview() sleep(3) camera.capture('/home/pi/image2.jpg') camera.stop_preview()
  17. 17. SAVE & RUN Ctrl + S F5
  18. 18. ADD A GPIO BUTTON
  19. 19. ADD GPIO TO CODE from picamera import PiCamera from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN, GPIO.PUD_UP) with PiCamera() as camera: camera.start_preview() GPIO.wait_for_edge(17, GPIO.FALLING) sleep(3) camera.capture('/home/pi/image2.jpg') camera.stop_preview()
  20. 20. ADD A LOOP with PiCamera() as camera: camera.start_preview() GPIO.wait_for_edge(17, GPIO.FALLING) for i in range(5): sleep(3) camera.capture('/home/pi/image%s.jpg' % i) camera.stop_preview()
  21. 21. WHAT'S THE DIFFERENCE? GPIO.wait_for_edge(17, GPIO.FALLING) for i in range(5): sleep(3) camera.capture('/home/pi/image%s.jpg' % i) for i in range(5): GPIO.wait_for_edge(17, GPIO.FALLING) camera.capture('/home/pi/image%s.jpg' % i) sleep(3)
  22. 22. WHAT CAN YOU DO?
  23. 23. WHAT CAN YOU DO?

×