https://neosarchizo.gitbooks.io/raspberrypiforsejonguniv/content/chapter4.html
프리뷰 보기
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
sleep(10)
camera.stop_preview()
- 다음을 입력해 camera.py를 실행한다. 실행하면 10초간 프리뷰가 뜨는 것을 볼 수 있다.
python camera.py
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 180
camera.start_preview()
sleep(10)
camera.stop_preview()
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview(alpha=200)
sleep(10)
camera.stop_preview()
사진
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
sleep(5)
camera.capture('/home/pi/image.jpg')
camera.stop_preview()
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
for i in range(5):
sleep(5)
camera.capture('/home/pi/image%s.jpg' % i)
camera.stop_preview()
비디오
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.start_recording('/home/pi/video.h264')
sleep(10)
camera.stop_recording()
camera.stop_preview()
효과
해상도
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.resolution = (2592, 1944)
camera.framerate = 15
camera.start_preview()
sleep(5)
camera.capture('/home/pi/max.jpg')
camera.stop_preview()
글자 표시
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.annotate_text = "Hello world!"
sleep(5)
camera.capture('/home/pi/Desktop/text.jpg')
camera.stop_preview()
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.annotate_text_size = 50
camera.annotate_text = "Hello world!"
sleep(5)
camera.capture('/home/pi/Desktop/text.jpg')
camera.stop_preview()
-
from picamera import PiCamera, Color
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.annotate_background = Color('blue')
camera.annotate_foreground = Color('yellow')
camera.annotate_text = " Hello world "
sleep(5)
camera.capture('/home/pi/Desktop/text.jpg')
camera.stop_preview()
밝기
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.brightness = 70
sleep(5)
camera.capture('/home/pi/bright.jpg')
camera.stop_preview()
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
for i in range(100):
camera.annotate_text = "Brightness: %s" % i
camera.brightness = i
sleep(0.1)
camera.stop_preview()
대비
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
for i in range(100):
camera.annotate_text = "Contrast: %s" % i
camera.contrast = i
sleep(0.1)
camera.stop_preview()
이미지 효과
none, negative, solarize, sketch, denoise,
emboss, oilpaint, hatch, gpen, pastel,
watercolor, film, blur, saturation, colorswap,
washedout, posterise, colorpoint, colorbalance,
cartoon, deinterlace1, deinterlace2
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.image_effect = 'colorswap'
sleep(5)
camera.stop_preview()
-
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
for effect in camera.IMAGE_EFFECTS:
camera.image_effect = effect
camera.annotate_text = "Effect: %s" % effect
sleep(5)
camera.stop_preview()
자동 화이트밸런스
off, auto, sunlight, cloudy, shade, tungsten,
fluorescent, incandescent, flash, horizon
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.awb_mode = 'sunlight'
sleep(5)
camera.capture('/home/pi/sunlight.jpg')
camera.stop_preview()
노출
off, auto, night, nightpreview, backlight,
spotlight, sports, snow, beach, verylong,
fixedfps, antishake, fireworks
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.exposure_mode = 'beach'
sleep(5)
camera.capture('/home/pi/beach.jpg')
camera.stop_preview()