Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python Picamera with GPIO Zero
Search
Ben Nuttall
October 15, 2016
Programming
0
300
Python Picamera with GPIO Zero
Picamera workshop given at Pi Towers Raspberry Jam, October 2016
Ben Nuttall
October 15, 2016
Tweet
Share
More Decks by Ben Nuttall
See All by Ben Nuttall
Numeronyms are obnoxious
bennuttall
0
220
Live Highlights in BBC iPlayer
bennuttall
0
63
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
130
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
79
Running a Python Package Index for Raspberry Pi
bennuttall
0
96
From Acorns to Raspberries
bennuttall
0
76
Innovation in the newsroom
bennuttall
0
91
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
150
How to market your open source project
bennuttall
0
200
Other Decks in Programming
See All in Programming
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
730
pylint custom ruleで始めるレビュー自動化
shogoujiie
0
120
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
昭和の職場からアジャイルの世界へ
kumagoro95
1
370
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
450
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
220
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.4k
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
310
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
270
苦しいTiDBへの移行を乗り越えて快適な運用を目指す
leveragestech
0
560
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
205
24k
Gamification - CAS2011
davidbonilla
80
5.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Site-Speed That Sticks
csswizardry
4
380
Music & Morning Musume
bryan
46
6.3k
How to train your dragon (web standard)
notwaldorf
91
5.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
RailsConf 2023
tenderlove
29
1k
For a Future-Friendly Web
brad_frost
176
9.5k
Transcript
Python Picamera with GPIO Zero Introducing the camera board and
Python module
Raspberry Pi camera module - 5Mpx / 8Mpx - Full
HD - Photo & video - Command line - Python module - Infra-red camera
Connect the camera
Add a GPIO Button
Boot the Pi and open Python 3
IDLE Python Shell >>> from picamera import PiCamera >>> from
gpiozero import Button >>> camera = PiCamera() >>> button = Button(17) >>> button.when_pressed = camera.start_preview >>> button.when_released = camera.stop_preview
Open a new file • File > New File •
File > Save • Save as camera.py
Take a selfie from picamera import PiCamera from time import
sleep camera = PiCamera() camera.start_preview() sleep(3) camera.capture("/home/pi/image.jpg") camera.stop_preview() Save and run: Ctrl + S F5
Add GPIO Button code from picamera import PiCamera from gpiozero
import Button from time import sleep camera = PiCamera() button = Button(17) camera.start_preview() button.wait_for_press() sleep(3) camera.capture("/home/pi/button.jpg") camera.stop_preview()
Add a loop camera.start_preview() for i in range(5): button.wait_for_press() sleep(3)
camera.capture("/home/pi/button%s.jpg" % i) camera.stop_preview()
Picamera effects
Picamera effects camera.start_preview() button.wait_for_press() camera.image_effect = 'negative' sleep(5) camera.capture("/home/pi/negative.jpg") camera.stop_preview()
Try more effects: - negative - colorswap - sketch - emboss
Picamera effects import random camera.start_preview() for i in range(5): button.wait_for_press()
effect = random.choice(list(camera.IMAGE_EFFECTS)) camera.image_effect = effect camera.annotate_text = effect sleep(5) camera.capture("/home/pi/%s.jpg" % effect) camera.stop_preview() Try more effects: - negative - colorswap - sketch - emboss
Documentation and help guides • picamera.readthedocs.io • gpiozero.readthedocs.io • raspberrypi.org/resources
• raspberrypi.org/education/downloads
What next? • Time-lapse • Stop motion animation • Wildlife
camera
What next? • Sensor trigger • Send to social media
• Robotics