picademy 5 picamera intro workshop
TRANSCRIPT
![Page 1: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/1.jpg)
PYTHON PICAMERA
Introducing the camera boardand Python module
![Page 2: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/2.jpg)
WHO'S THIS GUY?
Ben NuttallDevelopment & OutreachRaspberry Pi Education Team
@[email protected]/bennuttall
![Page 3: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/3.jpg)
CONNECT THE CAMERA
![Page 4: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/4.jpg)
COMMAND LINE
![Page 5: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/5.jpg)
RASPI CONFIG
$ sudo raspiconfig
![Page 6: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/6.jpg)
ENABLE CAMERA
![Page 7: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/7.jpg)
ENABLE CAMERA
![Page 8: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/8.jpg)
REBOOT
![Page 9: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/9.jpg)
COMMAND LINE
$ ls
![Page 10: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/10.jpg)
COMMAND LINE
$ raspistill o image1.jpg
![Page 11: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/11.jpg)
COMMAND LINE
$ ls
![Page 12: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/12.jpg)
BOOT TO DESKTOP
$ startx
![Page 13: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/13.jpg)
OPEN FILE MANAGER
![Page 14: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/14.jpg)
OPEN LXTERMINAL
![Page 15: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/15.jpg)
OPEN IDLE AS ROOT USER
$ sudo idle3 &
FILE > NEW WINDOW
SAVE WITH Ctrl + S
![Page 16: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/16.jpg)
TAKE A PICTURE WITH PYTHONfrom 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()
![Page 17: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/17.jpg)
SAVE & RUN
Ctrl + S
F5
![Page 18: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/18.jpg)
ADD A GPIO BUTTON
![Page 19: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/19.jpg)
ADD GPIO TO CODEfrom 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()
![Page 20: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/20.jpg)
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()
![Page 21: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/21.jpg)
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)
![Page 22: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/22.jpg)
WHAT CAN YOU DO?
![Page 23: Picademy 5 Picamera Intro Workshop](https://reader034.vdocuments.pub/reader034/viewer/2022052308/55d5781dbb61eb9a2f8b4593/html5/thumbnails/23.jpg)
WHAT CAN YOU DO?