Merge pull request #16832 from liqi-c:3.4-tengine-android

* Add android support for tengine

* modify tengine download use commit id

* Del some invalid log in Tengine

* Test. default enable tengine

* ndk version judegment

* Close test . set Tengine default OFF

* Logic problem

* test .Android NDK judgement .

* Cmake error modify.

* cmake: cleanup tengine scripts

* cmake: use tengine target name

* cmake: disable testing of BUILD_ANDROID_PROJECTS=OFF

* Close test .
pull/16863/head^2
NesQl 5 years ago committed by GitHub
parent 8ac333697d
commit bf224e61a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 57
      3rdparty/libtengine/tengine.cmake
  2. 2
      CMakeLists.txt
  3. 39
      cmake/OpenCVFindTengine.cmake

@ -22,69 +22,70 @@
# sqfu@openailab.com # sqfu@openailab.com
# #
SET(TENGINE_VERSION "tengine-opencv") SET(TENGINE_COMMIT_VERSION "2f3cd86217f3530c8e4a82f3ed5af14c7a4e3943")
SET(OCV_TENGINE_DSTDIRECTORY ${OpenCV_BINARY_DIR}/3rdparty/libtengine) SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
SET(DEFAULT_OPENCV_TENGINE_SOURCE_PATH ${OCV_TENGINE_DSTDIRECTORY}/Tengine-${TENGINE_VERSION}) SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
IF(EXISTS ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}) IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
MESSAGE(STATUS "Tengine is exist already .") MESSAGE(STATUS "Tengine is exist already at: ${OCV_TENGINE_SOURCE_PATH}")
SET(Tengine_FOUND ON) SET(Tengine_FOUND ON)
set(BUILD_TENGINE ON) SET(BUILD_TENGINE ON)
ELSE() ELSE()
SET(OCV_TENGINE_FILENAME "${TENGINE_VERSION}.zip")#name2 SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name2
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2 SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2
SET(tengine_md5sum 9c80d91dc8413911522ec80cde013ae2) #md5sum2 SET(tengine_md5sum 9124324b6e2b350012e46ae1db4bad7d) #md5sum2
MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****") #MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
ocv_download(FILENAME ${OCV_TENGINE_FILENAME} ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
HASH ${tengine_md5sum} HASH ${tengine_md5sum}
URL URL
"${OPENCV_TENGINE_URL}" "${OPENCV_TENGINE_URL}"
"$ENV{OPENCV_TENGINE_URL}" "$ENV{OPENCV_TENGINE_URL}"
"${OCV_TENGINE_URL}" "${OCV_TENGINE_URL}"
DESTINATION_DIR ${OCV_TENGINE_DSTDIRECTORY} DESTINATION_DIR "${OCV_TENGINE_DIR}"
ID TENGINE ID TENGINE
STATUS res STATUS res
UNPACK RELATIVE_URL) UNPACK RELATIVE_URL)
if (NOT res) if (NOT res)
MESSAGE(STATUS "TENGINE DOWNLOAD FAILED .Turning Tengine_FOUND off.") MESSAGE(STATUS "TENGINE DOWNLOAD FAILED. Turning Tengine_FOUND off.")
SET(Tengine_FOUND OFF) SET(Tengine_FOUND OFF)
else () else ()
MESSAGE(STATUS "TENGINE DOWNLOAD success . ") MESSAGE(STATUS "TENGINE DOWNLOAD success . ")
SET(Tengine_FOUND ON) SET(Tengine_FOUND ON)
set(BUILD_TENGINE ON) SET(BUILD_TENGINE ON)
endif() endif()
ENDIF() ENDIF()
if (BUILD_TENGINE) if(BUILD_TENGINE)
set(HAVE_TENGINE 1) SET(HAVE_TENGINE 1)
# android system # android system
if(ANDROID) if(ANDROID)
if(${ANDROID_ABI} STREQUAL "armeabi-v7a") if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
set(CONFIG_ARCH_ARM32 ON) SET(CONFIG_ARCH_ARM32 ON)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
set(CONFIG_ARCH_ARM64 ON) SET(CONFIG_ARCH_ARM64 ON)
endif() endif()
endif() SET(Tengine_LIB "tengine" CACHE INTERNAL "")
else()
# linux system # linux system
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
set(CONFIG_ARCH_ARM32 ON) SET(CONFIG_ARCH_ARM32 ON)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
set(CONFIG_ARCH_ARM64 ON) SET(CONFIG_ARCH_ARM64 ON)
endif()
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
endif() endif()
SET(DEFAULT_OPENCV_TENGINE_SOURCE_PATH ${OCV_TENGINE_DSTDIRECTORY}/Tengine-${TENGINE_VERSION}) SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
set(BUILT_IN_OPENCV ON) ## set for tengine compile discern . SET(Tengine_INCLUDE_DIR "${OCV_TENGINE_SOURCE_PATH}/core/include" CACHE INTERNAL "")
set(Tengine_INCLUDE_DIR ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}/core/include) if(EXISTS "${OCV_TENGINE_SOURCE_PATH}/CMakeLists.txt")
set(Tengine_LIB ${CMAKE_BINARY_DIR}/lib/${ANDROID_ABI}/libtengine.a) add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build")
if ( IS_DIRECTORY ${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}) else()
add_subdirectory("${DEFAULT_OPENCV_TENGINE_SOURCE_PATH}" ${OCV_TENGINE_DSTDIRECTORY}/build) message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}")
SET(HAVE_TENGINE 1)
endif() endif()
endif() endif()

@ -433,7 +433,7 @@ OCV_OPTION(WITH_QUIRC "Include library QR-code decoding" ON
VISIBLE_IF TRUE VISIBLE_IF TRUE
VERIFY HAVE_QUIRC) VERIFY HAVE_QUIRC)
OCV_OPTION(WITH_TENGINE "Include Arm Inference Tengine support" OFF OCV_OPTION(WITH_TENGINE "Include Arm Inference Tengine support" OFF
VISIBLE_IF (ARM OR AARCH64) AND UNIX AND NOT ANDROID AND NOT IOS VISIBLE_IF (ARM OR AARCH64) AND (UNIX OR ANDROID) AND NOT IOS
VERIFY HAVE_TENGINE) VERIFY HAVE_TENGINE)
# OpenCV build components # OpenCV build components

@ -21,25 +21,42 @@
# #
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Path for Tengine modules # Path for Tengine binaries
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Where to look for additional OpenCV modules (can be ;-separated list of paths)") set(OPENCV_LIBTENGINE_ROOT_DIR "" CACHE PATH "Path to TENGINE binaries installation")
IF(OPENCV_LIBTENGINE_ROOT_DIR) IF(OPENCV_LIBTENGINE_ROOT_DIR AND NOT BUILD_TENGINE)
MESSAGE(STATUS "TENGINE:-- Set tengine lib dir by user ") MESSAGE(STATUS "TENGINE:-- Use binaries at ${OPENCV_LIBTENGINE_ROOT_DIR}")
SET(Tengine_FOUND ON) SET(Tengine_FOUND ON)
set(BUILD_TENGINE OFF) set(BUILD_TENGINE OFF)
SET(Tengine_INCLUDE_DIR ${OPENCV_LIBTENGINE_ROOT_DIR}/include) SET(Tengine_INCLUDE_DIR "${OPENCV_LIBTENGINE_ROOT_DIR}/include" CACHE PATH "TENGINE include dir")
SET(Tengine_LIB ${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a) SET(Tengine_LIB "${OPENCV_LIBTENGINE_ROOT_DIR}/lib/libtengine.a" CACHE PATH "TENGINE library dir")
ELSE() ELSE()
IF(ANDROID)
MESSAGE(STATUS "TENGINE:-- Auto download Tengine source code. ") IF(OPENCV_TENGINE_FORCE_ANDROID)
# nothing, use Android
ELSEIF(OPENCV_TENGINE_SKIP_ANDROID)
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ELSEIF(NOT DEFINED ANDROID_NDK_REVISION)
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION is not defined")
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ELSEIF(ANDROID_NDK_REVISION VERSION_LESS 14)
MESSAGE(STATUS "Android NDK version Tengine not support: ANDROID_NDK_REVISION=${ANDROID_NDK_REVISION}")
set(Tengine_FOUND OFF)
set(HAVE_TENGINE FALSE)
return()
ENDIF()
ENDIF()
MESSAGE(STATUS "TENGINE:-- Build Tengine from source code. ")
include("${OpenCV_SOURCE_DIR}/3rdparty/libtengine/tengine.cmake") include("${OpenCV_SOURCE_DIR}/3rdparty/libtengine/tengine.cmake")
ENDIF() ENDIF()
IF(NOT Tengine_LIB) IF(NOT Tengine_LIB)
@ -55,11 +72,7 @@ IF (Tengine_FOUND)
set(TENGINE_INCLUDE_DIRS ${Tengine_INCLUDE_DIR}) set(TENGINE_INCLUDE_DIRS ${Tengine_INCLUDE_DIR})
ENDIF (Tengine_FOUND) ENDIF (Tengine_FOUND)
MESSAGE(STATUS "Tengine include is:" ${Tengine_INCLUDE_DIR})
MESSAGE(STATUS "Tengine library is:" ${Tengine_LIB})
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
Tengine_INCLUDE_DIR Tengine_INCLUDE_DIR
Tengine_LIB Tengine_LIB
Tengine
) )

Loading…
Cancel
Save