Upgrade to Pro — share decks privately, control downloads, hide ads and more …

South London Pioneers - Picamera

South London Pioneers - Picamera

Ben Nuttall

May 21, 2017
Tweet

More Decks by Ben Nuttall

Other Decks in Programming

Transcript

  1. Raspberry Pi camera module - 5Mpx / 8Mpx - Full

    HD - Photo & video - Command line - Python module - Infra-red camera
  2. IDLE Python Shell >>> from picamera import PiCamera >>> from

    sense_hat import SenseHat >>> camera = PiCamera() >>> sense = SenseHat() >>> sense.stick.direction_up = camera.start_preview >>> sense.stick.direction_down = camera.stop_preview
  3. Open a new file • File > New File •

    File > Save • Save as camera.py
  4. 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
  5. Add joystick code from picamera import PiCamera from sense_hat import

    SenseHat from time import sleep camera = PiCamera() sense = SenseHat() camera.start_preview() sense.stick.wait_for_event(True) sleep(3) camera.capture("/home/pi/sense.jpg") camera.stop_preview()
  6. Picamera effects import random camera.start_preview() for i in range(5): sense.stick.wait_for_event(True)

    effect = random.choice(list(camera.IMAGE_EFFECTS)) camera.image_effect = effect camera.annotate_text = effect sleep(5) camera.capture("/home/pi/{}.jpg".format(effect)) camera.stop_preview() Try more effects: - negative - colorswap - sketch - emboss