Infra-red bird box

Infra-red bird box

Infra-red bird box activity for Scouts digital day

A1995c9abe48450ce2f82d93ca0b863f?s=128

Ben Nuttall

April 13, 2018
Tweet

Transcript

  1. Infra-red bird box camera Raspberry Pi Foundation UK Charity 1129409

  2. Raspberry Pi camera module • 5Mpx / 8Mpx • Full

    HD • Photo & video • Command line • Python module • Infra-red camera variant • 30fps @ 1080p 60fps @ 720p 90fps @ 480p
  3. Night vision camera • 5Mpx • Light sensors (LDR) •

    Infra-red LEDs • Adjustable lens focus • Compatible with official camera module
  4. Connect the camera

  5. Enable camera software

  6. Test the camera $ raspistill -k

  7. Open Thonny Python IDE

  8. Thonny Python IDE File editor – saved code Shell –

    testing code
  9. Python picamera from picamera import PiCamera from time import sleep

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

    = PiCamera() camera.rotation = 180 camera.start_preview(alpha=200) sleep(10) camera.stop_preview()
  11. 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()
  12. 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()
  13. 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()
  14. Video from picamera import PiCamera camera = PiCamera() camera.start_preview(alpha=200) camera.start_recording('/home/pi/video.h264')

    camera.wait_recording(10) camera.stop_recording() camera.stop_preview()
  15. Video playback $ omxplayer video.h264

  16. PIR Motion Sensor

  17. 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
  18. 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
  19. 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()
  20. 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()
  21. Infra-red bird box camera Raspberry Pi Foundation UK Charity 1129409