11 All-in-One Quickstart Application
This chapter describes the GK7206 all-in-one quickstart application example — sample_quickstart. The application demonstrates an end-to-end complete AI vision pipeline, including video capture, VPSS processing, VENC encoding, NPU face detection, and web display.
The application source code is located in the SDK directory sample/quickstart/. It is an easy-entry comprehensive example, suitable for learning the full capabilities of the GK7206.
1 Application Overview
1.1 Features
- End-to-end pipeline: capture + VPSS + VENC + NPU detection
- Real-time face detection: NPU-based person detection model
- Web visualization: embedded HTTP server, viewable directly in a browser
- RTSP streaming: supports RTSP stream pulling
- Detection result overlay: draws detection boxes on the video stream
1.2 Technical Parameters
| Parameter | Value |
|---|---|
Sensor resolution | 2560 × 1440 (SC465SL) |
Detection input resolution | 640 × 360 |
NPU inference frame rate | ~15 FPS |
Web service port | 80 |
Video encoding format | MJPEG |
Model format | .xmm (GK7206 NPU-specific format) |
1.3 Directory Structure
sample/quickstart/
├── Makefile # Build script
├── sample_quickstart.c # Main program
└── models/ # NPU model files (download separately)
└── person_detect.xmm # Person detection model2 Build and Deployment
2.1 Prerequisites
Before building this application, make sure the following preparations are complete:
- SDK environment ready: set up the cross-compilation toolchain and SDK configuration by following SDK Build
- NPU model ready: the person detection model must be placed in the
models/directory - Sensor connected: an SC465SL or compatible image sensor
2.2 Build the Application
# Enter the sample directory
cd <SDK_PATH>/sample
# Build the quickstart sample
make -C quickstart clean && make -C quickstart2.3 Deploy to the Board
# Mount the SD card (recommended)
mkdir -p /sd_card
mount -t vfat /dev/mmcblk1p1 /sd_card
# Transfer to the development board via SCP
scp sample/quickstart/sample_quickstart root@<board IP>:/sd_card/
# Transfer the NPU model
scp -Or sample/quickstart/models root@<board IP>:/sd_card/2.4 Run the Application
# Add execute permission
chmod +x /sd_card/sample_quickstart
# Enter the SD card directory
cd /sd_card
# Run
./sample_quickstart2.5 Expected Output
After a successful run, the terminal prints output similar to the following:
sample_quickstart running
sensor: 2560x1440 @ 30fps
npu: Initializing...
npu: Loading person_detect.xmm
npu: Model loaded!
pipeline: VI→VPSS→VENC(MJPEG) + VPSS→NPU(640x360)
web: http://192.168.1.100/
rtsp://192.168.1.100:554/livestream/0Open http://<board IP>/ in a browser to see the live face detection picture.
3 Internal Execution Logic
3.1 Application Architecture
The application adopts the following architecture:
Sensor → VI → VPSS → VENC(MJPEG) → Web display
↓
NPU inference → detection result overlay3.2 Initialization Flow
// Step 1: initialize the video pipeline
sample_comm_sys_init(&sys_config);
sample_comm_isp_init();
sample_comm_vi_start(...);
sample_comm_vpss_start(...);
sample_comm_venc_start(...);
// Step 2: initialize the NPU
init_npu();
// Step 3: start the NPU inference thread
pthread_create(&npu_thread, NULL, npu_inference_thread, NULL);
// Step 4: start the web server
web_server_run();4 Key Programming Points
4.1 NPU Model Loading
xmedia_cl_graph graph;
xmedia_u64 work_phy, weight_phy;
void *work_buf, *weight_buf;
// Query the memory size required by the model
xmedia_cl_graph_querysize_from_file("models/person_detect.xmm",
&worksize, &weightsize);
// Allocate MMZ memory
work_buf = xmedia_mmz_alloc_map("npu_work", &work_phy, worksize);
weight_buf = xmedia_mmz_alloc_map("npu_weight", &weight_phy, weightsize);
// Load the model
xmedia_cl_graph_loadmodel_from_file_withmem(&ctx, "models/person_detect.xmm",
work_buf, worksize, weight_buf, weightsize, &graph);4.2 Inference Loop
void *npu_inference_thread(void *arg)
{
while (running) {
// Acquire a frame from VPSS
xmedia_vpss_acquire_ochn_frame(pipe, ochn, &frame, timeout);
// Pre-processing (YUV → RGB)
yuv420sp_to_rgb888(frame.y_vir, frame.c_vir, rgb_buf, width, height);
// NPU inference
xmedia_cl_graph_process(graph);
// Post-processing (parse detection results)
parse_detections(output_buf, &detections);
// Release the frame
xmedia_vpss_release_ochn_frame(pipe, ochn, &frame);
}
}5 Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
svp create fail | NPU model file missing or wrong format | Check that the model file exists and its format is correct |
| Inaccurate detection results | Wrong model input image format | Check that the YUV→RGB conversion is correct |
| Out of memory (OOM) | 26 MB is tight for NPU + video encoding | Mount the SD card to free up memory |
