Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()