hello, world!

[라즈베리파이(RPi)] 센서 움직임 감지 시 촬영 본문

Project & Study/raspberryPi

[라즈베리파이(RPi)] 센서 움직임 감지 시 촬영

ferozsun 2020. 8. 12. 14:04

적외선 센서를 통해 움직임이 감지되면 연결된 카메라 모듈을 통해 사진이 찍힌다.

찍힌 사진은 counter 변수에 의해 번호가 매겨져 저장된다.

import RPi.GPIO as GPIO
import time
from time import sleep
from picamera import PiCamera

GPIO.setmode(GPIO.BCM)
GPIO.setup(21,GPIO.IN)

camera = PiCamera()
counter = 1

while True:
    input_state = GPIO.input(21)
    if input_state == True:
       print("Motion Detected")
       camera.start_preview()
       sleep(0.2)
       camera.capture('/home/pi/photo/%s.jpg' % counter)
       counter = counter + 1
       camera.stop_preview()
       
    else:
       print("No Detection")
    time.sleep(0.2)

이렇게 찍힌 사진에서 얼굴 정보를 뽑아내 출력시킬 것이다.


https://github.com/huunz

 

huunz

huunz has one repository available. Follow their code on GitHub.

github.com

Comments