UP | HOME
Sachin Patil

Sachin Patil

Free Software Developer | GNU Emacs Hacker

[Notes] OpenCV and RPi
Published on Apr 10, 2020 by Sachin.

Install OpenCV on RPi2

System details

 1: cat /etc/os-release
 2: PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
 3: NAME="Raspbian GNU/Linux"
 4: VERSION_ID="10"
 5: VERSION="10 (buster)"
 6: VERSION_CODENAME=buster
 7: ID=raspbian
 8: ID_LIKE=debian
 9: HOME_URL="http://www.raspbian.org/"
10: SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
11: BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Update & upgrade

1: apt-get update
2: apt-get upgrade

Install required packages

 1: # Other packages
 2: apt-get install build-essential cmake pkg-config
 3: apt-get install libjpeg-dev libtiff-dev libjasper-dev libpng12-dev
 4: 
 5: apt-get install libgtk2.0-dev
 6: apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
 7: apt-get install libatlas-base-dev gfortran
 8: 
 9: apt-get install libhdf5-dev
10: apt-get install libilmbase23
11: apt-get install libilmbase-dev
12: apt-get install libopenexr-dev
13: apt-get install libqtgui4
14: apt-get install libqt4-test
15: 
16: apt-get install python3-dev      # Updated on Apr 08, 2022
17: 
18: # Install setv to manage Python virtual environments
19: curl https://gitlab.com/psachin/setV/raw/master/install.sh | sh -
20: # Create Python virtual environment
21: setv --new --python /usr/bin/python3.7 cv
22: # Activate the virtual environment
23: setv cv
24: 
25: # Install numpy & OpenCV
26: pip install numpy
27: pip install opencv-contrib-python==4.1.0.25  # https://github.com/piwheels/packages/issues/59
28: # Install bpython
29: pip install bpython

Testing

1: bpython
2: >>> import cv2
3: >>> cv2.__version__
4: '4.1.0'