Skip to content

Commit c8c9776

Browse files
authored
✨ Add opencv_extras recipe (kivy#2209)
* ✨ Add `opencv_extras` recipe * 🚧 Test `opencv_extras` build via github actions * ⏪ Revert "🚧 Test `opencv_extras` build via github actions" This reverts commit eb6cc6b * 👌 Remove unneeded development inline comment
1 parent 0610d20 commit c8c9776

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

pythonforandroid/recipes/opencv/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class OpenCVRecipe(NDKRecipe):
3131
'libopencv_video.so',
3232
'libopencv_dnn.so',
3333
'libopencv_imgcodecs.so',
34-
'libopencv_photo.so'
34+
'libopencv_photo.so',
3535
]
3636

3737
def get_lib_dir(self, arch):
@@ -46,6 +46,16 @@ def get_recipe_env(self, arch):
4646
def build_arch(self, arch):
4747
build_dir = join(self.get_build_dir(arch.arch), 'build')
4848
shprint(sh.mkdir, '-p', build_dir)
49+
50+
opencv_extras = []
51+
if 'opencv_extras' in self.ctx.recipe_build_order:
52+
opencv_extras_dir = self.get_recipe(
53+
'opencv_extras', self.ctx).get_build_dir(arch.arch)
54+
opencv_extras = [
55+
f'-DOPENCV_EXTRA_MODULES_PATH={opencv_extras_dir}/modules',
56+
'-DBUILD_opencv_legacy=OFF',
57+
]
58+
4959
with current_directory(build_dir):
5060
env = self.get_recipe_env(arch)
5161

@@ -120,6 +130,8 @@ def build_arch(self, arch):
120130
'-DPYTHON{major}_PACKAGES_PATH={site_packages}'.format(
121131
major=python_major, site_packages=python_site_packages),
122132

133+
*opencv_extras,
134+
123135
self.get_build_dir(arch.arch),
124136
_env=env)
125137
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)