Skip to content

Commit

Permalink
✨ Add opencv_extras recipe (#2209)
Browse files Browse the repository at this point in the history
* ✨ 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
  • Loading branch information
opacam authored May 28, 2020
1 parent 0610d20 commit c8c9776
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pythonforandroid/recipes/opencv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OpenCVRecipe(NDKRecipe):
'libopencv_video.so',
'libopencv_dnn.so',
'libopencv_imgcodecs.so',
'libopencv_photo.so'
'libopencv_photo.so',
]

def get_lib_dir(self, arch):
Expand All @@ -46,6 +46,16 @@ def get_recipe_env(self, arch):
def build_arch(self, arch):
build_dir = join(self.get_build_dir(arch.arch), 'build')
shprint(sh.mkdir, '-p', build_dir)

opencv_extras = []
if 'opencv_extras' in self.ctx.recipe_build_order:
opencv_extras_dir = self.get_recipe(
'opencv_extras', self.ctx).get_build_dir(arch.arch)
opencv_extras = [
f'-DOPENCV_EXTRA_MODULES_PATH={opencv_extras_dir}/modules',
'-DBUILD_opencv_legacy=OFF',
]

with current_directory(build_dir):
env = self.get_recipe_env(arch)

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

*opencv_extras,

self.get_build_dir(arch.arch),
_env=env)
shprint(sh.make, '-j' + str(cpu_count()), 'opencv_python' + python_major)
Expand Down
23 changes: 23 additions & 0 deletions pythonforandroid/recipes/opencv_extras/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pythonforandroid.recipe import Recipe


class OpenCVExtrasRecipe(Recipe):
"""
OpenCV extras recipe allows us to build extra modules from the
`opencv_contrib` repository. It depends on opencv recipe and all the build
of the modules will be performed inside opencv recipe build directory.
.. note:: the version of this recipe should be the same than opencv recipe.
.. warning:: Be aware that these modules are experimental, some of them
maybe included in opencv future releases and removed from extras.
.. seealso:: https://github.com/opencv/opencv_contrib
"""
version = '4.0.1'
url = 'https://github.com/opencv/opencv_contrib/archive/{version}.zip'
depends = ['opencv']


recipe = OpenCVExtrasRecipe()

0 comments on commit c8c9776

Please sign in to comment.