rv1126 android,RV1126_RV1109 Rock-X 使用说明

一、简介

Rock-X SDK 是基于 RK3399Pro/RK180X 等平台的一套 AI 组件库。开发者通过 Rock-X SDK 提供的 API 接口能够快速构建 AI 应用。

Rock-X SDK 当前支持 Python/C 编程语言, 支持运行于 RK3399Pro Android/Linux 平台、RK180X Linux 平台以及 PC Linux/MacOS/Windows(需要接 RK1808 计算棒)。

本文测试基于RV1109或RV1126的buildroot系统中,运行rock-x sdk。

SDK 提供的功能如下:

Rock-X SDK 文件说明

rv1126_rv1109/linux_sdk_rockchip/external/rockx$ tree -L 3

.

├── auth

│ ├── Android

│ │ ├── arm64-v8a

│ │ └── armeabi-v7a

│ ├── Linux

│ │ ├── aarch64

│ │ ├── armhf

│ │ └── x86_64

│ ├── README.md

│ └── Windows

│ └── RKauth_tool_v1.02.zip

├── ChangeLog.txt

├── CMakeLists.txt

├── demo

│ ├── command_line_demo # Rock-X SDK C 示例程序

│ │ ├── build

│ │ ├── build-android-rk3399pro-v7a.sh

│ │ ├── build-android-rk3399pro-v8a.sh

│ │ ├── build-linux-rk1806.sh

│ │ ├── build-linux-rk1808.sh

│ │ ├── build-linux-rk3399pro-on-device.sh

│ │ ├── build-linux-rk3399pro.sh

│ │ ├── build-linux-rv1109.sh

│ │ ├── build-linux-x86.sh

│ │ ├── cmake

│ │ ├── CMakeLists.txt

│ │ ├── README.md

│ │ ├── rockx_body_mask_demo

│ │ ├── rockx_carplate_demo

│ │ ├── rockx_face_attribute_demo

│ │ ├── rockx_face_detection_demo

│ │ ├── rockx_face_landmark_demo

│ │ ├── rockx_face_masks_detection_demo

│ │ ├── rockx_face_recognition_demo

│ │ ├── rockx_head_detection_demo

│ │ ├── rockx_object_detection_demo

│ │ ├── rockx_object_track_demo

│ │ ├── rockx_person_detection_demo

│ │ ├── rockx_pose_body_demo

│ │ └── rockx_pose_finger_demo

│ └── rk3399pro_android_demo

│ ├── rockx-android-demo-carplate_recognition.zip

│ ├── rockx-android-demo-face_attribute.zip

│ ├── rockx-android-demo-face_landmark.zip

│ ├── rockx-android-demo-object_detection.zip

│ └── rockx-android-demo-pose_body.zip

├── doc

│ ├── Rockchip_Developer_Guide_RockX_SDK_CN.pdf

│ ├── Rockchip_Developer_Guide_RockX_SDK_EN.pdf

│ └── rockx_api_doc

│ └── html

├── LICENSE

├── python

│ ├── RockX-1.2.0-py3-none-any.whl

│ └── test

│ ├── camera

│ ├── image

│ └── __init__.py

├── sdk

│ ├── rockx-data

│ │ ├── carplate_align.data

│ │ ├── carplate_detection.data

│ │ ├── carplate_recognition.data

│ │ ├── face_attribute.data

│ │ ├── face_detection.data

│ │ ├── face_landmark5.data

│ │ ├── face_landmarks68.data

│ │ ├── face_liveness_2d.data

│ │ ├── face_recognition.data

│ │ ├── head_detection.data

│ │ ├── object_detection.data

│ │ ├── pose_body.data

│ │ ├── pose_finger.data

│ │ └── pose_hand.data

│ ├── rockx-data-rv1109 # 针对rv1109的 rock-x ai模型

│ │ ├── body_detection.data

│ │ ├── body_mask.data

│ │ ├── carplate_align.data

│ │ ├── carplate_detection.data

│ │ ├── carplate_recognition.data

│ │ ├── face_attribute.data

│ │ ├── face_detection_v2.data

│ │ ├── face_detection_v3.data

│ │ ├── face_detection_v3_fast.data

│ │ ├── face_detection_v3_large.data

│ │ ├── face_landmark5.data

│ │ ├── face_landmarks68.data

│ │ ├── face_mask_classify.data

│ │ ├── face_masks_detection.data

│ │ ├── face_recognition.data

│ │ ├── head_detection.data

│ │ ├── object_detection.data

│ │ ├── person_detection_v2.data

│ │ ├── person_detection_v3.data

│ │ ├── pose_body.data

│ │ ├── pose_body_v2.data

│ │ ├── pose_finger.data

│ │ └── pose_hand.data

│ ├── rockx-rk1806-Linux

│ │ ├── include

│ │ ├── lib

│ │ ├── lib64

│ │ └── RockXConfig.cmake

│ ├── rockx-rk1808-Linux

│ │ ├── include

│ │ ├── lib64

│ │ └── RockXConfig.cmake

│ ├── rockx-rk3399pro-Android

│ │ ├── arm64-v8a

│ │ ├── armeabi-v7a

│ │ ├── include

│ │ └── RockXConfig.cmake

│ ├── rockx-rk3399pro-Linux

│ │ ├── include

│ │ ├── lib64

│ │ └── RockXConfig.cmake

│ ├── rockx-rv1109-Linux # 针对rv1109的 rock-x 动态链接库和头文件

│ │ ├── include

│ │ ├── lib

│ │ └── RockXConfig.cmake

│ └── rockx-x86-64-Linux

│ ├── include

│ ├── lib64

│ └── RockXConfig.cmake

└── VERSION

57 directories, 68 files

二、编译Rock-X SDK

使用RK_SDK_rv1126_rv1109_linux SDK

1.下载编译CMake

rockx sdk的编译需要基于 3.10 以上版本的cmake, 如果系统的cmake版本比较旧,则需要更新cmake。

$ sudo apt-get install build-essential

$ cd ~/Download/

$ wget http://www.cmake.org/files/v3.11/cmake-3.11.3.tar.gz

$ tar -zxvf cmake-3.11.3.tar.gz

$ cd cmake-3.11.3

$ ./configure

$ make

# $ sudo make install

$ ~/Downloads/cmake-3.11.3/bin/cmake -version

cmake version 3.11.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

为了不应用系统已安装的cmake,可以不使用install。

2.修改编译环境

修改 external/rockx/demo/command_line_demo/build-linux-rv1109.sh

修改交叉编译工具链路径

修改cmake路径

手动编译

cd external/rockx/demo/command_line_demo

git diff build-linux-rv1109.sh

diff --git a/demo/command_line_demo/build-linux-rv1109.sh b/demo/command_line_demo/build-linux-rv1109.sh

index fa569de..5a34df1 100755

--- a/demo/command_line_demo/build-linux-rv1109.sh

+++ b/demo/command_line_demo/build-linux-rv1109.sh

@@ -1,6 +1,7 @@

#!/bin/bash

-GCC_COMPILER_PATH=~/opts/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf

+GCC_COMPILER_PATH=/home/ubuntu/disk1/rv1126_rv1109/linux_sdk_rockchip/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf

#BUILD_TYPE=Release

BUILD_TYPE=Debug

@@ -13,14 +14,16 @@ if [[ ! -d "${BUILD_DIR}" ]]; then

mkdir -p ${BUILD_DIR}

fi

+CMAKE_DIR=/home/ubuntu/Downloads/cmake-3.11.3/bin

+

cd ${BUILD_DIR}

-cmake ../.. \

+${CMAKE_DIR}/cmake ../.. \

-DTARGET_SOC=rv1109 \

-DCMAKE_SYSTEM_NAME=Linux \

-DCMAKE_C_COMPILER=${GCC_COMPILER_PATH}-gcc \

-DCMAKE_CXX_COMPILER=${GCC_COMPILER_PATH}-g++ \

-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \

-DCMAKE_INSTALL_PREFIX=${ROOT_PWD}/install/rockx_rv1109_linux

-make -j4

-make install

+#make -j4

+#make install

cd -

3.配置编译rockx

$ cd external/rockx/demo/command_line_demo

# 配置编译环境

$ bash build-linux-rv1109.sh

rockx_demo

-- Configuring done

-- Generating done

-- Build files have been written to: /home/ubuntu/disk1/rv1126_rv1109/linux_sdk_rockchip/external/rockx/demo/command_line_demo/build/build_rv1109_linux

/home/ubuntu/disk1/rv1126_rv1109/linux_sdk_rockchip/external/rockx/demo/command_line_demo

# 编译

$ cd ./build/build_rv1109_linux/

$ make

[ 6%] Built target rockx_face_detection

[ 13%] Built target rockx_face_landmark

[ 20%] Built target rockx_object_detection

[ 26%] Built target rockx_pose_body

[ 33%] Built target rockx_pose_body_async

[ 40%] Built target rockx_pose_finger

[ 46%] Built target rockx_face_recognition

[ 53%] Built target rockx_face_attribute

[ 60%] Built target rockx_head_detection

[ 66%] Built target rockx_carplate

[ 73%] Built target rockx_object_track

[ 80%] Built target rockx_face_masks_detection

[ 86%] Built target rockx_body_mask

[ 93%] Built target rockx_person_detection

[100%] Built target rockx_person_detection_async

三、在buildroot系统中运行rockx

1.复制编译结果和依赖文件到本地

将主机的编译结果和动态库等文件拷贝到RV1109或RV1126设备中

$ cd external/rockx/

$ scp -r sdk/ root@xxx:/userdata/rockx

$ scp -r demo/command_line_demo/ root@xxx:/userdata/rockx

2.加入动态链接库新搜索路径

# RV1109设备上

cd /userdata/rockx

# 将动态库和头文件放到与AI模型同一路径下

cp sdk/rockx-rv1109-Linux/lib/* sdk/rockx-data-rv1109/

cp sdk/rockx-rv1109-Linux/include/ sdk/rockx-data-rv1109/

# 修改环境变量

vi /etc/profile

# 加入

ROCKX_DATA_PATH=/userdata/rockx/sdk/rockx-data-rv1109

export LD_LIBRARY_PATH=${ROCKX_DATA_PATH}:$LD_LIBRARY_PATH

source /etc/profile

也可以直接把动态库和AI模型复制到系统路径

cp sdk/rockx-rv1109-Linux/lib/* /usr/lib/

cp sdk/rockx-rv1109-Linux/include/ /usr/lib/

cp sdk/rockx-data-rv1109/ /usr/lib/

3.运行rockx demo 可执行文件

$ cd /userdata/rockx/command_line_demo/build/build_rv1109_linux/rockx_carplate_demo

# 运行车牌识别程序

$ ./rockx_carplate ../../../rockx_carplate_demo/carplate_det_test1.jpg

(56 111 190 151) 0.986012

carplate: 苏JAY888

各模块运行时间和所需内存如下:

你可能感兴趣的:(rv1126,android)