After a long time of trying, it is determined to use the Legacy version of the Raspberry Pi OS (32-bit) buster
I have used both 64-bit and 32-bit bullseye, and found that the support for existing packages is still not good enough. Now I start from scratch, I hope it is not too late.
Legacy version of Raspberry Pi OS (32-bit) buster: Download link
Installation sequence: Qt5 -> Eigen 3.4.0 -> OpenCV 4.5.5 -> ncnn
Change Tsinghua source and fully update
sudo apt-get update
sudo apt-get dist-upgrade
Install Qt5
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install clang clang-format
sudo apt-get install qt5-default
sudo apt-get install qtcreator
sudo apt-get install qtdeclarative5-dev
Also change the following gtk3 to gtk2
sudo nano /etc/xdg/qt5ct/qt5ct.conf
After the installation is complete, you can open Qt Creator to check whether it is successful or not
Install Eigen 3.4.0
It is also compiled and installed, and the latest version can be installed.
First go to the official website to download the latest version: Eigen download address
After downloading, unzip and rename to the main directory:
unzip eigen-3.4.0.zip
mv eigen-3.4.0 ~/eigen
cd eigen
mkdir build
cd build
cmake ..
make -j4
sudo make install
sudo ldconfig
sudo reboot
So easyyyy!
Install OpenCV 4.5.5
First change the Raspberry Pi GPU memory to 128MB
and then change the swap-memory to 4096MB. You need to change the maximum limit and the current value,
and then restart.
Finally, update the eeprom of the Raspberry Pi, which is good for cooling down, and restart after the modification
sudo rpi-eeprom-update -a
sudo reboot
GitHub - opencv/opencv_contrib download address
Download, decompress, rename.
unzip opencv-4.5.5.zip
unzip opencv_contrib-4.5.5.zip
mv opencv-4.5.5 ~/opencv
mv opencv_contrib-4.5.5 ~/opencv_contrib
install dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake gfortran
sudo apt-get install python3-dev python3-numpy
sudo apt-get install libjpeg-dev libtiff-dev libgif-dev
sudo apt-get install libgstreamer1.0-dev gstreamer1.0-gtk3
sudo apt-get install libgstreamer-plugins-base1.0-dev gstreamer1.0-gl
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libgtk2.0-dev libcanberra-gtk*
sudo apt-get install libxvidcore-dev libx264-dev libgtk-3-dev
sudo apt-get install libtbb2 libtbb-dev libdc1394-22-dev libv4l-dev
sudo apt-get install libopenblas-dev libatlas-base-dev libblas-dev
sudo apt-get install libjasper-dev liblapack-dev libhdf5-dev
sudo apt-get install protobuf-compiler
Since buster still coexists with Python3 and Python2, you also need to install the dependencies of Python2
sudo apt-get install python-dev python-numpy
Compile and install
cd opencv
mkdir build
cd build
At this time, it is best to download all the files that need to be downloaded during the cmake process in advance, and put them in the opencv/.cache directory. This directory is hidden by default. I downloaded the most complete copy, and the cloud disk link is here. :
链接:https://pan.xunlei.com/s/VN9GfwEr1OdUpu85HZ23vrR2A1#
提取码:xcmd
unzip cache.zip
mv cache ~/opencv/.cache
then cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D WITH_OPENMP=ON \
-D WITH_OPENCL=OFF \
-D BUILD_ZLIB=ON \
-D BUILD_TIFF=ON \
-D WITH_FFMPEG=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D BUILD_TESTS=OFF \
-D WITH_EIGEN=ON \
-D WITH_GSTREAMER=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_VTK=OFF \
-D WITH_QT=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D PYTHON3_PACKAGES_PATH=/usr/lib/python3/dist-packages \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_EXAMPLES=OFF ..
make -j4
sudo make install
sudo ldconfig
sudo reboot
install ncnn
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake wget
sudo apt-get install libprotobuf-dev protobuf-compiler
unzip ncnn-master.zip
mv ncnn-master ~/ncnn
cd ncnn
mkdir build
cd build
cmake -D PI3=ON \
-D NCNN_DISABLE_RTTI=OFF \
-D CMAKE_EXE_LINKER_FLAGS=-ldl \
-D CMAKE_TOOLCHAIN_FILE=../toolchains/pi3.toolchain.cmake ..
make -j4
sudo make install
sudo ldconfig
The files of ncnn are all installed in the install under build and need to be copied to /usr/local
sudo cp -r install/lib/cmake/ncnn /usr/local/lib/cmake/
sudo mkdir /usr/local/lib/ncnn
sudo cp install/lib/libncnn.a /usr/local/lib/ncnn/
sudo cp -r install/include/ncnn /usr/local/include/
sudo cp -r install/bin/* /usr/local/bin/
You're done!