Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
330
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
420
Live Highlights in BBC iPlayer
bennuttall
0
120
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
180
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
130
Running a Python Package Index for Raspberry Pi
bennuttall
0
160
From Acorns to Raspberries
bennuttall
0
140
Innovation in the newsroom
bennuttall
0
180
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
200
How to market your open source project
bennuttall
0
250
Other Decks in Programming
See All in Programming
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
39
26k
開発に寄りそう自動テストの実現
goyoki
2
1.4k
AIエージェントの設計で注意するべきポイント6選
har1101
5
2.4k
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
450
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
190
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
460
Implementation Patterns
denyspoltorak
0
120
tparseでgo testの出力を見やすくする
utgwkk
2
290
AIコーディングエージェント(skywork)
kondai24
0
210
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
120
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
Patterns of Patterns
denyspoltorak
0
350
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
The agentic SEO stack - context over prompts
schlessera
0
560
Six Lessons from altMBA
skipperchong
29
4.1k
The Curious Case for Waylosing
cassininazir
0
190
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Rails Girls Zürich Keynote
gr2m
95
14k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
190
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
51
46k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
How to Ace a Technical Interview
jacobian
281
24k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
91
How to make the Groovebox
asonas
2
1.8k
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