Skip to content
Draft
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
7 changes: 4 additions & 3 deletions pythonforandroid/recipes/opencv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OpenCVRecipe(NDKRecipe):
build of most of the libraries of the opencv's package, so we can
process images, videos, objects, photos...
'''
version = '4.5.1'
version = '4.12.0'
url = 'https://github.com/opencv/opencv/archive/{version}.zip'
depends = ['numpy']
patches = ['patches/p4a_build.patch']
Expand Down Expand Up @@ -68,8 +68,9 @@ def build_arch(self, arch):
python_link_version = self.ctx.python_recipe.link_version
python_library = join(python_link_root,
'libpython{}.so'.format(python_link_version))
python_include_numpy = join(python_site_packages,
'numpy', 'core', 'include')
python_include_numpy = join(
self.ctx.get_python_install_dir(arch.arch), "numpy/_core/include",
)

shprint(sh.cmake,
'-DP4A=ON',
Expand Down
33 changes: 12 additions & 21 deletions pythonforandroid/recipes/opencv/patches/p4a_build.patch
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
This patch allow that the opencv's build command correctly detects our version
of python, so we can successfully build the python bindings (cv2.so)
--- opencv-4.0.1/cmake/OpenCVDetectPython.cmake.orig 2018-12-22 08:03:30.000000000 +0100
+++ opencv-4.0.1/cmake/OpenCVDetectPython.cmake 2019-01-31 11:33:10.896502978 +0100
@@ -175,7 +175,7 @@ if(NOT ${found})
diff '--color=auto' -uNr opencv-4.12.0/cmake/OpenCVDetectPython.cmake opencv-4.12.0.mod/cmake/OpenCVDetectPython.cmake
--- opencv-4.12.0/cmake/OpenCVDetectPython.cmake 2025-07-02 13:24:13.000000000 +0530
+++ opencv-4.12.0.mod/cmake/OpenCVDetectPython.cmake 2025-09-20 22:22:14.961944470 +0530
@@ -175,7 +175,7 @@
endif()
endif()

- if(NOT ANDROID AND NOT IOS)
+ if(P4A OR NOT ANDROID AND NOT IOS)
- if(NOT ANDROID AND NOT IOS AND NOT XROS)
+ if(P4A OR NOT ANDROID AND NOT IOS AND NOT XROS)
if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
execute_process(COMMAND ${_executable} -c "from sysconfig import *; print(get_path('purelib'))"
RESULT_VARIABLE _cvpy_process
@@ -244,7 +244,7 @@ if(NOT ${found})
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
- endif(NOT ANDROID AND NOT IOS)
+ endif(P4A OR NOT ANDROID AND NOT IOS)
endif()

# Export return values
--- opencv-4.0.1/modules/python/CMakeLists.txt.orig 2018-12-22 08:03:30.000000000 +0100
+++ opencv-4.0.1/modules/python/CMakeLists.txt 2019-01-31 11:47:17.100494908 +0100
diff '--color=auto' -uNr opencv-4.12.0/modules/python/CMakeLists.txt opencv-4.12.0.mod/modules/python/CMakeLists.txt
--- opencv-4.12.0/modules/python/CMakeLists.txt 2025-07-02 13:24:13.000000000 +0530
+++ opencv-4.12.0.mod/modules/python/CMakeLists.txt 2025-09-20 22:23:15.124356524 +0530
@@ -3,7 +3,7 @@
# ----------------------------------------------------------------------------
if(DEFINED OPENCV_INITIAL_PASS) # OpenCV build

-if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
+if(ANDROID AND NOT P4A OR APPLE_FRAMEWORK OR WINRT)
ocv_module_disable_(python2)
Expand Down
Loading