Currently, I'm working on an OpenCV face recognition project using our LCSC Taishan-RK3566-Linux Dev Board. However, the LCSC Taishan-RK3566-Linux Dev Board is quite niche, and there isn't much information available. So, I’m sharing some of my experience here.
For those who are interested, I’ll share the code parts of this project in the future, but this document mainly focuses on the environment setup!
The easiest way to use OpenCV programming on the LCSC Taishan-RK3566-Linux Dev Board is, of course, to build a Linux system with the OpenCV library using Buildroot. This makes the porting process very convenient, and such instructions can be found in other documents. However, when compiling, I found that Buildroot doesn't support the important "opencv_contrib" library for face recognition. There are rumors that this is due to copyright issues. Without this library, many future developments would be very difficult. So, we had to find another solution.
Compiling OpenCV
The implementation involves downloading the required version of OpenCV and the corresponding "opencv_contrib" module. This is the version I used:
If you're having trouble accessing the internet, I have a little tool to help😊
steamcommunity
It's originally a platform for loading games, but it can also load GitHub. If you’re not trying to access foreign websites, it’s quite recommended.
It’s best to do the compilation in a virtual machine. I used Ubuntu 18.04, and you’ll need to download cmake-gui. To install: sudo apt install cmake-gui
Check version: cmake-gui --version
The GUI is much easier to use, no need to strictly follow the command-line method. Just find this program and use it.
Two Paths: Source and Binary Files (Including Makefile Location)
1. Add Entry
NAME=CMAKE_AR;
Type=FILEPATH;
Value= /home/book/Release/buildroot/output/rockchip_rk3566/host/bin/aarch64-buildroot-linux-gnu-ar
Note
The value of the Value field should be customized to your own setup. I used Buildroot on LCSC Taishan-RK3566-Linux Dev Board to build the system, so it's located in the buildroot directory. The host directory contains tools and compilers used to compile the target system's binaries on the host machine. When you configure and compile Buildroot, it will create a host subdirectory in its build directory.
!!! If you're using a different system, make sure to find the appropriate cross-compiler that matches your target system, which will allow it to run on our LCSC Taishan-RK3566-Linux Dev Board.
2. configure
Thanks to OpenCV's wide usage across platforms, OpenCV provides a toolchain configuration to make compiling easier for us. This configuration is located in the platform/Linux directory within the OpenCV source. Select the appropriate toolchain for your architecture (I chose aarch64).
Now you can proceed with configuring the details you need.
3. CMAKE_INSTALL_PREFIX
This is the location where the compiled OpenCV library will be placed. You can choose any directory, just remember it.
4. WITH_GTK_2_X
This option needs to be selected.
5. BUILD_SHARED_LIBS
If selected, it will build shared libraries; if not selected, it will build static libraries.
6. BUILD_opencv_world
This is the "universal" OpenCV library that combines all OpenCV libraries into one. It’s up to you whether to select this, but it can make things easier.
7. WITH_V4L
Face recognition requires a camera.
8. MODULES_PATH
This is for the additional libraries you need. Since this is a face recognition project, I selected opencv_contrib/module/face. If you need other libraries, you can search online for the necessary ones. For this project, we mainly used these modules.
9. make
Once everything is selected, you can start generating the necessary files. After that, a Makefile will be generated in the directory you chose. Go to the folder with the Makefile and run make. It will take some time, so if possible, use multiple threads by running make -j8, but it will still take about half an hour. Finally, run make install to complete the compilation.
Usage
My project is developed using QT, and if you want to use QT as well, you can refer to other documents. It’s actually quite simple. The implementation involves adding QT configurations (it’s easier if you use Buildroot). The compiler is still located in the same path:
- Generating the Makefile
sudo {qmake_path} ./*.pro In your QT .pro file, add the following configuration: LIBS += -L/home/book/for_arm/opencv4-arm/lib -lopencv_world \
INCLUDEPATH += />home/book/for_arm/opencv4-arm/include/opencv4
INCLUDEPATH += /home/book/for_arm/opencv4-arm/include/opencv4/opencv2
Make sure to adjust the paths according to your setup. If you don't use the opencv_world library, it will be more complicated, and you’ll need to manually find and link the necessary libraries.
Testing
To run the project, it depends on three libraries:
libopencv_world.so libopencv_world.so.405 libopencv_world.so.4.5.5
So, make sure to copy them to the /lib directory on the board so it can run properly.
WiFi Issues
Since my project needs network access, I encountered a WiFi issue. I'm using Buildroot, but if you aren’t, you can skip this part. Buildroot uses a script called wifi_start.sh to configure WiFi. First, modify the WiFi name and password in:/buildroot/output/rockchip_rk3566/target/etc/wpa_supplicant.conf Then, recompile. I found a simple way to flexibly modify the WiFi being used by running: /usr/bin/wifi_start.sh
#!/bin/sh
WIFISSID=$1
WIFIPWD=$2
CONF=/tmp/wpa_supplicant.conf
cp /etc/wpa_supplicant.conf /tmp/
echo "connect to WiFi ssid: $WIFISSID, Passwd: $WIFIPWD"
sed -i "s/SSID/$WIFISSID/g" $CONF
sed -i "s/PASSWORD/$WIFIPWD/g" $CONF
killall wpa_supplicant
sleep 1
wpa_supplicant -B -i wlan0 -c $CONF
2
3
4
5
6
7
8
9
10
11
12
You will see
cp /etc/wpa_supplicant.conf /tmp/
At this line, just go ahead and change our /etc/wpa_supplicant.conf, and change it to the wifi you want to use
This gives us the flexibility to adjust our wifi