ubuntu系统配置opencv
时间: 2024-07-31 10:01:58 浏览: 121
ubuntu16.04TLS配置opencv3.4.1
在Ubuntu系统上配置OpenCV通常需要几个步骤:
1. **更新包列表并安装必要的依赖**:
```
sudo apt update && sudo apt install build-essential cmake git libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libtbb-dev libjpeg-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev python3-dev libatlas-base-dev gfortran
```
2. **下载并解压OpenCV源码**:
```
mkdir ~/opencv_build
cd ~/opencv_build
wget https://github.com/opencv/opencv/archive/refs/tags/4.x.zip
unzip 4.x.zip
mv opencv-4.x opencv
```
3. **配置OpenCV**:
```
cd opencv
mkdir -p build
cd build
cmake ..
-DCMAKE_BUILD_TYPE=RELEASE # 可选,编译模式,这里是释放模式
-DWITH_CUDA=OFF # 如果不需要CUDA支持,则设为OFF
-DWITH_CXX11=ON # 使用C++11标准
-DINSTALL_TESTS=OFF # 安装测试模块
```
4. **编译和安装**:
```
make -j$(nproc) # 并行编译,j是处理器核心数
sudo make install
```
5. **检查安装**:
```bash
pkg-config --modversion opencv
```
阅读全文