Ubuntu 16.04 LTS OpenCV C / C++ and Python interface (接口)
- Install OpenCV from the Ubuntu Repository (apt) - Python 调用接口
Python3
sudo apt update
sudo apt install python3-opencv
1
2
Python2
sudo apt update
sudo apt install python-opencv
1
2
OpenCV version
python3 -c “import cv2; print(cv2.version)”
python2 -c “import cv2; print(cv2.version)”
1
2
Uninstall OpenCV
sudo apt remove python3-opencv -y
sudo apt remove python-opencv -y
1
2
2. Install OpenCV from the Ubuntu Repository (pip) - Python 调用接口
Python3
sudo apt update
sudo pip3 install opencv-python
sudo pip3 install opencv-contrib-python
sudo pip3 install opencv-python4.2.0.32
sudo pip3 install opencv-contrib-python4.2.0.32
sudo pip3 install -i https://pypi.douban.com/simple opencv-python3.4.1.15
sudo pip3 install -i https://pypi.douban.com/simple opencv-contrib-python3.4.1.15
1
2
3
4
5
6
7
8
9
Python2
sudo apt update
sudo pip2 install opencv-python
sudo pip2 install opencv-contrib-python
sudo pip2 install opencv-python4.2.0.32
sudo pip2 install opencv-contrib-python4.2.0.32
sudo pip2 install -i https://pypi.douban.com/simple opencv-python3.4.1.15
sudo pip2 install -i https://pypi.douban.com/simple opencv-contrib-python3.4.1.15
1
2
3
4
5
6
7
8
9
OpenCV version
python3 -c “import cv2; print(cv2.version)”
python2 -c “import cv2; print(cv2.version)”
1
2
Uninstall OpenCV
sudo pip3 uninstall opencv-python
sudo pip3 uninstall opencv-contrib-python
sudo pip2 uninstall opencv-python
sudo pip2 uninstall opencv-contrib-python
1
2
3
4
5
3. Install OpenCV from the Ubuntu Repository (pip) - C / C++ 调用接口 (OpenCV 2.4.9.1)
Install OpenCV
sudo apt-get update
sudo apt-get install libopencv-dev -y
1
2
Uninstall OpenCV
sudo apt-get autoremove libopencv-dev
1
OpenCV version
pkg-config --modversion opencv
1
4. Install OpenCV 4 from the official site - C / C++ 调用接口 (OpenCV 4.2.0)
Install OpenCV
https://blog.csdn.net/chengyq116/article/details/104297224
bash install-opencv.sh
1
OpenCV version
pkg-config --modversion opencv4
1
Uninstall OpenCV
进入 …/OpenCV/build/ 目录,执行 sudo make uninstall。