LoginSignup
0
0

More than 1 year has passed since last update.

Raspberry Pi 3+モバイルバッテリーでタイムラプス撮影

Posted at

概要

モバイルバッテリーで動作させたRaspberry Pi 3でタイムラプス撮影するお話です。

使ったもの

Raspberry Pi 3 Model B
Raspberry Pi カメラモジュール
Samsung microSDカード32GB EVO Plus Class10 UHS-I対応
モバイルバッテリー(cheero Power Plus 3)容量:13400mAh 出力:DC 5V/3.4A

事前にやったこと & 参考にさせていただきました!

  • Raspberry Piにカメラモジュールを接続
  • タイムラプス関連

  • Raspberry Piにxrdpをインストール

  • MonoDevelopのインストール
    Downloadのページにインストール手順の記載があります。

自分でやったこと

MonoDevelopでGUIの作成

MonoDevelopでテキトーなGUIを作成して、raspistillコマンドの各パラメータを指定できるようにしました。ついでにavconvも
timelapse01.png timelapse02.png

MainWindow.cs
using System;
using System.IO;
using System.Diagnostics;
using System.Linq;
using Gtk;

public partial class MainWindow: Gtk.Window
{   
    public MainWindow () : base (Gtk.WindowType.Toplevel)
    {
        Build ();
    }

    protected void OnDeleteEvent (object sender, DeleteEventArgs a)
    {
        Application.Quit ();
        a.RetVal = true;
    }

    protected void OnBtnShotClicked (object sender, EventArgs e)
    {
        this.btnShot.Sensitive = false;

        // See below for the raspistill command
        // https://www.raspberrypi.org/documentation/accessories/camera.html

        string m_ImagePreFix = "/home/pi/Pictures/";
        string m_ImageExtent = ".jpg";

        string Width = "-w " + this.spnShotWidth.Value.ToString();
        string Height = "-h " + this.spnShotHeight.Value.ToString();
        string Quality = "-q " + this.spnShotQuality.Value.ToString();
        string TimeOut = "-t " + (this.spnShotTimeout.Value * 60 * 1000 ).ToString();
        string Timelapse = "-tl " + (this.spnShotTimelapse.Value *1000).ToString();
        string OutPut = "-o " + m_ImagePreFix + "%d" + m_ImageExtent;
        //string Preview = "-p '0, 0, 960, 540'";
        string Preview = "-n ";
        //string Imxfx = "";    //-ifx cartoon

        string Args = string.Format("{0} {1} {2} {3} {4} {5} {6}", Width, Height, Quality, TimeOut, Timelapse, OutPut, Preview);
        ProcessStartInfo psi = new ProcessStartInfo();
        psi.FileName = "raspistill";
        psi.Arguments = Args;

        System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
        p.WaitForExit ();

        //avconv -r 20 -i %d.jpg -s '1280x800' output.mp4
        //-r 20 :フレームレート(fps)を指定
        //-i %d.jpg :連番のjpgファイルを読み込む
        //-s '1280x800' :出力フレームサイズ
        //output.mp4 :出力ファイル名

        string avFps = "-r " + this.spnAvconvFps.Value.ToString();
        string avSize = "-s '" + this.spnAvconvWidth.Value.ToString() + "x" + this.spnAvconvHeight.Value.ToString() + "'";
        string avInPut = "-i " + m_ImagePreFix + "%d.jpg";
        string avOutPut = m_ImagePreFix + "output.mp4";

        Args = string.Format("{0} {1} {2} {3}", avFps, avInPut, avSize, avOutPut);
        psi = new ProcessStartInfo();
        psi.FileName = "avconv";
        psi.Arguments = Args;

        System.Diagnostics.Process avconv = System.Diagnostics.Process.Start(psi);
        avconv.WaitForExit ();

        this.btnShot.Sensitive = true;

        //throw new NotImplementedException ();
    }
}

小学生の工作

ラズパイのカメラを固定して、モバイルバッテリーと合体させました。
rasp01.png
rasp02.png

リモート操作で撮影開始

テキトーな場所に設置してモバイルバッテリーの電源ONにします。
ラズパイが起動したころを見計らって、手持ちのAndroid端末からラズパイにリモート接続します。
rasp03.png
リモート接続にはこのアプリを使用しました。

こんな感じに撮れました

窓ガラス越しに撮影したので、カメラの赤色LEDが映り込んでしまいました。。。

0
0
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
0
0