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

Infra-red bird box

Infra-red bird box

Infra-red bird box activity for Scouts digital day

Ben Nuttall

April 13, 2018
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 variant • 30fps @ 1080p 60fps @ 720p 90fps @ 480p
  2. Night vision camera • 5Mpx • Light sensors (LDR) •

    Infra-red LEDs • Adjustable lens focus • Compatible with official camera module
  3. Python picamera from picamera import PiCamera from time import sleep

    camera = PiCamera() camera.start_preview(alpha=200) sleep(10) camera.stop_preview()
  4. Rotation from picamera import PiCamera from time import sleep camera

    = PiCamera() camera.rotation = 180 camera.start_preview(alpha=200) sleep(10) camera.stop_preview()
  5. Still images from picamera import PiCamera from time import sleep

    camera = PiCamera() camera.start_preview(alpha=200) sleep(5) camera.capture('/home/pi/Desktop/image.jpg') camera.stop_preview()
  6. Text annotation from picamera import PiCamera from time import sleep

    camera = PiCamera() camera.start_preview(alpha=200) camera.annotate_text = "Hello world" sleep(5) camera.capture('/home/pi/Desktop/image.jpg') camera.stop_preview()
  7. Multiple capture from picamera import PiCamera from time import sleep

    camera = PiCamera() camera.start_preview(alpha=200) for i in range(5): sleep(5) camera.capture('/home/pi/Desktop/image{}.jpg'.format(i)) camera.stop_preview()
  8. Motion sensor from picamera import PiCamera from gpiozero import MotionSensor

    camera = PiCamera() pir = MotionSensor(4) pir.when_motion = camera.start_preview pir.when_no_motion = camera.stop_preview
  9. Motion sensor photo trigger from picamera import PiCamera from gpiozero

    import MotionSensor from datetime import datetime def capture(): timestamp = datetime.now().isoformat() camera.capture('/home/pi/{}.jpg'.format(timestamp)) camera = PiCamera() pir = MotionSensor(4) pir.when_motion = capture
  10. Motion sensor video trigger from picamera import PiCamera from gpiozero

    import MotionSensor from datetime import datetime camera = PiCamera() pir = MotionSensor(4) while True: if pir.motion_detected: camera.start_preview(alpha=200) timestamp = datetime.now().isoformat() camera.start_recording('/home/pi/{}.h264'.format(timestamp)) camera.wait_recording(10) camera.stop_recording() camera.stop_preview()
  11. Circular stream video from picamera import PiCamera, PiCameraCircularIO from gpiozero

    import MotionSensor camera = PiCamera() pir = MotionSensor(4) stream = PiCameraCircularIO(camera, seconds=20) camera.start_recording(stream, format='h264') try: while True: camera.wait_recording(1) if pir.motion_detected: camera.wait_recording(10) stream.copy_to('motion.h264') finally: camera.stop_recording()