sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install --upgrade git+https://github.com/Maratyszcza/PeachPy
sudo pip install --upgrade git+https://github.com/Maratyszcza/confu
Usually I install with pip3, but the original was just pip
git clone https://github.com/ninja-build/ninja.git
cd ninja
git checkout release
./configure.py --bootstrap
export NINJA_PATH=$PWD
Possible errors can be:
warning: A compatible version of re2c (>= 0.11.3) was not found;
changes to src/*.in.cc will not affect your build.
A possible solution can be:
sudo apt-get install -y re2c
1.4. Install clang (I'm not sure why we need this, NNPACK doesn't use it unless you specifically target it)
sudo apt-get install clang
cd
git clone https://github.com/shizukachan/NNPACK.git
cd NNPACK
mkdir build && cd build
export PATH="${PATH}:~/ninja"
cmake -G Ninja -DBUILD_SHARED_LIBS=on-DCMAKE_C_FLAGS=-march=armv6k ..
ninja
cd
sudo ninja install
git clone https://github.com/shizukachan/darknet-nnpack.git
cd darknet-nnpack
make
sudo find / -iname opencv.pc
export PKG_CONFIG_PATH=/path/to/the/file
It’s better to add this line to your bashrc file so that you don’t have to do it every single time you reopen your terminal.
sudo apt-get install pkg-config
sudo apt-get install libopencv-dev
wget https://pjreddie.com/media/files/yolov3-tiny.weights
./darknet detector test cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg
./darknet: error while loading shared libraries: libnnpack.so:
cannot open shared object file: No such file or directory
simply do:
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
./darknet detector demo cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights
Results (screenshot of video stream not included):
FPS:0.5
Objects:
person: 45%
7. Trying to run rpi_video.py
run in the darknet-nnpack directory as:
python yolo_test.py
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources
solution:
sudo apt-get update && sudo apt-get upgrade
sudo rpi-update
#reboot
Also, you can rise GPU memory to 256 Mb
Error: can only concatenate str (not "bytes") to str
I found some similar problems but didn't implement the solution in that code:
base64.b64encode produces a byte-stream, not a string. So for your concatenation to work, you have to convert it into a string first with str(base64.b64encode(addpermissions.encode('utf_16_le')))
b64cmd = base64.b64encode(cmd.encode('utf_16_le')).decode('utf-8')
os.system('powershell -enc ' + b64cmd)
EDIT: Normal string conversion didn't work with os.system, used decode('utf-8') instead
If it works on your Raspberry I am very glad, because it took me several days to finally make it work.
I would very much appreciate it if you could send me some nice code in python for the real-time detection from a raspberry pi cam because 0.5 fps is not enough.
For example, TensorFlow lite reaches 4-5 fps with active cooling and building it takes around 20 minutes.
In that case, I don't quite understand, what's the point in Yolo and darknet for the real-time detection purposes on raspberry.
Thanks for your attention.
COCO ./darknet detector test cfg/coco.data [cfg file] [weights file] [image path]