Skip to content

Commit

Permalink
[Android] integrate flycv to Android (#459)
Browse files Browse the repository at this point in the history
* [Android] integrate flycv into Andorid

* Falconcv (#27)

* [Bug Fix ]Update ppseg visualize python api && demo (#454)

Update ppseg visualize python api && demo

* [Model] update pptracking letterboxresize and add some comment (#438)

* add override mark

* delete some

* recovery

* recovery

* add tracking

* add tracking py_bind and example

* add pptracking

* add pptracking

* iomanip head file

* add opencv_video lib

* add python libs package

Signed-off-by: ChaoII <849453582@qq.com>

* complete comments

Signed-off-by: ChaoII <849453582@qq.com>

* add jdeTracker_ member variable

Signed-off-by: ChaoII <849453582@qq.com>

* add 'FASTDEPLOY_DECL' macro

Signed-off-by: ChaoII <849453582@qq.com>

* remove kwargs params

Signed-off-by: ChaoII <849453582@qq.com>

* [Doc]update pptracking docs

* delete 'ENABLE_PADDLE_FRONTEND' switch

* add pptracking unit test

* update pptracking unit test

Signed-off-by: ChaoII <849453582@qq.com>

* modify test video file path and remove trt test

* update unit test model url

* remove 'FASTDEPLOY_DECL' macro

Signed-off-by: ChaoII <849453582@qq.com>

* fix build python packages about pptracking on win32

Signed-off-by: ChaoII <849453582@qq.com>

* update comment

Signed-off-by: ChaoII <849453582@qq.com>

* add pptracking model explain

Signed-off-by: ChaoII <849453582@qq.com>

Signed-off-by: ChaoII <849453582@qq.com>
Co-authored-by: Jason <jiangjiajun@baidu.com>

Signed-off-by: ChaoII <849453582@qq.com>
Co-authored-by: huangjianhui <852142024@qq.com>
Co-authored-by: ChaoII <849453582@qq.com>
Co-authored-by: Jason <jiangjiajun@baidu.com>

* [cmake] optimize examples CMakeLists.txt

Signed-off-by: ChaoII <849453582@qq.com>
Co-authored-by: huangjianhui <852142024@qq.com>
Co-authored-by: ChaoII <849453582@qq.com>
Co-authored-by: Jason <jiangjiajun@baidu.com>
  • Loading branch information
4 people authored Oct 30, 2022
1 parent b1bdd93 commit a9f7fe2
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 32 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ option(ENABLE_OPENVINO_BACKEND "Whether to enable openvino backend." OFF)
option(ENABLE_LITE_BACKEND "Whether to enable paddle lite backend." OFF)
option(ENABLE_VISION "Whether to enable vision models usage." OFF)
option(ENABLE_TEXT "Whether to enable text models usage." OFF)
option(ENABLE_FLYCV "Whether to enable flycv to boost image preprocess." OFF)
option(WITH_TESTING "Whether to compile with unittest." OFF)
############################# Options for Android cross compiling #########################
option(WITH_OPENCV_STATIC "Use OpenCV static lib for Android." OFF)
Expand Down
12 changes: 10 additions & 2 deletions FastDeploy.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,17 @@ if(ENABLE_VISION)

if(ENABLE_FLYCV)
include_directories(${CMAKE_CURRENT_LIST_DIR}/third_libs/install/flycv/include)
find_library(FLYCV_LIB flycv_shared ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/flycv/lib NO_DEFAULT_PATH)
list(APPEND FASTDEPLOY_LIBS ${FLYCV_LIB})
set(FLYCV_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/flycv/lib)
if(ANDROID)
add_library(flycv_shared STATIC IMPORTED GLOBAL)
set_property(TARGET flycv_shared PROPERTY IMPORTED_LOCATION ${FLYCV_LIB_DIR}/${ANDROID_ABI}/libflycv_shared.so)
list(APPEND FASTDEPLOY_LIBS flycv_shared)
else()
find_library(FLYCV_LIB flycv_shared ${FLYCV_LIB_DIR} NO_DEFAULT_PATH)
list(APPEND FASTDEPLOY_LIBS ${FLYCV_LIB})
endif()
endif()

endif()

if (ENABLE_TEXT)
Expand Down
89 changes: 66 additions & 23 deletions cmake/flycv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,42 @@ set(FLYCV_INSTALL_DIR ${THIRD_PARTY_PATH}/install/flycv)
set(FLYCV_INC_DIR
"${FLYCV_INSTALL_DIR}/include"
CACHE PATH "flycv include directory." FORCE)
set(FLYCV_LIB_DIR
"${FLYCV_INSTALL_DIR}/lib/"
CACHE PATH "flycv lib directory." FORCE)
if(ANDROID)
set(FLYCV_LIB_DIR
"${FLYCV_INSTALL_DIR}/lib/${ANDROID_ABI}"
CACHE PATH "flycv lib directory." FORCE)
else()
set(FLYCV_LIB_DIR
"${FLYCV_INSTALL_DIR}/lib/"
CACHE PATH "flycv lib directory." FORCE)
endif()
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}"
"${FLYCV_LIB_DIR}")

include_directories(${FLYCV_INC_DIR})

# ABI check
if(ANDROID)
if((NOT ANDROID_ABI MATCHES "armeabi-v7a") AND (NOT ANDROID_ABI MATCHES "arm64-v8a"))
message(FATAL_ERROR "FastDeploy with FlyCV only support armeabi-v7a, arm64-v8a now.")
endif()
if(NOT ANDROID_TOOLCHAIN MATCHES "clang")
message(FATAL_ERROR "Currently, only support clang toolchain while cross compiling FastDeploy for Android with FlyCV, but found ${ANDROID_TOOLCHAIN}.")
endif()
endif()

if(WIN32)
set(FLYCV_COMPILE_LIB
"${FLYCV_INSTALL_DIR}/lib/flycv.lib"
CACHE FILEPATH "flycv compile library." FORCE)
elseif(APPLE)
set(FLYCV_COMPILE_LIB
"${FLYCV_INSTALL_DIR}/lib/libflycv.dylib"
CACHE FILEPATH "flycv compile library." FORCE)
CACHE FILEPATH "flycv compile library." FORCE)
elseif(ANDROID)
set(FLYCV_COMPILE_LIB
"${FLYCV_INSTALL_DIR}/lib/${ANDROID_ABI}/libflycv_shared.so"
CACHE FILEPATH "flycv compile library." FORCE)
else()
set(FLYCV_COMPILE_LIB
"${FLYCV_INSTALL_DIR}/lib/libflycv_shared.so"
Expand All @@ -45,41 +66,63 @@ endif(WIN32)
set(FLYCV_URL_BASE "https://bj.bcebos.com/fastdeploy/third_libs/")
set(FLYCV_VERSION "1.0.1025")
if(WIN32)
message(FATAL_ERROR "FalconCV is not supported on Windows now.")
message(FATAL_ERROR "FlyCV is not supported on Windows now.")
set(FLYCV_FILE "flycv-win-x64-${FLYCV_VERSION}.zip")
elseif(APPLE)
message(FATAL_ERROR "FalconCV is not supported on Mac OSX now.")
message(FATAL_ERROR "FlyCV is not supported on Mac OSX now.")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
set(FLYCV_FILE "flycv-osx-arm64-${FLYCV_VERSION}.tgz")
else()
set(FLYCV_FILE "flycv-osx-x86_64-${FLYCV_VERSION}.tgz")
endif()
elseif(ANDROID)
set(FLYCV_FILE "flycv-android-${FLYCV_VERSION}.tgz")
else()
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
set(FLYCV_FILE "flycv-linux-aarch64-${FLYCV_VERSION}.tgz")
else()
message(FATAL_ERROR "FalconCV is not supported on Linux x64 now.")
message(FATAL_ERROR "FlyCV is not supported on Linux x64 now.")
set(FLYCV_FILE "flycv-linux-x64-${FLYCV_VERSION}.tgz")
endif()
endif()
set(FLYCV_URL "${FLYCV_URL_BASE}${FLYCV_FILE}")

ExternalProject_Add(
${FLYCV_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
URL ${FLYCV_URL}
PREFIX ${FLYCV_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND
${CMAKE_COMMAND} -E remove_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E make_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E rename ${FLYCV_SOURCE_DIR}/lib/
${FLYCV_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
${FLYCV_SOURCE_DIR}/include ${FLYCV_INC_DIR}
BUILD_BYPRODUCTS ${FLYCV_COMPILE_LIB})
if(ANDROID)
ExternalProject_Add(
${FLYCV_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
URL ${FLYCV_URL}
PREFIX ${FLYCV_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND
${CMAKE_COMMAND} -E remove_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E make_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E make_directory ${FLYCV_INSTALL_DIR}/lib &&
${CMAKE_COMMAND} -E rename ${FLYCV_SOURCE_DIR}/lib/${ANDROID_ABI}
${FLYCV_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
${FLYCV_SOURCE_DIR}/include ${FLYCV_INC_DIR}
BUILD_BYPRODUCTS ${FLYCV_COMPILE_LIB})
else()
ExternalProject_Add(
${FLYCV_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
URL ${FLYCV_URL}
PREFIX ${FLYCV_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND
${CMAKE_COMMAND} -E remove_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E make_directory ${FLYCV_INSTALL_DIR} &&
${CMAKE_COMMAND} -E rename ${FLYCV_SOURCE_DIR}/lib/
${FLYCV_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
${FLYCV_SOURCE_DIR}/include ${FLYCV_INC_DIR}
BUILD_BYPRODUCTS ${FLYCV_COMPILE_LIB})
endif()

add_library(external_flycv STATIC IMPORTED GLOBAL)
set_property(TARGET external_flycv PROPERTY IMPORTED_LOCATION
Expand Down
12 changes: 9 additions & 3 deletions cmake/paddlelite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ set(PADDLELITE_INSTALL_DIR ${THIRD_PARTY_PATH}/install/${PADDLELITE_FILENAME})
set(PADDLELITE_INC_DIR
"${PADDLELITE_INSTALL_DIR}/include"
CACHE PATH "paddlelite include directory." FORCE)
set(PADDLELITE_LIB_DIR
"${PADDLELITE_INSTALL_DIR}/lib/${ANDROID_ABI}"
CACHE PATH "paddlelite lib directory." FORCE)
if(ANDROID)
set(PADDLELITE_LIB_DIR
"${PADDLELITE_INSTALL_DIR}/lib/${ANDROID_ABI}"
CACHE PATH "paddlelite lib directory." FORCE)
else()
set(PADDLELITE_LIB_DIR
"${PADDLELITE_INSTALL_DIR}/lib/"
CACHE PATH "paddlelite lib directory." FORCE)
endif()
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLELITE_LIB_DIR}")

set(PADDLELITE_URL_PREFIX "https://bj.bcebos.com/fastdeploy/third_libs")
Expand Down
25 changes: 22 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ function(config_fastdeploy_executable_link_flags TARGET_NAME)
endif()
endfunction()

# Usage: add_fastdeploy_executable_cc_files(xxx_var vision detection)
function(add_fastdeploy_executable_cc_files CC_FILES_VAR FIELD SUB_FIELD)
file(GLOB_RECURSE _EXAMPLE_SRCS ${PROJECT_SOURCE_DIR}/examples/${FIELD}/${SUB_FIELD}/*/cpp/*.cc)
set(${CC_FILES_VAR} ${_EXAMPLE_SRCS} PARENT_SCOPE)
endfunction()

set(EXAMPLES_NUM 0)
function(add_fastdeploy_executable FIELD CC_FILE)
# temp target name/file var in function scope
Expand Down Expand Up @@ -69,9 +75,22 @@ if(BUILD_EXAMPLES AND ENABLE_VISION)
if(EXISTS ${PROJECT_SOURCE_DIR}/examples/vision)
message(STATUS "")
message(STATUS "*************FastDeploy Vision Examples Summary**********")
file(GLOB_RECURSE ALL_VISION_EXAMPLE_SRCS ${PROJECT_SOURCE_DIR}/examples/vision/*/*/cpp/*.cc)
foreach(_CC_FILE ${ALL_VISION_EXAMPLE_SRCS})
add_fastdeploy_executable(vision ${_CC_FILE})
set(ALL_VISION_SUD_FIELDS classification
detection
facedet
faceid
keypointdetection
matting
ocr
segmentation)
if(NOT ANDROID)
list(APPEND ALL_VISION_SUD_FIELDS tracking)
endif()
foreach(_SUB_FIELD ${ALL_VISION_SUD_FIELDS})
add_fastdeploy_executable_cc_files(_SUB_CC_FILES vision ${_SUB_FIELD})
foreach(_CC_FILE ${_SUB_CC_FILES})
add_fastdeploy_executable(vision ${_CC_FILE})
endforeach()
endforeach()
message(STATUS " [FastDeploy Executable Path] : ${EXECUTABLE_OUTPUT_PATH}")
endif()
Expand Down
1 change: 0 additions & 1 deletion fastdeploy/vision/tracking/pptracking/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "fastdeploy/vision/tracking/pptracking/model.h"
#include "yaml-cpp/yaml.h"
#include "paddle2onnx/converter.h"

namespace fastdeploy {
namespace vision {
Expand Down

0 comments on commit a9f7fe2

Please sign in to comment.