캡쳐/비디오 전송
캡쳐 - 스틸 이미지
비디오 - 연속적인 이미지, 동영상
캡쳐 전송
python Flask와 picamera의 이미지 캡쳐를 활용하여http://라즈베리파이주소:5000/capture
주소를 입력하면 캡쳐된 이미지가 웹 브라우져에 나타날 수 있도록 만든다.
두 가지 방법으로 구현이 가능한데, 두 가지 모두 해볼 것!
1) 해당 URL 요청이 올 때마다 캡쳐하기
2) 주기적으로 캡쳐하는 프로그램을 만들고, 해당 URL 요청이 오면 미리 캡쳐된 화면을 전송하기
참고:
picamera 캡쳐https://picamera.readthedocs.io/en/release-1.12/recipes1.html#capturing-to-a-file
Flask
http://flask.pocoo.org/docs/0.11/quickstart/
지난 학기 Flask 강의 자료:
http://jylecture.blogspot.kr/2016/05/os-519-python-flask-web-framework.html
비디오 전송
https://picamera.readthedocs.io/en/release-1.12/recipes1.html#recording-to-a-network-stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import time | |
import picamera | |
camera = picamera.PiCamera() | |
camera.resolution = (640, 480) | |
camera.framerate = 24 | |
server_socket = socket.socket() | |
server_socket.bind(('0.0.0.0', 8000)) | |
server_socket.listen(0) | |
# Accept a single connection and make a file-like object out of it | |
connection = server_socket.accept()[0].makefile('wb') | |
try: | |
camera.start_recording(connection, format='h264') | |
camera.wait_recording(60) | |
camera.stop_recording() | |
finally: | |
connection.close() | |
server_socket.close() |
vlc tcp/h264://my_pi_address:8000/
* 위와는 완전 다른 방법으로 웹 브라우져로 보는 예제(시간 남으면 해볼 것)
https://github.com/waveform80/pistreaming