配置环境
Debian换源
修改配置文件
sudo nano /etc/apt/sources.list
内容修改为
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free
执行更新
sudo apt update && sudo apt upgrade
NCNN
环境配置
sudo apt-get install -y gfortran
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libprotoc-dev
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
获取ncnn
cd ncnn
git clone https://github.com/Tencent/ncnn
修改CMakeList.txt
将
add_subdirectory(examples)
add_subdirectory(benchmark)
前的注释删除
编译安装ncnn
cd build
mkdir build
cmake ../
make -j4
make install
Opencv安装
安装python & pip
sudo apt install python3 -y
sudo apt install -y python3-pip
配置pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade pip
安装opencv
pip3 install opencv-python opencv-contrib-python numpy matplotlib opencv-python-headless
pip3 install onnxruntime onnx-simplifier onnx skl2onnx
验证OpenCV安装
# python3
> import cv2
> cv2.__version__
ncnn环境变量
sudo cp ~/ncnn/build/install/include/ncnn/* /usr/include/
sudo mkdir -p /usr/local/lib/ncnn/
sudo cp ncnn/build/src/libncnn.a /usr/local/lib/ncnn/
/etc/profile写入
export PATH=$PATH:$HOME/bin
C_INCLUDE_PATH=/usr/include/:/usr/include/opencv4:$C_INCLUDE_PATH
export C_INCLUDE_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/:/usr/include/opencv4
export CPLUS_INCLUDE_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/include/:/usr/include/opencv4
export LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH:/usr/include/:/usr/include/opencv4
export LIBRARY_PATH
测试ncnn
前提
- 64位树莓派系统
- NCNN框架
- 64位opencv
- 安装codeblocks
sudo apt-get install codeblocks
获取yolofast2-yolo for RPi
wget https://github.com/Qengineering/YoloFastestV2-ncnn-Raspberry-Pi-4/archive/refs/heads/main.zip
or
git clone https://github.com/Qengineering/YoloFastestV2-ncnn-Raspberry-Pi-4
解压,使用codeblocks打开YoloFastestV2.cbp,编译运行
安装yolo fastest
环境配置
sudo apt install git
git clone https://github.com/dog-qiuqiu/Yolo-FastestV2.git
#失败时可以改为git clone git://github.com/dog-qiuqiu/Yolo-FastestV2.git
- armv7l
pip install torch torchvision torchsummary -f https://torch.maku.ml/whl/stable.html
pip install -r Yolo-FastestV2\requirements.txt
- others
pip install -r Yolo-FastestV2\requirements.txt
验证安装
cd Yolo-FastestV2
python3 test.py --data data/coco.data --weights modelzoo/coco2017-epoch-0.235624ap-model.pth --img img/000230.jpg