1.下载opencv源码
OpenCV官方源码下载链接为https://opencv.org/releases/,选择3.4.16版本下载。放在ubuntu系统\~/opencv文件夹中,解压缩,opencv文件夹中新建build和install文件夹用于存放编译文件和安装文件:
2. 安装编译工具
- 安装 cmake 和 cmake-gui 工具
sudo apt-get install cmake cmake-qt-gui cmake-curses-gui - 安装交叉编译器arm-none-linux-gnueabihf
3.安装opencv前安装环境依赖
sudo apt-get install build-essential
sudo apt-get install libopenblas-dev
sudo apt-get install git pkg-config libavcodec-dev libavformat-dev libswscale-dev
处理图像所需的包
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
处理视频所需的包
sudo apt-get install libxvidcore-dev libx264-dev
优化opencv功能
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install ffmpeg
4. 编译
进入build文件夹
命令cmake-gui
执行完成后会出现图形化工具 cmake-gui
问题汇总:
问题1:
/arm-none-linux-gnueabihf/libc/usr/include/features.h:311:52: error: operator '&&' has no right operand
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
解决:
在#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64前面 加上
#define _FILE_OFFSET_BITS 64
问题2
若出现recipt target for all failed
解决:
继续执行刚刚的make指令就跳过了