A C++ implementation for deploying YOLO11 object detection model on Rockchip RK3588 platform using RKNN API.
- YOLO11 object detection on RK3588 NPU
- Support for int8, uint8, and fp32 quantization
- Hardware-accelerated inference using RKNN Runtime
- OpenCV-based image preprocessing and visualization
- Configurable detection parameters (confidence, NMS threshold)
- Built-in logger for debugging
- Rockchip RK3588 development board
- RK3588 Linux SDK
- RKNPU2 SDK
- OpenCV (aarch64)
- RGA Library (Rockchip Graphics Acceleration)
- CMake >= 3.4.1
- C++17 compatible compiler
rknn_model/
├── include/
│ ├── rknn_model.hpp # Base model class
│ ├── yolo11.hpp # YOLO11 detector implementation
│ ├── type.hpp # Type definitions
│ ├── utils.hpp # Utility functions
│ └── logger.hpp # Logging utilities
├── src/
│ ├── main.cc # Entry point
│ ├── rknn_model.cc # Base model implementation
│ ├── yolo11.cc # YOLO11 implementation
│ ├── utils.cc # Utility functions
│ └── logger.cc # Logger implementation
├── model/
│ ├── yolo11.rknn # RKNN model file
│ ├── car.jpg # Test image
│ └── coco_80_labels_list.txt # Class labels
└── CMakeLists.txt # Build configuration
Update the SDK path in CMakeLists.txt:
# CMakeLists.txt (line 4)
set(SDK_ROOT_PATH "/path/to/your/rk3588_linux_release")Place your RKNN model file in the model/ directory:
yolo11.rknn- YOLO11 model converted to RKNN formatcoco_80_labels_list.txt- Class labels file- Test images (e.g.,
car.jpg)
# Create build directory
mkdir -p build
cd build
# Configure CMake with toolchain file
cmake -DCMAKE_TOOLCHAIN_FILE=/home/clark/rk3588/rk3588-buildroot-2021.11-sysroot-v1.0/buildroot/output/rockchip_rk3588/host/share/buildroot/toolchainfile.cmake ..
# Build the project
make
# Install (optional)
make installThe compiled executable will be located at build/rknn_model.
Note: Update the toolchain file path to match your RK3588 buildroot installation directory.
#include "yolo11.hpp"
int main() {
// Configure detection parameters
detector::DetectParam detect_param = {
0.25, // confidence threshold
0.45, // NMS threshold
114, // background fill color
80 // number of classes
};
// Load image
cv::Mat img = cv::imread("./model/car.jpg");
// Create YOLO11 detector
std::unique_ptr<rknn::Model> yolo11 =
std::make_unique<detector::YOLO11>(
"./model/yolo11.rknn",
logger::Level::DEBUG,
detect_param
);
// Run inference
yolo11->inference(img);
// Draw results
yolo11->draw(img);
return 0;
}| Parameter | Type | Description | Default |
|---|---|---|---|
confidence |
float | Confidence threshold for detection | 0.25 |
nms_threshold |
float | Non-Maximum Suppression threshold | 0.45 |
bf_color |
int | Background fill color | 114 |
class_num |
int | Number of object classes | 80 |
logger::Level::DEBUG- Detailed debug informationlogger::Level::INFO- General informationlogger::Level::WARN- Warning messageslogger::Level::ERROR- Error messages
Transfer the following files to your RK3588 board:
# Required files
build/rknn_model # Executable
model/yolo11.rknn # Model file
model/coco_80_labels_list.txt # Labels
model/car.jpg # Test image (optional)Run on device:
cd /path/to/deployment
./rknn_modelrknn::Model (Base class)
└── detector::YOLO11 (YOLO11 implementation)
-
rknn::Model - Abstract base class providing:
- Model initialization
- Inference pipeline
- Tensor management
- Logging utilities
-
detector::YOLO11 - YOLO11 specific implementation:
- Image preprocessing (resize, letterbox)
- Multi-scale feature processing
- Post-processing (NMS, coordinate transformation)
- Result visualization
-
Preprocessing Pipeline:
- Letterbox resizing to maintain aspect ratio
- Color space conversion
- Normalization
-
Postprocessing Pipeline:
- Distribution Focal Loss (DFL) for bounding boxes
- Confidence filtering
- Non-Maximum Suppression (NMS)
- Coordinate transformation to original image space
- The RK3588 NPU provides hardware acceleration for model inference
- int8 quantization offers the best performance
- Image preprocessing is done on CPU using OpenCV
- RGA library can be used for hardware-accelerated image operations
-
Toolchain file not found
- Verify the toolchain file path in the cmake command
- Ensure RK3588 buildroot SDK is properly installed
-
Missing dependencies
- Check RKNN API path in
CMakeLists.txt - Verify OpenCV and RGA library paths
- Check RKNN API path in
-
Model loading failed
- Ensure
.rknnmodel file is accessible - Check model compatibility with RKNN runtime version
- Ensure
-
Inference errors
- Enable DEBUG logging to diagnose issues
- Verify input image format and dimensions
This project is provided as-is for educational and development purposes.
- Rockchip for RKNN SDK and RK3588 platform
- Ultralytics for YOLO11 architecture
- OpenCV community