RK3588 ubuntu系统安装opencv

废话不多说直接上步骤:

  1. 先切换至root用户 sudo su 输入密码
  2. 先更新一下本地软件

apt update
apt upgrade

  1. 安装相关环境

apt install build-essential cmake git pkg-config libgtk-3-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev
gfortran openexr libatlas-base-dev python3-dev python3-numpy
libtbb2 libtbb-dev libdc1394-22-dev libopenblas-dev liblapack-dev
libprotobuf-dev protobuf-compiler libgoogle-glog-dev libgflags-dev
libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

  1. 下载opencv 源码也可以直接去官网下载 .zip的源码压缩包传到开发板解压

git clone https://github.com/opencv/opencv.git

  1. 打开刚刚解压的opencv文件夹 并创建一个build文件夹
 cd opencv
 mkdir build
  1. 进入build进行编译
  	cmake -D CMAKE_BUILD_TYPE=RELEASE \
       -D CMAKE_INSTALL_PREFIX=/usr \
       -D WITH_TBB=ON \
       -D WITH_EIGEN=ON \
       -D WITH_OPENMP=ON \
      -D OPENCV_GENERATE_PKGCONFIG=ON  ..
  1. 下载并编译相关库并
make -j 8     
make install
  1. 最后一步

pkg-config --modversion opencv4

不出意外就成功了在/usr/lib下面会有opencv相关so库 ,在/usr/include下面会有opencv4的.h头文件
如果有问题 可以把 -D CMAKE_INSTALL_PREFIX=/usr 换成 -D CMAKE_INSTALL_PREFIX=/usr/local 但是生成的so文件和头文件需要复制到/usr/lib 和/usr/include 下面去

你可能感兴趣的:(ubuntu,opencv,linux)