Camera Explorer


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]:
{u'blur': 15,
 u'cartoon': 22,
 u'colorbalance': 21,
 u'colorpoint': 20,
 u'colorswap': 17,
 u'deinterlace1': 23,
 u'deinterlace2': 24,
 u'denoise': 7,
 u'emboss': 8,
 u'film': 14,
 u'gpen': 11,
 u'hatch': 10,
 u'negative': 1,
 u'none': 0,
 u'oilpaint': 9,
 u'pastel': 12,
 u'posterise': 19,
 u'saturation': 16,
 u'sketch': 6,
 u'solarize': 2,
 u'washedout': 18,
 u'watercolor': 13}

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 [ ]: