6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

定点カメラで撮影した映像をつなげて動画を作成してみた

Last updated at Posted at 2018-06-28

はじめに

バッテリーとソーラーパネル、Raspberry Pi、USBカメラを使って植物を観察するサービスを開発しているのですが、一定間隔で収集される写真の使い道を検討した結果、動画にしてみようということになって試した結果をまとめます。

完成動画

IMAGE ALT TEXT HERE

前提条件

  1. 記録の画像はJPEGで、拡張子は「jpg」
  2. 画像は一つのフォルダにまとめて保存
  3. 動画生成用スクリプトも画像と同じフォルダに保存
  4. 出力ファイルは「output.mp4」

スクリプト作成・実行

PythonでOpenCVを使用します。

make_mp4.py
import glob
import cv2

files = glob.glob('./*.jpg')
files.sort()

FILE_NAME = "output.mp4"
FRAME_RATE = 10
FRAME_SIZE = (1280, 720)

rec = cv2.VideoWriter(FILE_NAME, cv2.VideoWriter_fourcc(*'XVID'), FRAME_RATE, FRAME_SIZE, True)

for file in files:
	print(file)
	img = cv2.imread(file)
	rec.write(img)
	
rec.release()

作成したら以下のコマンドで実行。

python3 make_mp4.py

以上、めでたし、めでたし(^-^)

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?