Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:opencv:install [2018/06/12 08:22] – [android method 2] scipio | tips:opencv:install [2018/06/13 09:06] (current) – scipio | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== opencv install ====== | ====== opencv install ====== | ||
+ | |||
+ | ===== android studio ===== | ||
+ | |||
+ | [[https:// | ||
===== linux ===== | ===== linux ===== | ||
Line 76: | Line 80: | ||
</ | </ | ||
- | ===== android | + | ===== android ===== |
prereq: | prereq: | ||
- | * substitute /opt/android-sdk/tools with https:// | + | * android |
- | * android sdk in / | + | |
+ | Download a stub android sdk and opencv sources | ||
< | < | ||
- | cd /opt | + | # adjust these paths ## |
- | git clone -b 3.4 --depth 1 https:// | + | REAL_ANDROID_SDK=/opt/ |
- | </ | + | # output builded opencv, can be removed after |
+ | BASE=/ | ||
+ | ####################### | ||
- | <file python platforms/ | ||
- | vars=dict(BUILD_ANDROID_PROJECTS=' | ||
- | |||
- | ABIs = [ | ||
- | # | ||
- | # | ||
- | ABI(" | ||
- | ABI(" | ||
- | # | ||
- | ] | ||
- | </ | ||
- | |||
- | create / | ||
- | < | ||
- | cd / | ||
- | python ./ | ||
- | | ||
- | | ||
- | | ||
- | / | ||
- | </ | ||
- | |||
- | ===== android method 2 ===== | ||
- | |||
- | Thank you to everyone for your help. | ||
- | |||
- | I recently had to build OpenCV for Android from source (because I wanted to link against LLVM libc++ STL instead of GNU STL). In case it’s useful to anyone else, here are some quick instructions on how I did it: | ||
- | |||
- | < | ||
- | $ mkdir ~/sdk && cd ~/sdk | ||
- | $ wget https:// | ||
- | $ tools/ | ||
- | Select and install the following two packages: | ||
- | Android SDK Build-tools 27.0.3 | ||
- | Android 8.1.0 (API 27) -> SDK Platform 27 | ||
- | $ mkdir ~/opencv && cd ~/opencv | ||
- | $ git clone https:// | ||
- | $ cd ~/ | ||
- | $ wget https:// | ||
- | $ cd platforms/ | ||
- | $ ANDROID_SDK=~/ | ||
- | </ | ||
- | |||
- | I already had the ANDROID_NDK environment variable set to a local NDK 16 installation. | ||
- | |||
- | To compile against libc++, I then changed ANDROID_STL=" | ||
- | |||
- | One unusual thing I couldn’t work out was why the static libs I built were much larger than those in the official distribution (e.g. my arm64-v8a/ | ||
- | @peterchaula | ||
- | peterchaula commented on Apr 11 | ||
- | |||
- | @ngriffiths you need to strip out intel threading libs (TBB). That' | ||
- | |||
- | ===== anroid method 3 ===== | ||
- | |||
- | < | ||
- | BASE=~/ | ||
mkdir -p ${BASE} | mkdir -p ${BASE} | ||
cd ${BASE} | cd ${BASE} | ||
Line 151: | Line 100: | ||
Select and install the following two packages: | Select and install the following two packages: | ||
Android SDK Build-tools 27.0.3 | Android SDK Build-tools 27.0.3 | ||
- | Android 8.1.0 (API 27) -> SDK Platform | + | Android 8.1.0 (API 27) -> SDK Platform |
git clone --depth 1 https:// | git clone --depth 1 https:// | ||
Line 159: | Line 108: | ||
cd platform/ | cd platform/ | ||
- | ANDROID_SDK=~/sdk ANDROID_HOME=~/sdk ./ | + | |
- | /< | + | # edit ndk-16.config.py |
+ | # ABI(" | ||
+ | |||
+ | ANDROID_SDK=${BASE} | ||
+ | --force_opencv_toolchain \ | ||
+ | --ndk_path ${REAL_ANDROID_SDK}/ | ||
+ | --config ndk-16.config.py | ||
+ | ${BASE}/ | ||
+ | </code> | ||
+ | |||
+ | To compile against libc++, I then changed ANDROID_STL=" | ||
+ | |||
+ | @ngriffiths you need to strip out intel threading libs (TBB). That' |