Implementing Material Recognition on LicheePi 4A with YOLOX and OpenCV

Development Board Setup

System Installation

The Debian system (20230920 version) was selected for the LicheePi 4A. The installation process involves:

  1. Using burn_tools.zip for flashing
  2. Modifying the burn_lpi4a.bat file path to point to the downloaded image
  3. Disabling driver signature enforcement in Windows 10 for successful driver installation

System Configuration

Key configuration steps:

sudo passwd  # Change root password
mousepad /etc/ssh/sshd_config  # Enable root SSH login

SD Card Expansion

Partition management steps:

sudo fdisk -l  # List partitions
sudo fdisk /dev/mmcblk1  # Partition management
# Follow with d (delete), n (new), t (type), w (write) commands
sudo mkfs.ext4 /dev/mmcblk1p1  # Format partition

Add to /etc/fstab:

/dev/mmcblk1p1 /mnt/sdcard auto defaults 0 2

YOLOX Environment Setup

Dependency Installatoin

sudo apt update
sudo apt install wget git vim
wget https://github.com/T-head-Semi/csi-nn2/releases/download/v2.4-beta.1/c920.tar.gz
tar xf c920.tar.gz
cp c920/lib/* /usr/lib/riscv64-linux-gnu/ -rf

Model Setup

git clone https://github.com/Megvii-BaseDetection/YOLOX
cd YOLOX/demo/ONNXRuntime
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx

Python Package Installation

pip install numpy-1.25.0-cp311-cp311-linux_riscv64.whl
pip install opencv_python-4.5.4+4cd224d-cp311-cp311-linux_riscv64.whl
# Additional packages...
wget https://github.com/zhangwm-pt/onnxruntime/releases/download/riscv_whl/onnxruntime-1.14.1-cp311-cp311-linux_riscv64.whl
pip install onnxruntime-1.14.1-cp311-cp311-linux_riscv64.whl

OpenCV GUI Isue Resolution

The error occurs when OpenCV lacks GTK2.0 support:

cv2.error: OpenCV(4.5.4) ... The function is not implemented.

Solutions:

  1. Install a newer OpenCV version with GTK2.0 support
  2. Compile OpenCV from source with GTK2.0 enabled for RISC-V architecture

Tags: RISC-V LicheePi YOLOX OpenCV Computer Vision

Posted on Sat, 09 May 2026 17:03:16 +0000 by seanlyons