Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV Installation improvements & fixes #53

Merged
merged 4 commits into from
Dec 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions opencvDirectInstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ execute () {
fi
}

# Executes first command passed &
# echo's it to the file passed as second argument
run_and_echo () {
eval $1
echo "$1" >> $2
}


if [[ -n $(echo $SHELL | grep "zsh") ]] ; then
SHELLRC=~/.zshrc
elif [[ -n $(echo $SHELL | grep "bash") ]] ; then
Expand All @@ -50,17 +58,16 @@ fi

execute sudo apt-get update
execute sudo apt-get install build-essential curl g++ cmake cmake-curses-gui git pkg-config checkinstall -y
execute sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev gfortran -y
execute sudo apt-get install libopenblas-dev liblapacke-dev libatlas-base-dev gfortran -y

spatialPrint "Image manipulation libraries"
execute sudo apt-get install libpng-dev libjpeg-dev libtiff5-dev zlib1g-dev libwebp-dev libopenexr-dev libgdal-dev -y

if [[ $(which python) = *"conda"* || (-n $CIINSTALL) ]] ; then
PIP="pip install" # Even though we've forced usage of bash, if conda exists, it will derive it since the parent shell is zsh/ksh/....with conda in the path
else
execute sudo apt-get install python3 python3-dev python python-dev -y
execute sudo apt-get install python3-tk python-tk -y
if [[ ! -n $CIINSTALL ]]; then sudo apt-get install python3-pip python-pip -y; fi
execute sudo apt-get install python3 python3-dev -y
if [[ ! -n $CIINSTALL ]]; then sudo apt-get install python3-pip -y; fi
PIP="sudo pip3 install"
fi
execute $PIP --upgrade numpy pip
Expand Down Expand Up @@ -90,17 +97,22 @@ if [[ ! -n $(cat $SHELLRC | grep '# ffmpeg-build-script') ]]; then
sed -i 's/execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} ./execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DBUILD_SHARED_LIBS=1 ./g' build-ffmpeg

AUTOINSTALL=yes ./build-ffmpeg --build

echo "Adding ffmpeg's libraries to LD_LIBRARY_PATH"
{
echo ""
echo "# ffmpeg-build-script"
echo "export LD_LIBRARY_PATH=$(pwd)/workspace/lib:\$LD_LIBRARY_PATH"
echo "export PKG_CONFIG_PATH=$(pwd)/workspace/lib/pkgconfig:\$(pkg-config --variable pc_path pkg-config)"
echo "export PKG_CONFIG_LIBDIR=$(pwd)/workspace/lib/:\$PKG_CONFIG_LIBDIR"

} >> $SHELLRC

run_and_echo "export LD_LIBRARY_PATH=$(pwd)/workspace/lib:\$LD_LIBRARY_PATH" $SHELLRC
run_and_echo "export PKG_CONFIG_PATH=$(pwd)/workspace/lib/pkgconfig:\$(pkg-config --variable pc_path pkg-config)" $SHELLRC
run_and_echo "export PKG_CONFIG_LIBDIR=$(pwd)/workspace/lib/:\$PKG_CONFIG_LIBDIR" $SHELLRC

# Update shell environment with the changes
if [[ ! -n $CIINSTALL ]]; then
su - $USER
fi
)
source $SHELLRC
fi

spatialPrint "GUI and openGL extensions"
Expand Down Expand Up @@ -166,9 +178,6 @@ git checkout -f $latest_tag
mkdir -p build
cd build

py2Ex=$(which python2)
py2In=$(python2 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
py2Pack=$(python2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
py3Ex=$(which python3)
py3In=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
py3Pack=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
Expand Down Expand Up @@ -198,9 +207,6 @@ fi
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D PYTHON2_EXECUTABLE="$py2Ex" \
-D PYTHON2_INCLUDE_DIR="$py2In" \
-D PYTHON2_PACKAGES_PATH="$py2Pack" \
-D PYTHON3_EXECUTABLE="$py3Ex" \
-D PYTHON3_INCLUDE_DIR="$py3In" \
-D PYTHON3_PACKAGES_PATH="$py3Pack" \
Expand Down