Difference between revisions of "Set-up Tutorial"

From SynWiki
Jump to navigation Jump to search
Line 38: Line 38:
 
We assume that we have a working Pi that has just logged in for the first time
 
We assume that we have a working Pi that has just logged in for the first time
  
−
The Pi will first need the timelapse folder. It will be placed in /home/pi directory
+
The Pi will first need the '''timelapse''' folder. This folder is located on Synergy Azure Devops => timelapse stream Project
 +
 
 +
It will be placed in /home/pi directory
  
 
This folder will contain the scripts to actually run the program and some testing scripts
 
This folder will contain the scripts to actually run the program and some testing scripts

Revision as of 14:41, 31 August 2022

Welcome to the First Edition of the set-up tutorial for the Time-lapse Camera

Examples:


Basic Overview

System Design Draft.png


The current System consists of 3 systems.

  1. Camera (Raspberry Pi)
  2. Server
  3. Website


The chain of events is as follows:

  1. The Camera Takes a Timelapse of Photos during the day
  2. The Camera compresses those photos into a small .mp4 video
  3. The Camera then Uploads the .mp4 video to the Server
  4. When the Server gets the uploaded video, it will stick it to the end of the current video
  5. When the Server has completed that, the video will be viewable on the WebPage

How to Set-up

Camera

Hopefully in the future there will be a Plug n' Play system where when we need another camera we can simply:

  1. Build the Camera
  2. Plug in an Image SD Card
  3. Run Basic Tests
  4. Ready to be placed (Calibration Testing may or may not also be needed)


However that's not currently the Case

Set-up scripts

We assume that we have a working Pi that has just logged in for the first time

The Pi will first need the timelapse folder. This folder is located on Synergy Azure Devops => timelapse stream Project

It will be placed in /home/pi directory

This folder will contain the scripts to actually run the program and some testing scripts

Set-up Packages

Here is a list of modules that must be installed in order for the program to work

Modules : ffmpeg, pysftp, configparser


To install them you must copy and paste the below commands into the terminal. (you can be at any directory when installing)

Links are provided above for official documentation


https://pypi.org/project/pysftp/

  =>   'pip install pysftp'

https://pypi.org/project/ffmpeg-python/

  =>   'pip install ffmpeg-python'

https://pypi.org/project/ffmpeg-python/

  =>   'pip3 install configparser'

Set-up Crontab

Crontab is a default program that allows us to automatically run a script (python file) at a certain time.

Checkout the websites below (the first one has more detail) on how to create a crontab code line

Better Generator https://crontab.guru/

Simplier Generator https://crontab-generator.com/


To edit the crontab file type this into any terminal on the pi

  =>   crontab -e


An editor will then appear (likely vim) and the following line will need to be inputted and saved

  =>   */30 8-16 * * 1-5 python3 /home/pi/timelapse/timelapse.py

After changing the crontab file, the Pi will need to be rebooted inorder for the code to take effect

You can use the GUI to Reboot the Pi or you can type

  =>   systemctl reboot

Server

Based of CentOS 7. CentOS has reached End of Life, we will need to migrate our server to Ubuntu for continuous support.

Set-up Scripts

There are 2 scripting files (as of writing this) that exist on the Server.

combine.py and watch-incoming.sh

These two files should be placed in the highest (/) directory in the server

Set-up Modules

The first module that the server needs is python3 as by default it will not include it


https://www.liquidweb.com/kb/how-to-install-python-3-on-centos-7/

  =>   yum install -y python3


Next is FFmpeg, a module used for anything video

This Link has instructions as there are a few

https://www.vultr.com/docs/how-to-install-ffmpeg-on-centos/


Next is inotify-tools

https://installati.one/centos/7/inotify-tools/

  =>   yum -y install inotify-tools


Next is glob, which is used to get all files from a Path

https://stackoverflow.com/questions/42964691/how-to-install-the-glob-module

  =>   pip3 install glob2

Set-up Files

The file structure that the server uses is whatever comes by default by the linux distribution.

Useful files will exist in the var/www/html folder

Here a couple important files will need to be added

  1. processed => where the processed main.mp4 file is stored
  2. upload => where the new time-lapse video is initially uploaded to
  3. checkfile => where a checkfile is uploaded to notify the server that the upload is complete

These files are crucial to the Systems operation and they must not be deleted


The server also uses Crontab similar to the Pi.

This time the command does not run at a given time but rather it is always running after the server reboots

  =>   @reboot sudo /watch-incoming.sh

Once again, to save implement this change, the server must be restarted with

  =>   systemctl reboot

Website

FileOverview

The video file (.mp4) that the website references comes from the upload folder which is located at

     /var/www/html/processed/main.mp4