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
320
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
390
Live Highlights in BBC iPlayer
bennuttall
0
110
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
170
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
110
Running a Python Package Index for Raspberry Pi
bennuttall
0
150
From Acorns to Raspberries
bennuttall
0
120
Innovation in the newsroom
bennuttall
0
140
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
190
How to market your open source project
bennuttall
0
240
Other Decks in Programming
See All in Programming
Cloudflare AgentsとAI SDKでAIエージェントを作ってみた
briete
0
140
CSC509 Lecture 04
javiergs
PRO
0
300
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
160
CSC509 Lecture 05
javiergs
PRO
0
300
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
210
overlayPreferenceValue で実現する ピュア SwiftUI な AdMob ネイティブ広告
uhucream
0
180
CI_CD「健康診断」のススメ。現場でのボトルネック特定から、健康診断を通じた組織的な改善手法
teamlab
PRO
0
200
All About Angular's New Signal Forms
manfredsteyer
PRO
0
110
チームの境界をブチ抜いていけ
tokai235
0
160
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
240
Flutterで分数(Fraction)を表示する方法
koukimiura
0
130
(Extension DC 2025) Actor境界を越える技術
teamhimeh
1
250
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Being A Developer After 40
akosma
91
590k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
4 Signs Your Business is Dying
shpigford
185
22k
Why Our Code Smells
bkeepers
PRO
339
57k
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