Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add opencv_extras recipe #2209

Merged
merged 4 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 13 additions & 0 deletions pythonforandroid/recipes/opencv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OpenCVRecipe(NDKRecipe):
'libopencv_dnn.so',
'libopencv_imgcodecs.so',
'libopencv_photo.so'
# todo: add opencv_extras libraries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the story on that one?

]

def get_lib_dir(self, arch):
Expand All @@ -46,6 +47,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 +131,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()