Yolo-FastestV2
This project is developed in Linux, with Python 3.10. Has not been tested in Windows.
Build
Requirements
- Tested with Python 3.10 and 3.9
- C++17 compatible compilers (tested with gcc10)
Compile Tencent/ncnn and install it to /usr/local/
. See also Build for Linux and Build for ARM Cortex-A family with cross-compiling
git clone --recursive https://github.com/crosstyan/Yolo_Fastest_Example
# https://pkgs.org/
sudo apt install libspdlog-dev
# https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
sudo apt install libopencv-dev
sudo apt install libhiredis-dev
sudo apt install python3-gevent
# https://github.com/sewenew/redis-plus-plus/
cd lib/redis-plus-plus
mkdir build
cd build
cmake -DREDIS_PLUS_PLUS_CXX_STANDARD=17 ..
make
make install
sudo apt install libpython3.9-dev
pip install python-config
python-config --includes
# change Python3_INCLUDE_DIR and Python3_LIBRARY
# return to ${PROJECT_SOURCE_DIR}
cd ../../
mkdir build
cd build
# you need to specify the path to Python and OpenCV if needed
# cmake .. -DOpenCV_DIR=/opt/rk3328_cross_compile_opencv
cmake ..
cmake --build . --target yolo_app -- -j $(nproc)
# default install to ${PROJECT_SOURCE_DIR}/py
make
make install
cd ../py
pip install requirements.txt
now run python3 g.py
in ${PROJECT_SOURCE_DIR}/py
Build Note
Swapfile
You need a swapfile to compile it if your memory is not enough. At least 3 GB of memory is needed.
sudo free -h
# or
sudo swapon --show
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
then edit /etc/fstab
/swapfile swap swap defaults 0 0
Maybe you need to remove the swap file later for small disk space device.
sudo swapoff -v /swapfile
redis
apt install redis
Disable Redis Persistent Store to prevent run out of disk
Modify /etc/redis/redis.conf
then restart the redis systemctl restart redis
proxychains
Clash or other proxy software should be accessible via LAN or running locally.
/etc/proxychains.conf
Install GCC10
Install Python3.10
apt install python3.10-dev python3.10-venv
using pip
Pip is not working for Python 3.10 on Ubuntu
Proxy is usually necessary.
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
update-alternatives
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 3
Install Latest CMake (3.24.0-rc1)
Download binary from cmake.
Copy to /usr/
(or /usr/local/
?)
i2cdetect
apt-get install i2c-tools
IDE
This is a cmake project. Everything should work if your IDE supports it.
VSCdoe
See Configure Hello World also c-cpp-properties-schema-reference
Add "configurationProvider": "ms-vscode.cmake-tools"
to your c_cpp_properties.json
CLion
Everything is perfect in CLion.
Notes
using OpenCV's Gstreamer API
gst-launch-1.0 -v videotestsrc ! x264enc ! flvmux ! rtmpsink location='rtmp://localhost:1935/live/rfBd56ti2SMtYvSgD5xAV0YU99zampta7Z7S575KLkIZ9PYk'
gst-launch-1.0 videotestsrc is-live=true ! x264enc pass=5 quantizer=25 speed-preset=6 ! video/x-h264, profile=baseline ! flvmux ! rtmpsink location='rtmp://localhost:1935/live/rfBd56ti2SMtYvSgD5xAV0YU99zampta7Z7S575KLkIZ9PYk'
gst-inspect-1.0 | grep x264
ffmpeg -re -i demo.flv -c copy -f flv rtmp://localhost:1935/live/rfBd56ti2SMtYvSgD5xAV0YU99zampta7Z7S575KLkIZ9PYk
What does a C process status mean in htop? htop explained
python3 g.py --host 192.168.123.43 -d
GStreamer + gstreamer-rockchip (fork form firefly-linux/external/gstreamer-rockchip) + gstreamer-rockchip-extra and rockchip-linux/mpp
base_pipeline = "appsrc ! " + \
"videoconvert ! " + \
"mpph264enc ! " + \
"h264parse ! " + \
"flvmux streamable=true ! " + \
"queue ! " + \
"rtmpsink sync=true location="