Created
December 29, 2016 18:52
-
-
Save Samcfuchs/9cfa86c89b6c593133fa54308bdb2df6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This should build an environment for opencv code on the | |
# raspberry pi 2. Make sure that you have a working internet | |
# connection before running | |
cd ~ | |
# Install python3 | |
sudo apt-get install -y python3-dev | |
sudo apt-get install -y build-essential git cmake pkg-config | |
sudo apt-get install -y libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev | |
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev | |
sudo apt-get install -y libgtk2.0-dev | |
sudo apt-get install -y libatlas-base-dev gfortran | |
# Install pip | |
echo "INSTALLING PIP" | |
wget https://bootstrap.pypa.io/get-pip.py | |
sudo python3 get-pip.py | |
# Download opencv | |
echo "DOWNLOADING OPENCV" | |
cd ~ | |
git clone https://github.com/opencv/opencv.git | |
cd opencv | |
git checkout 3.2.0 | |
# Get extra modules | |
cd ~ | |
git clone https://github.com/opencv/opencv_contrib.git | |
cd opencv_contrib | |
git checkout 3.2.0 | |
sudo rm -rf ~/.cache/pip/ | |
sudo pip install numpy | |
sudo pip install pynetworktables | |
# Build | |
echo "BUILDING OPENCV" | |
cd ~/opencv | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_C_EXAMPLES=ON \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ | |
-D BUILD_EXAMPLES=ON .. | |
# Compile | |
echo "COMPILING OPENCV" | |
make -j4 | |
# Install | |
echo "INSTALL OPENCV" | |
sudo make install | |
sudo ldconfig | |
echo "PACKAGES:" | |
ls -l /usr/local/lib/python3.5/site-packages | |
ls -l /usr/local/lib/python3.5/dist-packages | |
#Update | |
echo "DONE! UPDATING" | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment