This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
products:sbc:edge-2l:npu:rknn-sdk-quick-start [2025/10/21 23:21] william created |
products:sbc:edge-2l:npu:rknn-sdk-quick-start [2026/05/11 02:49] (current) nick ↷ Page moved from local:users:william:debug:edge2l:rknn-sdk-quick-start to products:sbc:edge-2l:npu:rknn-sdk-quick-start |
||
|---|---|---|---|
| Line 42: | Line 42: | ||
| ``` | ``` | ||
| === Create Python Environment Using Miniforge Conda === | === Create Python Environment Using Miniforge Conda === | ||
| + | In the terminal window on the computer, execute the following command to switch to the Miniforge conda base | ||
| + | environment: | ||
| ```shell | ```shell | ||
| $ source ~/ | $ source ~/ | ||
| ``` | ``` | ||
| + | Create a Python 3.8 environment named ' | ||
| ```shell | ```shell | ||
| $ conda create -n py38Toolkit2.3.2 python=3.8 | $ conda create -n py38Toolkit2.3.2 python=3.8 | ||
| ``` | ``` | ||
| + | Activate the ' | ||
| ```shell | ```shell | ||
| $ conda activate py38Toolkit2.3.2 | $ conda activate py38Toolkit2.3.2 | ||
| ``` | ``` | ||
| + | === Install RKNN-Toolkit2 === | ||
| + | Install via local wheel packag. | ||
| + | ```shell | ||
| + | $ cd rknn-toolkit2/ | ||
| + | $ pip3 install -r requirements_cp38-2.3.2.txt | ||
| + | $ pip3 install ./ | ||
| + | ``` | ||
| + | |||
| + | === Check if the RKNN-Toolkit2 Environment is Installed Successfully === | ||
| + | Switch to Python interactive mode | ||
| + | ```shell | ||
| + | $ python | ||
| + | ``` | ||
| + | Import the RKNN class | ||
| + | ```shell | ||
| + | $ from rknn.api import RKNN | ||
| + | ``` | ||
| ==== Install Compilation Tools on the Computer ==== | ==== Install Compilation Tools on the Computer ==== | ||
| + | === Install NDK on Android System Development Board === | ||
| + | Note: This section is applicable to development boards with the Android system. If the board is running on the | ||
| + | Linux system, please skip this section.\\ | ||
| + | Download the Android NDK from the following link: | ||
| + | ```shell | ||
| + | $ wget -c https:// | ||
| + | ``` | ||
| + | Extract Android NDK files | ||
| + | ```shell | ||
| + | $ unzip android-ndk-r19c-linux-x86_64.zip | ||
| + | ``` | ||
| - | ==== Install | + | ==== Install |
| + | Note: This section is applicable to development boards with the Linux system. If the board is running on the | ||
| + | Android system, please skip this section.\\ | ||
| + | Download the GCC Cross-Compiler from the following link: | ||
| + | ```shell | ||
| + | $ wget -c https:// | ||
| + | ``` | ||
| + | Extract GCC Cross-Compiler files | ||
| + | ```shell | ||
| + | $ tar -xJvf gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.tar.xz | ||
| + | ``` | ||
| ===== Run Example Programs ===== | ===== Run Example Programs ===== | ||
| + | |||
| + | ==== Prepare Model ==== | ||
| + | Switch to the rknn_model_zoo/ | ||
| + | script will download an available YOLOv5 ONNX model and store it in the current model directory. Refer to the | ||
| + | following commands: | ||
| + | |||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ chmod a+x download_model.sh && ./ | ||
| + | ``` | ||
| + | |||
| + | ==== Model Conversion ==== | ||
| + | Switch to the rknn_model_zoo/ | ||
| + | the original ONNX model to the RKNN model. Refer to the following commands: | ||
| + | |||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ chmod a+x convert.py && python convert.py ../ | ||
| + | ``` | ||
| + | |||
| + | ==== Run RKNN Python Demo ==== | ||
| + | Switch to the rknn_model_zoo/ | ||
| + | YOLOv5 model on the development board using on-board debugging. Refer to the following command: | ||
| + | |||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ chmod a+x yolov5.py && python yolov5.py --model_path ../ | ||
| + | ``` | ||
| + | |||
| + | ==== Run RKNN C Demo ==== | ||
| + | To run a RKNN C Demo, you need to first compile the C/C++ source code into an executable file. After that, push | ||
| + | the executable file, model files, input images, and other related files to the development board. Finally, execute | ||
| + | the executable file on the development board. | ||
| + | |||
| + | === Board is running on the Android system === | ||
| + | In the ' | ||
| + | |||
| + | ```shell | ||
| + | $ ANDROID_NDK_PATH=Projects/ | ||
| + | ``` | ||
| + | Then, in the ' | ||
| + | |||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ ./ | ||
| + | ``` | ||
| + | |||
| + | Push Files to the edge2l Board: | ||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ adb root | ||
| + | $ adb install/ | ||
| + | ``` | ||
| + | |||
| + | Run the Demo on edge2l Board: | ||
| + | ```shell | ||
| + | $ adb shell | ||
| + | edge2l$ cd / | ||
| + | edge2l$ export LD_LIBRARY_PATH=./ | ||
| + | edge2l$ ./ | ||
| + | ``` | ||
| + | === Board is running on the Linux system === | ||
| + | In the ' | ||
| + | |||
| + | ```shell | ||
| + | $ GCC_COMPILER=Projects/ | ||
| + | ``` | ||
| + | Then, in the ' | ||
| + | |||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ ./ | ||
| + | ``` | ||
| + | |||
| + | Push Files to the edge2l Board: | ||
| + | ```shell | ||
| + | $ cd Projects/ | ||
| + | $ adb install/ | ||
| + | ``` | ||
| + | |||
| + | Run the Demo on edge2l Board: | ||
| + | ```shell | ||
| + | $ adb shell | ||
| + | edge2l$ cd / | ||
| + | edge2l$ export LD_LIBRARY_PATH=./ | ||
| + | edge2l$ ./ | ||
| + | ``` | ||
| + | |||
| + | |||
| + | |||
| + | ==== View Results ==== | ||
| + | By default, the output image is saved at the path rknn_yolov5_demo/ | ||
| + | from the board to the local machine. In the local computer terminal, execute the following command: | ||
| + | ```shell | ||
| + | $ adb pull / | ||
| + | ``` | ||
| + | {{local: | ||
| ===== Important Note ===== | ===== Important Note ===== | ||