This the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Generic linux steps

Generic linux/debian commands

Generic linux/debian commands

1 - Virtual environment python

Intro

Steps to create a virtual python environment using a specific python version (other than the version installed by default).

Steps

Install python version

Here using 3.8.4:

cd ~
mkdir tmp
cd tmp
wget https://www.python.org/ftp/python/3.8.4/Python-3.8.4.tgz
tar zxfv Python-3.8.4.tgz 
cd Python-3.8.4
./configure --prefix=$HOME/opt/python-3.8.4 --enable-loadable-sqlite-extensions
make
make install

Install virtual environment

cd ~/tmp
wget https://files.pythonhosted.org/packages/aa/9d/d7713847ff3f58801045ab2ea5d4b6cdebc4a075b2bdd086f093beb92ecf/virtualenv-20.0.27.tar.gz
tar zxfv
tar zxfv virtualenv-20.0.27.tar.gz 
cd virtualenv-20.0.27
~/opt/python-3.8.4/bin/python3.8 setup.py install

Create environment

/home/xxx/opt/python-3.8.4/bin/virtualenv -p /home/xxx/opt/python-3.8.4/bin/python3.8 envfubar

2 - Octoprint on debian

Goal

Instead of running octoprint on a raspberry pi, I run it on an old laptop that is lying around here. Below is the code to get video to work.

Setup webcam

Installation of mjpeg streamer

ssh to the device with octoprint installed.

sudo apt install git
sudo apt-get install cmake
sudo apt-get install gcc g++
sudo apt-get install libjpeg62-turbo-dev
sudo apt autoremove
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/
cd mjpg-streamer-experimental
make
sudo make install
sudo chmod 777 /dev/video0 (or whatever your device name is)

command to startup mjpeg streamer with webcam and make it accessible over http port 8080:

mjpg_streamer -i "input_uvc.so -d /dev/video0 -n" -o "output_http.so -p 8080 -w /usr/local/www"

installation of ffmpeg

easy: sudo apt install ffmpeg

To find the path of ffmpeg execute the command whereis ffmpeg, you’ll need it later in the octoprint settings.

setup in octoprint

Enter the following settings:

  • Stream url: http://192.168.0.210:8080/?action=stream
  • Snapshot url: http://192.168.0.210:8080/?action=snapshot
  • Path to FFMPEG: /usr/bin/ffmpeg (or whatever whereis ffmpeg returned)

Press the test button for each of them to see if it works.

3 - Time laps

Goal

Create timelaps of captured images

MotioneyeOs

Capture images by installing on a raspberry https://github.com/ccrisan/motioneyeos

Convert files in chronological order

Glue files together to an animated gif:

  • by renaming them in chronological order (using linux command)
  • by using ffmpeg to convert into a movie and animated gif
ls | cat -n | while read n f; do mv "$f" `printf "%04d.jpg" $n`; done
ffmpeg -r 3 -f image2 -start_number 1 -i %04d.jpg -codec:v prores -profile:v 2 output.mov
ffmpeg -i output.mov -filter_complex "[0:v] fps=12,scale=800:-1" schaduw.gif