【RK3588-linux开发】2、编译安装opemcv\opencv_contrib

按照步骤来一步通过!!!
1. 环境准备

sudo apt-get update
sudo apt-get install build-essential -y
sudo apt-get install cmake git libavcodec-dev libavformat-dev -y
sudo apt-get update
sudo apt-get install libgtk2.0-dev libswscale-dev libopenexr-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install python-dev-is-python3 python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev

添加源:

sudo gedit /etc/apt/sources.list

(文件末尾添加)

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe

sudo apt-get update
sudo apt-get install libjasper1 libjasper-dev libdc1394-22-dev 

2. 下载opencv4.1.0\opencv_contrib4.1.0
可以直接下载添加了 .i 文件的压缩包
3. 编译

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4.1.0 \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON ..

make -j6

报错信息:

[ 94%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o
/home/firefly/opencv_build/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp:51:10: fatal error: features2d/test/test_detectors_regression.impl.hpp: No such file or directory
51 | #include “features2d/test/test_detectors_regression.impl.hpp”
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

解决:

cp -r ~/opencv_build/opencv/modules/features2d/ ~/opencv_build/opencv/build/

继续make

make -j6
sudo make install

4. 写入环境变量

sudo gedit ~/.bashrc
添加:
		export PKG_CONFIG_PATH=/usr/local/opencv4.1.0/lib/pkgconfig
		export LD_LIBRARY_PATH=/usr/local/opencv4.1.0/lib 
source ~/.bashrc

5. 测试

pkg-config --modversion opencv4


$firefly@firefly:~/opencv_build/opencv/samples/cpp/example_cmake$
cmake .
make 
./opencv_example
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值