Skip to content

Commit 4674afa

Browse files
committed
✨ Add opencv_extras recipe
1 parent e4404c8 commit 4674afa

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

pythonforandroid/recipes/opencv/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class OpenCVRecipe(NDKRecipe):
3232
'libopencv_dnn.so',
3333
'libopencv_imgcodecs.so',
3434
'libopencv_photo.so'
35+
# todo: add opencv_extras libraries
3536
]
3637

3738
def get_lib_dir(self, arch):
@@ -46,6 +47,16 @@ def get_recipe_env(self, arch):
4647
def build_arch(self, arch):
4748
build_dir = join(self.get_build_dir(arch.arch), 'build')
4849
shprint(sh.mkdir, '-p', build_dir)
50+
51+
opencv_extras = []
52+
if 'opencv_extras' in self.ctx.recipe_build_order:
53+
opencv_extras_dir = self.get_recipe(
54+
'opencv_extras', self.ctx).get_build_dir(arch.arch)
55+
opencv_extras = [
56+
f'-DOPENCV_EXTRA_MODULES_PATH={opencv_extras_dir}/modules',
57+
'-DBUILD_opencv_legacy=OFF',
58+
]
59+
4960
with current_directory(build_dir):
5061
env = self.get_recipe_env(arch)
5162

@@ -120,6 +131,8 @@ def build_arch(self, arch):
120131
'-DPYTHON{major}_PACKAGES_PATH={site_packages}'.format(
121132
major=python_major, site_packages=python_site_packages),
122133

134+
*opencv_extras,
135+
123136
self.get_build_dir(arch.arch),
124137
_env=env)
125138
shprint(sh.make, '-j' + str(cpu_count()), 'opencv_python' + python_major)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pythonforandroid.recipe import Recipe
2+
3+
4+
class OpenCVExtrasRecipe(Recipe):
5+
"""
6+
OpenCV extras recipe allows us to build extra modules from the
7+
`opencv_contrib` repository. It depends on opencv recipe and all the build
8+
of the modules will be performed inside opencv recipe build directory.
9+
10+
.. note:: the version of this recipe should be the same than opencv recipe.
11+
12+
.. warning:: Be aware that these modules are experimental, some of them
13+
maybe included in opencv future releases and removed from extras.
14+
15+
.. seealso:: https://github.com/opencv/opencv_contrib
16+
17+
"""
18+
version = '4.0.1'
19+
url = 'https://github.com/opencv/opencv_contrib/archive/{version}.zip'
20+
depends = ['opencv']
21+
22+
23+
recipe = OpenCVExtrasRecipe()

0 commit comments

Comments
 (0)