찐s/Raspberry Pi
[RPi] Lab.04-4: piCamera
jjin bbang
2020. 12. 13. 22:10
[RPi] Lab.01-3: GPIO 실습에 이어 DE2-115 보드에서 라즈베리파이 카메라를 제어를 실습한다
[GPIO test]
[RPi]
[gpio_capture.py]
#####gpio_capture.py-------------------------#####
import RPi.GPIO as gpio
from time import sleep
import picamera
gpio4 = 23
gpio.setmode(gpio.BCM)
gpio.setup(gpio4, gpio.IN)
#####----------------------------------------#####
camera = picamera.PiCamera()
n = 0
print('Push Button')
try:
while True:
if gpio.input(gpio4) == 0:
camera.resolution = (399,300)
camera.start_preview()
sleep(0)
camera.stop_preview()
camera.capture('image'+str(n)+'.jpg')
print('image'+str(n)+'.jpg')
n = n+1
sleep(1)
except KeyboardInterrupt:
gpio.cleanup()
camera.close()
[Test Result]
회로를 구성하고 터미널 gpio_capture.py 를 실행하고 DE2-115 보드의 푸쉬 버튼을 누르면 라즈베리파이에 사진(image.jpg) 이 저장 됨을 알수 있다.
$ python3 gpio_capture.py
![]() |
![]() |
[참조]
반응형