Last active
July 12, 2018 17:07
-
-
Save qenops/7050d70468547d3138d040c5686d1cf5 to your computer and use it in GitHub Desktop.
Setup code for new raspberry pi including python, opencv
This file contains hidden or 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
sudo raspi-config | |
# interfacing options -> camera -> enable | |
# advanced options -> expand filesystem | |
# reboot | |
# install vim | |
sudo apt-get install vim | |
# clean up bloatware | |
sudo apt-get purge wolfram-engine | |
sudo apt-get purge libreoffice* | |
sudo apt-get clean | |
sudo apt-get autoremove | |
# make /playpen dir | |
cd / | |
sudo mkdir playpen | |
sudo chmod 777 playpen | |
cd ~ | |
# install dependancies | |
sudo apt-get update | |
sudo apt-get -y upgrade | |
sudo apt-get -y install build-essential cmake pkg-config | |
sudo apt-get -y install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev | |
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev | |
sudo apt-get -y install libxvidcore-dev libx264-dev | |
sudo apt-get -y install libgtk2.0-dev | |
sudo apt-get -y install libatlas-base-dev gfortran | |
sudo apt-get -y install python2.7-dev python3-dev | |
# Download OpenCV source | |
cd ~ | |
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.4.2.zip | |
unzip opencv.zip | |
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.2.zip | |
unzip opencv_contrib.zip | |
# install pip | |
wget https://bootstrap.pypa.io/get-pip.py | |
sudo python get-pip.py | |
# compile and install openCV | |
cd ~/opencv-3.4.2/ | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.2/modules \ | |
-D BUILD_EXAMPLES=ON .. | |
make -j4 | |
sudo make install | |
sudo ldconfig | |
# rename python3 .so | |
cd /usr/local/lib/python3.5/dist-packages/ | |
sudo mv cv2.cpython-35m-arm-linux-gnueabihf.so cv2.so | |
# install picamera | |
sudo apt-get install python3-picamera | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment