|
9 | 9 |
|
10 | 10 |
|
11 | 11 | class OpenCVRecipe(NDKRecipe): |
12 | | - version = '2.4.10.1' |
13 | | - url = 'https://github.com/Itseez/opencv/archive/{version}.zip' |
14 | | - # md5sum = '2ddfa98e867e6611254040df841186dc' |
| 12 | + version = '4.0.1' |
| 13 | + url = 'https://github.com/opencv/opencv/archive/{version}.zip' |
15 | 14 | depends = ['numpy'] |
16 | | - patches = ['patches/p4a_build-2.4.10.1.patch'] |
17 | | - generated_libraries = ['cv2.so'] |
18 | | - |
19 | | - def prebuild_arch(self, arch): |
20 | | - self.apply_patches(arch) |
21 | 15 |
|
22 | 16 | def get_recipe_env(self, arch): |
23 | 17 | env = super(OpenCVRecipe, self).get_recipe_env(arch) |
24 | | - env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() |
25 | 18 | env['ANDROID_NDK'] = self.ctx.ndk_dir |
26 | 19 | env['ANDROID_SDK'] = self.ctx.sdk_dir |
27 | | - env['SITEPACKAGES_PATH'] = self.ctx.get_site_packages_dir() |
28 | 20 | return env |
29 | 21 |
|
| 22 | + def should_build(self, arch): |
| 23 | + return True |
| 24 | + |
30 | 25 | def build_arch(self, arch): |
31 | | - with current_directory(self.get_build_dir(arch.arch)): |
| 26 | + build_dir = os.path.join(self.get_build_dir(arch.arch), 'build') |
| 27 | + shprint(sh.mkdir, '-p', build_dir) |
| 28 | + with current_directory(build_dir): |
32 | 29 | env = self.get_recipe_env(arch) |
33 | | - cvsrc = self.get_build_dir(arch.arch) |
34 | | - lib_dir = os.path.join(self.ctx.get_python_install_dir(), "lib") |
35 | | - |
36 | 30 | shprint(sh.cmake, |
37 | | - '-DP4A=ON', '-DANDROID_ABI={}'.format(arch.arch), |
38 | | - '-DCMAKE_TOOLCHAIN_FILE={}/platforms/android/android.toolchain.cmake'.format(cvsrc), |
39 | | - '-DPYTHON_INCLUDE_PATH={}/include/python2.7'.format(env['PYTHON_ROOT']), |
40 | | - '-DPYTHON_LIBRARY={}/lib/libpython2.7.so'.format(env['PYTHON_ROOT']), |
41 | | - '-DPYTHON_NUMPY_INCLUDE_DIR={}/numpy/core/include'.format(env['SITEPACKAGES_PATH']), |
| 31 | + '-DANDROID_ABI={}'.format(arch.arch), |
| 32 | + '-DCMAKE_TOOLCHAIN_FILE={}/build/cmake/android.toolchain.cmake'.format(self.ctx.ndk_dir), |
| 33 | + '-DPYTHON_NUMPY_INCLUDE_DIR={}/numpy/core/include'.format(self.ctx.get_site_packages_dir()), |
42 | 34 | '-DANDROID_EXECUTABLE={}/tools/android'.format(env['ANDROID_SDK']), |
43 | | - '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', |
| 35 | + '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DENABLE_TESTING=OFF', |
44 | 36 | '-DBUILD_EXAMPLES=OFF', '-DBUILD_ANDROID_EXAMPLES=OFF', |
45 | | - '-DPYTHON_PACKAGES_PATH={}'.format(env['SITEPACKAGES_PATH']), |
46 | | - cvsrc, |
| 37 | + '-DBUILD_opencv_imgproc=OFF', '-DBUILD_opencv_flann=OFF', |
| 38 | + '-DBUILD_opencv_python3=ON', |
| 39 | + '-DBUILD_WITH_STANDALONE_TOOLCHAIN=ON', |
| 40 | + '-DPYTHON_PACKAGES_PATH={}'.format(self.ctx.get_site_packages_dir()), |
| 41 | + '-DANDROID_STANDALONE_TOOLCHAIN={}'.format(self.ctx.ndk_dir), |
| 42 | + '-DANDROID_NATIVE_API_LEVEL={}'.format(self.ctx.android_api), |
| 43 | + self.get_build_dir(arch.arch), |
47 | 44 | _env=env) |
48 | | - shprint(sh.make, '-j', str(cpu_count()), 'opencv_python') |
| 45 | + shprint(sh.make, '-j', str(cpu_count())) |
49 | 46 | shprint(sh.cmake, '-DCOMPONENT=python', '-P', './cmake_install.cmake') |
50 | | - sh.cp('-a', sh.glob('./lib/{}/lib*.so'.format(arch.arch)), lib_dir) |
| 47 | + sh.cp('-a', sh.glob('./lib/{}/lib*.a'.format(arch.arch)), self.ctx.get_libs_dir(arch.arch)) |
| 48 | + self.ctx.get_libs_dir(arch.arch) |
51 | 49 |
|
52 | 50 |
|
53 | 51 | recipe = OpenCVRecipe() |
0 commit comments