Skip to content

Instantly share code, notes, and snippets.

@gaborvecsei
Last active January 24, 2023 19:52
Show Gist options
  • Save gaborvecsei/ad216f214731441bd66a34ae9a2dc3f3 to your computer and use it in GitHub Desktop.
Save gaborvecsei/ad216f214731441bd66a34ae9a2dc3f3 to your computer and use it in GitHub Desktop.
Install OpenCV easily on your Raspberry Pi 3 B
mkdir opencv
cd opencv
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install build-essential cmake pkg-config -y
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libgtk2.0-dev libgtk-3-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
sudo apt-get install python2.7-dev python3-dev -y
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.1.zip
unzip opencv.zip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python3 get-pip.py
sudo pip install numpy
cd opencv-3.3.1
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j2
sudo make install
sudo ldconfig
sudo find /usr/local/lib -type f -name "cv2.*.so" -exec sh -c 'x="{}"; echo mv "$x" "$(dirname ${x})/cv2.so"' \;
echo "OpenCV is successfully installed"
@impskil
Copy link

impskil commented Dec 16, 2017

Hi,
in line 1 : mkdir opencv

@mikeymp
Copy link

mikeymp commented Jun 9, 2019

make sure you fix line one before install. This works perfect on raspi-3b thanks for an easy way to get Opencv.

@gaborvecsei
Copy link
Author

@impskil, @mikeymp, Thank you, I updated the gist!

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