ubuntu安装opencv3.4.6
时间: 2023-11-09 22:49:29 浏览: 129
可以按照以下步骤在Ubuntu上安装OpenCV 3.4.6:
1. 安装依赖项:
```shell
sudo apt-get update
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
```
2. 下载OpenCV 3.4.6源代码:
```shell
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.6.zip
unzip opencv.zip
```
3. 编译安装OpenCV 3.4.6:
```shell
cd opencv-3.4.6
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install
```
其中,`-j4`参数表示使用4个CPU核心进行编译。
4. 配置OpenCV库文件路径:
将以下代码添加到`~/.bashrc`文件中:
```shell
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
```
保存文件并执行以下命令使配置生效:
```shell
source ~/.bashrc
```
现在,你已经成功在Ubuntu上安装了OpenCV 3.4.6。可以使用以下命令验证安装是否成功:
```shell
pkg-config --modversion opencv
```
如果输出的版本号为3.4.6,则说明安装成功。
阅读全文