From 585cae279ea9bf0753bd5994e6be290004b5cb06 Mon Sep 17 00:00:00 2001 From: nihui Date: Sat, 2 Mar 2024 23:33:37 +0800 Subject: [PATCH] build yuzuki-chameleon package with hw jpg decoder (#102) --- .github/workflows/release.yml | 10 ++++++++ README.md | 15 ++++++++++-- highgui/src/jpeg_decoder_aw.cpp | 13 +++++++++- .../aarch64-openwrt-linux-gnu.toolchain.cmake | 24 +++++++++++++++++++ .../arm-openwrt-linux-gnueabi.toolchain.cmake | 24 +++++++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 toolchains/aarch64-openwrt-linux-gnu.toolchain.cmake create mode 100644 toolchains/arm-openwrt-linux-gnueabi.toolchain.cmake diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c75f1dbb..c9328f37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1172,6 +1172,16 @@ jobs: export TOOLCHAIN_ROOT_PATH=$GITHUB_WORKSPACE/toolchain-sunxi-musl-gcc-830/toolchain export STAGING_DIR=$GITHUB_WORKSPACE/toolchain-sunxi-musl-gcc-830/toolchain + - name: yuzuki-chameleon + single-core: false + cmake-toolchain: arm-openwrt-linux-gnueabi.toolchain.cmake + setup-toolchain-cmd: | + wget -q https://github.com/YuzukiHD/sunxi-bsp-toolchains/releases/download/1.0.0/toolchain-sunxi-glibc-arm-gcc-830.tar.gz + tar -xf toolchain-sunxi-glibc-arm-gcc-830.tar.gz + setup-env-cmd: | + export TOOLCHAIN_ROOT_PATH=$GITHUB_WORKSPACE/toolchain-sunxi-glibc-gcc-830/toolchain + export STAGING_DIR=$GITHUB_WORKSPACE/toolchain-sunxi-glibc-gcc-830/toolchain + - name: purple-pi single-core: false cmake-toolchain: arm-linux-gnueabihf.toolchain.cmake diff --git a/README.md b/README.md index 01a901af..13fa0e1e 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,19 @@ https://github.com/nihui/opencv-mobile/releases/latest opencv4-tinyvision + + + yuzuki-chameleon +
yuzuki-chameleon +
+
arm-openwrt-linux-gnueabi
+ ✅ HW JPG decoder
+ + opencv4-yuzuki-chameleon + + + + purple-pi @@ -348,8 +361,6 @@ https://github.com/nihui/opencv-mobile/releases/latest opencv4-purple-pi - - myir-t113i diff --git a/highgui/src/jpeg_decoder_aw.cpp b/highgui/src/jpeg_decoder_aw.cpp index 84f3f060..1021adaa 100644 --- a/highgui/src/jpeg_decoder_aw.cpp +++ b/highgui/src/jpeg_decoder_aw.cpp @@ -41,6 +41,7 @@ namespace cv { // 0 = unknown // 1 = t113-i // 2 = tinyvision +// 3 = yuzuki-chameleon static int get_device_model() { static int device_model = -1; @@ -67,6 +68,11 @@ static int get_device_model() // tinyvision device_model = 2; } + if (strncmp(buf, "sun50iw9", 8) == 0) + { + // yuzuki-chameleon + device_model = 3; + } } return device_model; @@ -86,6 +92,11 @@ static bool is_device_whitelisted() // tinyvision return true; } + if (device_model == 3) + { + // yuzuki-chameleon + return true; + } return false; } @@ -1111,7 +1122,7 @@ int jpeg_decoder_aw_impl::decode(const unsigned char* jpgdata, int jpgsize, unsi vconfig_v85x.nRotateHoldingFrameBufferNum = 0; vconfig_v85x.nDecodeSmoothFrameBufferNum = 1; - VConfig* p_vconfig = get_device_model() == 2 ? (VConfig*)&vconfig_v85x : &vconfig; + VConfig* p_vconfig = (get_device_model() == 2 || get_device_model() == 3) ? (VConfig*)&vconfig_v85x : &vconfig; int ret = InitializeVideoDecoder(vdec, &videoInfo, p_vconfig); if (ret != 0) diff --git a/toolchains/aarch64-openwrt-linux-gnu.toolchain.cmake b/toolchains/aarch64-openwrt-linux-gnu.toolchain.cmake new file mode 100644 index 00000000..6d1cca16 --- /dev/null +++ b/toolchains/aarch64-openwrt-linux-gnu.toolchain.cmake @@ -0,0 +1,24 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +if(DEFINED ENV{TOOLCHAIN_ROOT_PATH}) + file(TO_CMAKE_PATH $ENV{TOOLCHAIN_ROOT_PATH} TOOLCHAIN_ROOT_PATH) +else() + message(FATAL_ERROR "TOOLCHAIN_ROOT_PATH env must be defined") +endif() + +set(TOOLCHAIN_ROOT_PATH ${TOOLCHAIN_ROOT_PATH} CACHE STRING "root path to toolchain") + +set(CMAKE_C_COMPILER "${TOOLCHAIN_ROOT_PATH}/bin/aarch64-openwrt-linux-gnu-gcc") +set(CMAKE_CXX_COMPILER "${TOOLCHAIN_ROOT_PATH}/bin/aarch64-openwrt-linux-gnu-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv8-a") +set(CMAKE_CXX_FLAGS "-march=armv8-a") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/toolchains/arm-openwrt-linux-gnueabi.toolchain.cmake b/toolchains/arm-openwrt-linux-gnueabi.toolchain.cmake new file mode 100644 index 00000000..40d1408f --- /dev/null +++ b/toolchains/arm-openwrt-linux-gnueabi.toolchain.cmake @@ -0,0 +1,24 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +if(DEFINED ENV{TOOLCHAIN_ROOT_PATH}) + file(TO_CMAKE_PATH $ENV{TOOLCHAIN_ROOT_PATH} TOOLCHAIN_ROOT_PATH) +else() + message(FATAL_ERROR "TOOLCHAIN_ROOT_PATH env must be defined") +endif() + +set(TOOLCHAIN_ROOT_PATH ${TOOLCHAIN_ROOT_PATH} CACHE STRING "root path to toolchain") + +set(CMAKE_C_COMPILER "${TOOLCHAIN_ROOT_PATH}/bin/arm-openwrt-linux-gnueabi-gcc") +set(CMAKE_CXX_COMPILER "${TOOLCHAIN_ROOT_PATH}/bin/arm-openwrt-linux-gnueabi-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")