Ubuntu20.04 安装 opencv

下载源码

https://opencv.org/releases/
官网下载
在这里插入图片描述
这里下载的是3.4.16

安装依赖项

sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev  libtiff5-dev libopenexr-dev libtbb-dev4

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libgtk-3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev pkg-config

报错解决

安装libgtk-3-dev时报错

The following packages have unmet dependencies:
libgtk-3-dev :
Depends: gir1 …

Depends: libgtk-3-0 (= 3.24.20-0ubuntu1) but 3.24.20-1 is to be installed

我用的是阿里源,可能是阿里源的版本过新,不兼容。

解决:

编辑/etc/apt/sources.list文件

在最后一行加入:

deb http://archive.ubuntu.com/ubuntu focal-updates main

运行:

sudo apt update

再次尝试安装,即可成功

编译和安装

解压压缩包

unzip opencv-3.4.16.zip

进入解压文件夹,并运行cmake

cd opencv-3.4.16
mkdir build
cd build
cmake ..

开始编译

make -j8

在这里插入图片描述

sudo make install

在这里插入图片描述
安装成功

参考:Ubuntu安装OpenCV3.4.5(两种方法&&图文详解)

GitHub 加速计划 / opencv31 / opencv
77.4 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:3 个月前 )
23fcea0d Missing include directories needed for wayland-util and xkbcommon #26563 See: #26561 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake 1 天前
03cedee0 Fixed several cases of unaligned pointer cast 3 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐