目录
1. 前言
介绍了OpenCV和NCNN库的交叉编译过程,并在TIAM62开发板上部署YOLACT实力分割模型
2. OpenCV交叉编译
首先下载opencv源码,如下
git clone https:
cd opencv
git submodule update --init --recursive
下载opencv_contrib源码,如下
git clone https://github.com/opencv/opencv_contrib
开启交叉编译docker环境,将opencv源码和opencv_contrib源码复制到docker中,如下
cd docker/
docker load -i myir-env.tar
docker images
docker run -itd 41f916f6b5c0
docker ps
docker cp opencv 88c3cc603221:/opt/arago-2023.04/sysroots/aarch64-oe-linux/home/root
docker cp opencv_contrib 88c3cc603221:/opt/arago-2023.04/sysroots/aarch64-oe-linux/home/root/
进入docker中编译opencv源码,首先运行如下命令将编译器改为交叉编译器,
docker exec -it -u root 88c3cc603221 bash
. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
然后编译opencv和opencv_contrib源码,
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/home/root/opencv
mkdir build & cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/opencv/ -DOPENCV_EXTRA_MODULE_PATH=../../opencv_contrib-4.x/modules/ -DBUILD_opencv_world=OFF -DBUILD_PNG=ON -DBUILD_ZLIB=ON -DWITH_PNG=ON -DWITH_JPEG=ON -DWITH_OPENJPEG=ON -DBUILD_opencv_apps=ON -DBUILD_opencv_calib3d=ON -DBUILD_opencv_core=ON -DBUILD_opencv_dnn=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_flann=ON -DBUILD_opencv_highgui=ON -DBUILD_opencv_imgcodecs=ON -DBUILD_opencv_imgproc=ON -DBUILD_opencv_video=ON -DBUILD_opencv_videoio=ON -DWITH_OPENGL=ON -DWITH_QT=ON
make & make install
3. NCNN交叉编译
下载ncnn源码,如下
git clone https://github.com/Tencent/ncnn.git
将ncnn源码复制到docker中,
docker cp ncnn 88c3cc603221:/opt/arago-2023.04/sysroots/aarch64-oe-linux/home/root
进入docker编译ncnn源码,如下
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/home/root/ncnn
mkdir build & cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_VULKAN=ON -DNCNN_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/ncnn/ ..
make & make install
4. opencv和ncnn移植
在/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/opencv/lib/ 和/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/ncnn/lib/ 有opencv和ncnn的库文件,将其移植到TIAM62开发板上
|