Skip to content

Instantly share code, notes, and snippets.

@edharman
Last active February 24, 2022 17:38
Show Gist options
  • Save edharman/dc8dc37d5f9216c97c345c6b0abab251 to your computer and use it in GitHub Desktop.
Save edharman/dc8dc37d5f9216c97c345c6b0abab251 to your computer and use it in GitHub Desktop.
GMN RMS install scripts for Linux
Copy and save both install.sh and opencv4_install.sh to your home directory ~/
make them executable -
chmod +x *.sh
You may wish to edit the opencv4_install.sh to reflect any additional components you may wish to configure e.g. GPU options.
As-is this should work ok if you have an Intel Iris enabled CPU, if you use Nvidia you'll have to google for specific instructions.
Also you can optimise the number of threads used for the compilation by adjusting the line -
make -j4
to -
make -j<number of threads>
I tested this on a cloud version of Ubuntu 20.4.2 LTS (multipass) running under Hyper-V on my windows desktop and with
10 cores configured the total installation time was ~27 mins.
YMMV wrt total time since it's dependant on cpu clock speed, # cores/threads and disk speed...
The multipass Ubuntu instance is a server variant since I prefer to use headless, however a desktop variant will work just as well with
no differences to the install procedure.
Note: install.sh at some point downloads opencv which includes an opencv4_install.sh that is not optimised for a non-Pi platform.
This script then copies the customised version from your home directory into the opencv env before executing it.
execute ./install.sh
...you will be prompted for your sudo password
At some point you will be prompted to agree to the terms of the EULA when the truetypefonts are installed
If running headless you will need to play with the network settings if you wish to use any graphical apps since these multipass
versions are designed for cloud based deployments and thus are optimised for security with ssh key based authentication enforced
by default and nopassword enabled.
(happy to document this network trickery if it's felt worthwhile, it's not terribly complicated but is 'down in the weeds' for most users..)
Once the script completes -
edit ./config to reflect your stations details, device string options below -
# using gstreamer with VAAPI GPU acceleration (to enable VAAPI I followed these instructions -
http://lifestyletransfer.com/how-to-install-gstreamer-vaapi-plugins-on-ubuntu/)
device: rtspsrc location=rtsp://192.168.0.150:554/user=admin&password=&channel=1&stream=0.sdp ! rtpjitterbuffer ! rtph264depay ! h264parse ! vaapidecodebin ! videoconvert ! appsink
# Alternatively using FFMPEG with no hardware acceleration
device: rtsp://<camera-ip>:554/user=admin&password=&channel=1&stream=0.sdp
..on my host I find the latter consumes less resources even though it isn't using the GPU
To test the installation on a desktop install launch ShowLiveStream
If you are running headless and have X forwarding enabled (i.e. the $DISPLAY variable is correctly set)
At a shell prompt
$ source vRMS/bin/activate
(vRMS) <user@hostname:> cd source/RMS
(vRMS) <user@hostname:> python -m Utils.ShowLiveStream
and after a short while during which Cython will check that it is up to date you should see a new window open showing the livestream.
To start the RMS capture from the shell I use the following -
nohup ./Scripts/RMS_StartCapture.sh &> /dev/null &
This redirects both stdout and stderr to /dev/null and backgrounds the entire process so that the process will still run after
the terminal session is closed.
#!/usr/bin/bash
# Debian 11 Bullseye version only....
mkdir source
cd source
sudo apt-get install -y git
git clone https://github.com/CroatianMeteorNetwork/RMS.git
sudo apt-get update
sudo apt-get -y upgrade
if grep -Fq Debian /etc/issue; then
sudo apt-get install -y python3-tk
wget http://ftp.br.debian.org/debian/pool/main/x/xcb-util/libxcb-util1_0.4.0-1+b1_amd64.deb
sudo dpkg -i libxcb-util1_0.4.0-1+b1_amd64.deb
elif grep -Fq Ubuntu /etc/issue; then
sudo apt-get install -y python3.8-tk
fi
sudo apt-get install -y git mplayer python3 python3-dev python3-pip libblas-dev libatlas-base-dev \
liblapack-dev at-spi2-core libopencv-dev python3-pil.imagetk libffi-dev libssl-dev socat ntp \
libxml2-dev libxslt1-dev imagemagick ffmpeg cmake unzip
sudo pip3 install --upgrade pip
sudo pip3 install virtualenv
cd ~
virtualenv vRMS
source ~/vRMS/bin/activate
pip install -U pip setuptools
pip install numpy
pip install Pillow
pip install gitpython scipy cython pyephem astropy paramiko
pip install matplotlib
pip install imreg_dft
pip install configparser
pip install imageio
pip install pyfits
pip install PyQt5
cd ~/source/RMS
cp ~/opencv4_install.sh .
./opencv4_install.sh ~/vRMS
cd ~/source
sudo apt install -y gstreamer1.0*
sudo apt install -y gstreamer1.0-python3-dbg-plugin-loader
sudo apt install -y gstreamer1.0-python3-plugin-loader
sudo apt install -y ubuntu-restricted-extras
sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
git clone https://github.com/opencv/opencv.git
cd opencv/
git checkout 4.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D WITH_GSTREAMER=ON \
-D BUILD_EXAMPLES=ON ..
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON
sudo make -j$(nproc)
sudo make install
sudo ldconfig
cd ~/source/RMS
python setup.py install
sudo apt install -y gstreamer1.0-plugins-good python3-pyqt5
git clone https://github.com/CroatianMeteorNetwork/cmn_binviewer.git
mv cmn_binviewer/ ../
./Scripts/GenerateDesktopLinks.sh # add desktop links
#!/usr/bin/bash
mkdir source
cd source
sudo apt-get install -y git
git clone https://github.com/CroatianMeteorNetwork/RMS.git
sudo apt-get update
sudo apt-get -y upgrade
if grep -Fq Debian /etc/issue; then
sudo apt-get install -y python3-tk
wget http://ftp.br.debian.org/debian/pool/main/x/xcb-util/libxcb-util1_0.4.0-1+b1_amd64.deb
sudo dpkg -i libxcb-util1_0.4.0-1+b1_amd64.deb
elif grep -Fq Ubuntu /etc/issue; then
sudo apt-get install -y python3.8-tk
fi
sudo apt-get install -y git mplayer python3 python3-dev python3-pip libblas-dev libatlas-base-dev \
liblapack-dev at-spi2-core libopencv-dev python-imaging-tk libffi-dev libssl-dev socat ntp \
libxml2-dev libxslt-dev imagemagick ffmpeg cmake unzip
sudo pip3 install --upgrade pip
sudo pip3 install virtualenv
cd ~
virtualenv vRMS
source ~/vRMS/bin/activate
pip install -U pip setuptools
pip install numpy
pip install Pillow
pip install gitpython scipy cython pyephem astropy paramiko
pip install matplotlib
pip install imreg_dft
pip install configparser
pip install imageio
pip install pyfits
pip install PyQt5
cd ~/source/RMS
cp ~/opencv4_install.sh .
./opencv4_install.sh ~/vRMS
cd ~/source
sudo apt install -y gstreamer1.0*
sudo apt install -y gstreamer1.0-python3-dbg-plugin-loader
sudo apt install -y gstreamer1.0-python3-plugin-loader
sudo apt install -y ubuntu-restricted-extras
sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
git clone https://github.com/opencv/opencv.git
cd opencv/
git checkout 4.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D WITH_GSTREAMER=ON \
-D BUILD_EXAMPLES=ON ..
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON
sudo make -j$(nproc)
sudo make install
sudo ldconfig
cd ~/source/RMS
python setup.py install
sudo apt install -y gstreamer1.0-plugins-good python3-pyqt5
git clone https://github.com/CroatianMeteorNetwork/cmn_binviewer.git
mv cmn_binviewer/ ../
#!/bin/sh
if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then
echo "Usage: $0 VIRTUALENV_PATH" >&2
exit 1
fi
# The script takes the path to the virtual environment directory as the argument
# Configuration
HOME_DIR=$HOME
VERSION=4.1.2
# Installation
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y build-essential cmake pkg-config
sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libxvidcore-dev libx264-dev
sudo apt-get install -y gstreamer1.0-tools
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y libgtk-3-dev
sudo apt-get install -y libatlas-base-dev gfortran
cd ${HOME_DIR}
wget -O opencv.zip https://github.com/Itseez/opencv/archive/${VERSION}.zip
unzip -o opencv.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/${VERSION}.zip
unzip -o opencv_contrib.zip
cd ${HOME_DIR}/opencv-${VERSION}/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=DEBUG \
-D CMAKE_INSTALL_PREFIX=${1} \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=${HOME_DIR}/opencv_contrib-${VERSION}/modules \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D WITH_opencv_python3=ON \
-D HAVE_opencv_python2=OFF \
-D WITH_OPENMP=ON \
-D BUILD_TIFF=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D BUILD_TESTS=OFF \
-D WITH_EIGEN=OFF \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_VTK=OFF \
-D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D BUILD_opencv_python3=TRUE \
-D WITH_GSTREAMER=ON \
-D WITH_FFMPEG=ON ..
# Check output cmake, it should include python 2
# For more information check: http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
make -j4
sudo make install
sudo ldconfig
cd ${HOME_DIR}
rm -rf opencv-${VERSION} opencv_contrib-${VERSION} opencv.zip opencv_contrib.zip
@edharman
Copy link
Author

edharman commented Feb 21, 2021

If using an Intel GMA/Iris enabled CPU and you want to use GPU acceleration you may find that the output of
gst-inspect-1.0 vaapi
returns the driver installed but no plugins enabled.
This is likely due to a permissions issue with renderD128 -

`ls -l /dev/dri

total 0

drwxr-xr-x 2 root root 80 Jan 19 15:24 by-path

crw-rw---- 1 root video 226, 0 Jan 22 18:28 card0

crw-rw---- 1 root render 226, 128 Jan 22 18:28 renderD128`

Workaround is to add that group to the current user -
usermod -a -G render <username>
log out and log in again for the change to be reflected in your new session and you should now see the plugins -
`gst-inspect-1.0 vaapi
Plugin Details:
Name vaapi
Description VA-API based elements
Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
Version 1.18.0
License LGPL
Source module gstreamer-vaapi
Source release date 2020-09-08
Binary package gstreamer-vaapi
Origin URL https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues

vaapijpegdec: VA-API JPEG decoder
vaapimpeg2dec: VA-API MPEG2 decoder
vaapih264dec: VA-API H264 decoder
vaapivc1dec: VA-API VC1 decoder
vaapipostproc: VA-API video postprocessing
vaapidecodebin: VA-API Decode Bin
vaapisink: VA-API sink
vaapimpeg2enc: VA-API MPEG-2 encoder
vaapih264enc: VA-API H264 encoder`

You should then be able to use vaapidecodebin instead of decodebin in the device configuration line of the RMS .config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment