In [1]:
from picamera import PiCamera, Color
from time import sleep
camera = PiCamera()
Set the camera to take a bit smaller photos (lower resolution). This will make our image processing a bit faster.
In [2]:
camera.resolution = (480, 320)
camera.vflip = True
camera.hflip = True
In [3]:
camera.start_preview()
camera.annotate_foreground = Color('white')
camera.annotate_text = "Colorswap Effect"
camera.annotate_text_size = 10
camera.image_effect = 'colorswap'
sleep(2)
camera.capture('img/colorswap.jpg')
camera.stop_preview()
One can see all the available effects by listing the camera EFFECTS
In [4]:
camera.IMAGE_EFFECTS
Out[4]:
Let's just loop through some interesting ones:
In [5]:
camera.start_preview()
sleep(2)
cool_effects = ['none', 'watercolor', 'negative', 'emboss', 'washedout', 'solarize', 'oilpaint', 'sketch']
for effect in cool_effects:
camera.image_effect = effect
camera.annotate_text = "Effect: %s" % effect
camera.capture('img/effect-%s.jpg' % effect)
sleep(1)
camera.stop_preview()
Let's grab a few more photos to do some work on. Try to move in the frame as these are taken.
In [ ]:
camera.start_preview()
sleep(2)
camera.image_effect = 'none'
camera.annotate_text = ""
for i in range(3):
camera.capture('img/frame-%s.jpg' % i)
sleep(2)
camera.stop_preview()
Now we'll clean up our camera object...
In [6]:
camera.close()
In [ ]: