opencv4.0.1编译Android opencv SDK-ubuntu

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编译

python [src_dir]/build_sdk.py [out_dir] [src_dir]
#实例:
#/opencv/opencv$ python ./platforms/android/build_sdk.py ./mysdk-build/ ./

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__)

你可能感兴趣的:(Android源码,算法)