C/C++教程

centos7 cmake编译opencv+protobuf+ncnn

本文主要是介绍centos7 cmake编译opencv+protobuf+ncnn,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、opencv编译

  下载网址:Tags · opencv/opencv (github.com)

  我下载的opencv-3.4.15

  centos 终端输入:su 获取root权限;(以下所有命令皆在root权限下)

  -安装所需(参考:(27条消息) CentOS 里安装 OpenCV_whudee的博客-CSDN博客_centos opencv):

sudo yum -y install epel-release			# 安装epel扩展源
sudo yum -y install git gcc gcc-c++ cmake3
sudo yum -y install qt5-qtbase-devel
sudo yum install -y python36 python36-devel python36-pip
sudo yum install -y python python-devel python-pip
sudo yum -y install python-devel numpy python36-numpy
sudo yum -y install gtk2-devel
sudo yum install -y libpng-devel
sudo yum install -y jasper-devel
sudo yum install -y openexr-devel
sudo yum install -y libwebp-devel
sudo yum -y install libjpeg-turbo-devel 
sudo yum install -y freeglut-devel mesa-libGL mesa-libGL-devel
sudo yum -y install libtiff-devel 
sudo yum -y install libdc1394-devel
sudo yum -y install tbb-devel eigen3-devel
sudo yum -y install boost boost-thread boost-devel
sudo yum -y install libv4l-devel
sudo yum -y install gstreamer-plugins-base-devel

#=========== 安装 ffmpeg ===========
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm  https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
(可选) rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
(可选) rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
yum -y install ffmpeg ffmpeg-devel	# 安装ffmpeg依赖

  第一次安装编译没安装上面的依赖库,也编译过去了,但是后面运行程序时出错了,所以还是老老实实安装这一坨吧。

  -正式安装opencv

cd opencv-3.4.15
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .
make
make install

2、ncnn编译

    2.1 protobuf编译

    下载网址:Tags · protocolbuffers/protobuf (github.com)

    我下载的protobuf-3.4.0

    centos终端输入:

cd protobuf-3.4.0
mkdir build20220119
cd build20220119
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/protobuf -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
make
make install

    2.2 ncnn编译

  下载网址:Tags · Tencent/ncnn (github.com)

  我下载的ncnn-20211208

   centos终端输入:

cd ncnn-20211208 
mkdir -p build20220119
cd build20220119
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ncnn -DProtobuf_INCLUDE_DIR=/usr/local/protobuf/include -DProtobuf_LIBRARIES=/usr/local/protobufl/lib64/libprotobuf.a -DProtobuf_PROTOC_EXECUTABLE=/usr/local/protobuf/bin/protoc -DNCNN_VULKAN=OFF ..
make 
make install

  ok,编译完成。

 

这篇关于centos7 cmake编译opencv+protobuf+ncnn的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!