openCV android SDK编译
1.环境变量设置 ~/.bashrc
export ANDROID_HOME="/media/vicent/NewDisk2/bin_linux/android-sdk-linux"
export ANDROID_SDK="/media/vicent/NewDisk2/bin_linux/android-sdk-linux"
export ANDROID_SDK_ROOT="/media/vicent/NewDisk2/bin_linux/android-sdk-linux"
export ANDROID_NDK_HOME="/media/vicent/NewDisk2/bin_linux/android-sdk-linux/ndk-bundle"
export ANDROID_NDK="/media/vicent/NewDisk2/bin_linux/android-sdk-linux/ndk-bundle"
export NDKROOT="/media/vicent/NewDisk2/bin_linux/android-sdk-linux/ndk-bundle"
2.python编译
python3 [src_dir]/build_sdk.py [out_dir] [src_dir]
#实例:
#/opencv/opencv$ python3 ./platforms/android/build_sdk.py ./mysdk-build/ ./
编译扩展
python3 ./platforms/android/build_sdk.py ./mysdk-build/ ./ --extra_modules_path=
3.编译opencl
./platforms/android/build_sdk.py 中
WITH_OPENCL
def build_library(self, abi, do_install):
cmd = ["cmake", "-GNinja"]
cmake_vars = dict(
CMAKE_TOOLCHAIN_FILE=self.get_toolchain_file(),
INSTALL_CREATE_DISTRIB="ON",
WITH_OPENCL="ON",//change
WITH_IPP=("ON" if abi.haveIPP() else "OFF"),
WITH_TBB="ON",
BUILD_EXAMPLES="OFF",
BUILD_TESTS="OFF",
BUILD_PERF_TESTS="OFF",
BUILD_DOCS="OFF",
BUILD_ANDROID_EXAMPLES="ON",
INSTALL_ANDROID_EXAMPLES="ON",
)
./modules/core/src/opencl/runtime/opencl_core.cpp
找到 #if defined(__linux__)
这一项将其修改为:
#if defined(__linux__)&&!defined(__ANDROID__)