본문으로 바로가기
 

3. Quick Start — Picamera 1.10 documentation

© Copyright 2013,2014 Dave Jones. Revision 6f36295e.

picamera.readthedocs.io

picamera

  • picamera 는 Python 2.7 이상, Python 3.2 이상의  Raspberry Pi 카메라 모듈에 대한 Python 인터페이스를 제공한다.

 

사진 찍기

사진을 찍을 때는 caputre() 를 사용합니다.

 

기본적으로 카메라 모듈은 원하는 방향으로 찍기가 힘든 형태입니다. 

이렇게 생겼습니다.jpg

 

회전할 때는 rotation 속성을 사용하면 됩니다. (default rotation 속성값은 0)

180은 180회전을 의미합니다.

import time
import picamera

with picamera.PiCamera() as camera:
    camera.start_preview()
    time.sleep(10)
    print(camera.rotation)
    camera.rotation = 180
    camera.capture('jvvp.jpg')
    camera.stop_preview()
0

 

 

동영상 찍기

start_recording(), stop_recording() 으로 시작과 중지할 수 있습니다.

wait_recording() 은 기록 중, 디스크 공간 부족 등의 사항에 대해 예외를 발생합니다.

import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.start_preview()
    camera.rotation = 180
    camera.start_recording('jvvp.h264')
    camera.wait_recording(60)
    camera.stop_recording()
    camera.stop_preview()

 

h264mp4 로 변환

pi@raspberrypi:~/venv_dev/work/camera $ MP4Box -add jvvp.h264 jvvp.mp4
AVC-H264 import - frame size 640 x 480 at 25.000 FPS
AVC Import results: 1796 samples - Slices: 30 I 1766 P 0 B - 0 SEI - 30 IDR
Saving to jvvp.mp4: 0.500 secs Interleaving