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
290
Live Highlights in BBC iPlayer
bennuttall
0
81
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
140
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
93
Running a Python Package Index for Raspberry Pi
bennuttall
0
110
From Acorns to Raspberries
bennuttall
0
93
Innovation in the newsroom
bennuttall
0
110
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
170
How to market your open source project
bennuttall
0
210
Other Decks in Programming
See All in Programming
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
500
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
350
Making TCPSocket.new "Happy"!
coe401_
1
2.5k
大LLM時代にこの先生きのこるには-ITエンジニア編
fumiyakume
7
3.2k
ComposeでのPicture in Picture
takathemax
0
130
インプロセスQAにおいて大事にしていること / In-process QA Meetup
medley
0
100
Being an ethical software engineer
xgouchet
PRO
0
230
The Missing Link in Angular’s Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
110
KANNA Android の技術的課題と取り組み
watabee
0
160
エンジニア向けCursor勉強会 @ SmartHR
yukisnow1823
2
10k
Ruby on Railroad: The Power of Visualizing CFG
ydah
0
270
メモリウォールを超えて:キャッシュメモリ技術の進歩
kawayu
0
1.9k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
69
4.6k
Typedesign – Prime Four
hannesfritz
41
2.6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.1k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
23
2.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
580
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Cult of Friendly URLs
andyhume
78
6.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
How to Think Like a Performance Engineer
csswizardry
23
1.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