ubuntu 16.04 install opencv 3.4.1
时间: 2023-09-07 07:05:01 浏览: 173
要在Ubuntu 16.04上安装OpenCV 3.4.1,可以按照以下步骤进行操作:
1. 打开终端并更新软件包列表:
```
sudo apt-get update
```
2. 安装必要的依赖项:
```
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
```
3. 下载OpenCV 3.4.1:
```
cd ~
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.1.zip
unzip opencv.zip
```
4. 下载OpenCV的额外模块:
```
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.1.zip
unzip opencv_contrib.zip
```
5. 安装Python开发包:
```
sudo apt-get install python-dev python-numpy python3-dev python3-numpy
```
6. 创建构建目录并进行编译:
```
cd ~/opencv-3.4.1
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.1/modules ..
make -j4
```
7. 安装OpenCV到系统:
```
sudo make install
```
8. 配置OpenCV:
```
sudo ldconfig
```
完成这些步骤后,OpenCV 3.4.1就会成功安装在Ubuntu 16.04上。您可以通过导入`import cv2`来确认OpenCV是否正确安装。
阅读全文