ubuntu16.04上如何安装libopencv-nonfree-dev?
时间: 2023-08-10 17:09:31 浏览: 144
在Ubuntu 16.04上安装`libopencv-nonfree-dev`,您需要按照以下步骤进行操作:
1. 打开终端并更新apt-get:
```
sudo apt-get update
```
2. 安装OpenCV的依赖项:
```
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libtiff5-dev libswscale-dev libjasper-dev libopencv-dev
```
3. 安装`libopencv-nonfree-dev`:
```
sudo apt-get install libopencv-nonfree-dev
```
4. 安装完成后,您可以通过以下命令验证安装是否成功:
```
pkg-config --modversion opencv
```
如果成功安装,它将返回OpenCV安装的版本号。
相关问题
ubuntu16.04如何编译安装libopencv-nonfree
要编译安装`libopencv-nonfree`,需要先安装OpenCV。下面是Ubuntu 16.04上编译安装OpenCV和`libopencv-nonfree`的步骤:
1. 安装OpenCV的依赖项:
```
sudo apt-get update
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
```
2. 下载OpenCV源代码:
```
git clone https://github.com/opencv/opencv.git
```
3. 切换到源代码目录并创建一个构建目录:
```
cd opencv
mkdir build
cd build
```
4. 配置安装选项:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
```
5. 编译和安装OpenCV:
```
make -j4
sudo make install
```
6. 下载`libopencv-nonfree`源代码:
```
git clone https://github.com/opencv/opencv_contrib.git
```
7. 切换到源代码目录并创建一个构建目录:
```
cd opencv_contrib
mkdir build
cd build
```
8. 配置安装选项:
```
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../modules ..
```
9. 编译和安装`libopencv-nonfree`:
```
make -j4
sudo make install
```
完成后,`libopencv-nonfree` 库应该已经被安装在 `/usr/local/lib` 目录下。
阅读全文