elucideye / acf

Aggregated Channel Feature object detection in C++ and OpenGL ES 2.0 based on https://github.com/pdollar/toolbox
BSD 3-Clause "New" or "Revised" License
49 stars 20 forks source link

How to build libacf in iOS? #59

Closed haithanhp closed 5 years ago

haithanhp commented 6 years ago

Hi, Thanks for great work. Could you show me the step by step to build libraries for iOS? I try to run command polly.py --toolchain ios --config RELEASE --fwd HUNTER_CONFIGURATION_TYPES=RELEASE --install --verbose But I get the error: Environment variable POLLY_IOS_DEVELOPMENT_TEAM is empty (see details: http://polly.readthedocs.io/en/latest/toolchains/ios/errors/polly_ios_development_team.html)

CMake Error at /Users/mac/Documents/Workspace/acf/polly-master/utilities/polly_fatal_error.cmake:10 (message): Call Stack (most recent call first): /Users/mac/Documents/Workspace/acf/polly-master/utilities/polly_ios_development_team.cmake:15 (polly_fatal_error) /Users/mac/Documents/Workspace/acf/polly-master/ios.cmake:47 (include) /Users/mac/Documents/Workspace/acf/_ci/cmake/share/cmake-3.11/Modules/CMakeDetermineSystem.cmake:94 (include) CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!

[hunter INTERNAL ] Configure project failed [hunter INTERNAL ] [Directory:/Users/mac/Documents/Workspace/acf]

------------------------------ WIKI ------------------------------- https://github.com/ruslo/hunter/wiki/error.internal

CMake Error at cmake/HunterGate.cmake:83 (message): Call Stack (most recent call first): cmake/HunterGate.cmake:93 (hunter_gate_wiki) cmake/HunterGate.cmake:333 (hunter_gate_internal_error) cmake/HunterGate.cmake:513 (hunter_gate_download) CMakeLists.txt:84 (HunterGate)

-- Configuring incomplete, errors occurred!

Could yoi help me to solve this? Thanks.

headupinclouds commented 6 years ago

But I get the error: Environment variable POLLY_IOS_DEVELOPMENT_TEAM is empty (see details: http://polly.readthedocs.io/en/latest/toolchains/ios/errors/polly_ios_development_team.html)

Take a look at the link provided in the polly log message. It should tell you what you need to do. If you are still having problems let me know. That should get your build working. After that, you may have to decide how you want to integrate the library in your project. If you build your application or SDK with Hunter, it will be straightforward. If you want to integrate in an existing application without using Hunter, then you could create a dynamic framework to drop into an Xcode project. I'll follow up with some notes on how to do that.

This repository makes use of the cross platform unit testing framework gauze. If you want to confirm that things are building/running properly for your device, or you want to run a benchmark, you can do the following:

headupinclouds commented 6 years ago

I've added ACF_BUILD_SHARED_SDK in #60 , so you can generate a dynamic framework for iOS using a command like this:

polly.py --toolchain ${TOOLCHAIN} --config ${CONFIG} --fwd HUNTER_CONFIGURATION_TYPES=${CONFIG} ACF_BUILD_SHARED_SDK=ON --install --verbose --framework --reconfig --framework-lib libacf.dylib

I've added some additional notes for this scenario in the README here

haithanhp commented 6 years ago

Thank you so much. I will try to use it for my iOS project and give you the feedbacks. Thanks again for supporting me.

haithanhp commented 6 years ago

Hi, I use your updated codes to build library for iOS. However, I got the error. Here is the log file.

log.txt

I use command line: polly.py --toolchain ios --config RELEASE --fwd HUNTER_CONFIGURATION_TYPES=RELEASE ACF_BUILD_SHARED_SDK=ON --install --verbose --framework --reconfig --framework-lib libacf.dylib

headupinclouds commented 6 years ago

At first glance it looks like the OpenCV WebP dependency is failing due to some SIMD ARM NEON optimizations that aren't supported (possibly because it is attempting to use those on a simulator architecture). I'll try to reproduce that later this week. There are 3 things you can try:

1) Disable WebP in your OpenCV package. You can do that by modifying cmake/Hunter/config.cmake:

if(IOS OR ANDROID)
  # local workaround for protobuf compiler crash with Xcode 8.1
  # see https://github.com/elucideye/acf/issues/41
  set(opencv_cmake_args
    WITH_PROTOBUF=OFF
    BUILD_PROTOBUF=OFF
    BUILD_LIBPROTOBUF_FROM_SOURCES=NO
    BUILD_opencv_dnn=OFF

    WITH_JASPER=OFF
    BUILD_JASPER=OFF

    WITH_WEBP=OFF  ####### ADD
    BUILD_WEBP=OFF ####### ADD
  )
  hunter_config(OpenCV VERSION ${HUNTER_OpenCV_VERSION} CMAKE_ARGS ${opencv_cmake_args})  
endif()

2) Skip the simulator architectures. For the ios.cmake toolchain you may end up building 5 architectures, which can take a long time.

See: https://github.com/ruslo/polly/blob/4dcb237f387d445d8b82e9c26a582b4ec7519855/ios.cmake#L32-L40

My guess is that this is related to webp + simulator builds.

grep IPHONESIMULATOR_ARCH ${POLLY_ROOT}/ios.cmake 
  set(IPHONESIMULATOR_ARCHS i386;x86_64)

You could find an iOS toolchain that matches your desired Xcode + iOS SDK version using only device architectures and try that. For example, my current xcrun --sdk iphoneos --show-sdk-version reports 11.3, in which case I might use the following single architecture toolchain ios-11-3-dep-9-0-arm64.

3) Try to debug the OpenCV + WebP build logic. It looks like you've hit a bug, and it would be nice to sort it out upstream.

headupinclouds commented 6 years ago

This should be fixed in Hunter v0.20.75 (available here after merging #65)

credit @ruslo :

headupinclouds commented 6 years ago

Please pull the latest and test with ACF >= v0.1.7. The opencv+webp+simulator issue should be resolved.

headupinclouds commented 5 years ago

Closing old issue