Article Directory
foreword
I get .bin+.param files in windows environment, and then complete the work of ncnn on Linux compilation and deployment
win, please refer to:
**ncnn deployment preparation: **Similar to Android deployment, ncnn needs to install ncnn+protobuf+opencv in Linux environment.
Reference: https://blog.csdn.net/shanglianlm/article/details/103188992/
1. Install g++ gcc
The meta package is a package that contains many compilation-related packages. Of course, you can also install g++ gcc separately
方法1:
sudo apt-get install build-essential
方法2:
sudo apt-get install g++
sudo apt-get install gcc
2. Install cmake
CMake is a cross-platform, open-source build tool. In short, it is a necessary tool for compiling projects.
方法1:
sudo apt-get install cmake
方法2:
# 下载地址: https://cmake.org/
tar -xvf cmake-3.24.0-rc1.tar.gz
chmod -R 777 cmake-3.24.0-rc1
cd cmake-3.24.0-rc1
sudo ./bootstrap
sudo make
sudo make install
#安装成功查看cmake版本:
cmake --version
3. Install protobuf
Install the automake tool
sudo apt-get install autoconf automake libtool
download protobuf
My suggestion is to download the library of the protobuf-all series
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protobuf-all-3.19.4.zip
Unzip and compile
cd protobuf-3.19.4
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
protoc --version
The installation is complete!
4. Install opencv
sudo apt-get install git cmake
sudo apt-get install -y gfortran
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev libatlas-base-dev
4. Compile ncnn
#cd yolov5
git clone https://github.com/Tencent/ncnn.git
#cd /yolov5pro/ncnn
mkdir -p build
#cd /content/ncnn/build
cmake -DNCNN_VULKAN=OFF ..
#vulkan是针对gpu的,如果想要ncnn能调用gpu做推理,那么选项需要打开,设置为ON。
#最后的 .. 不可少
make -j4 #开始编译
When 100% appears, the compilation is complete
If we use our own model, we need to change: cpp* in the ncnn\examples file
*Modify the bin and param names it reads, 3 outputs and corresponding anchors, categories
5. Call ncnn detection
After modifying cpp according to your own model,Recompile.
It is recommended to use vs code to modify it. It is not recommended to use linux text editor to modify cpp, which is prone to unknown errors.
#cd /content/ncnn/build
cmake -DNCNN_VULKAN=OFF ..
make -j4
After the compilation is successful, put the project and .bin .param in the same folder, and start testing!