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

Does the opencv recipe for buildozer not include the extra face class? #2166

Closed
SonofPoseidon1982 opened this issue May 1, 2020 · 9 comments

Comments

@SonofPoseidon1982
Copy link

If the face class (which is now part of the opencv-contrib-python module) is not included in the opencv recipe (which it doesn't seem to be), would it be too problematic to import it?

Thanks,
Nicholas

@SonofPoseidon1982
Copy link
Author

Do I have to edit the opencv recipe?

@SonofPoseidon1982
Copy link
Author

Look, listen. I really need to know how difficult it would be to import a few extra contrib modules through Python-For-Android.. would I need to try to make a new recipe for them? (This is important), I have an app that mostly uses PIP and other Libraries, but only 10 lines of code are dedicated to actually extracting the facial landmarks through opencv. I have put a lot of work into this app and I don't want to waste all my effort

@RobertFlatt
Copy link
Contributor

This is how to make a local copy of an existing recipe in order to modify it.
Making new recpies for packages that are not pure Python is not somthing I can help with.

Replace RECIPE_NAME with whatever recipe you are changing:

  1. in buildozer.spec change this
    #p4a.local_recipes =
    to
    p4a.local_recipes = ./p4a-recipes

  2. create directories
    ./p4a-recipes
    ./p4a-recipes/RECIPE_NAME

  3. copy and paste the files from
    https://github.com/kivy/python-for-android/tree/develop/pythonforandroid/recipes/RECIPE_NAME
    ( Note using 'develop' to get latest fixes)

  4. Change the files in a way that makes you happy (and beware of breaking patch files).

  5. buildozer android clean

  6. buildozer android debug

@SonofPoseidon1982
Copy link
Author

Thankyou for your help,
I am very grateful you took the time,
I've already changed the OpenCV recipe but libopencv_face.so doesn't get built (there is no patch disabling the face class I suspect), but I'm still missing something

@SonofPoseidon1982
Copy link
Author

Ok, I have made the changes but it seems to crash when applying the patch. I have created the following directories

.p4a-recipes/opencv_contrib which contains the subdirectory containing the patch(p4a_build.patch)
The structure is as follows:
.p4a-recipes/opencv_contrib/init.py
.p4a-recipes/opencv_contrib/patches/p4a_build.patch
.p4a-recipes/opencv_contrib/pycache/ (etc..)

I just cut and pasted the whole tree from GitHub (using develop).

Here is my buildozer spec (only including relevant areas):

===============================================================

(list) Application requirements

comma separated e.g. requirements = sqlite3,kivy

requirements = python3, kivy, numpy, scipy, Pillow, selenium, urllib3, appium-python-client, jnius, kivmob, android, hostpython3, xcamera, plyer, opencv_contrib

(str) The directory in which python-for-android should look for your own build recipes (if any)

p4a.local_recipes = ./p4a-recipes

===============================================================
I get the following from the buildozer error log:

[INFO]: Applying patches for opencv_contrib[armeabi-v7a]
[INFO]: Applying patch patches/p4a_build.patch
[INFO]: -> running patch -t -d /mnt/c/users/nicholas/documents/f_con2/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/op...(and 151 more)
Exception in thread background thread for pid 13560:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/nloizou/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/nloizou/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/nloizou/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/nloizou/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /usr/bin/patch -t -d /mnt/c/users/nicholas/documents/f_con2/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/opencv_contrib/armeabi-v7a__ndk_target_21/opencv_contrib -p1 -i /mnt/c/users/nicholas/documents/f_con2/p4a-recipes/opencv_contrib/patches/p4a_build.patch

STDOUT:
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:

|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

No file to patch. Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 25
Perhaps you used the wrong -p or --strip option?

@SonofPoseidon1982
Copy link
Author

oh its ok, I renamed the recipe /opencv and its ok, but it still doesn't build libopencv_face.so

@abhishekju06
Copy link

@SonofPoseidon1982 are you able to solve the issue?
I am facing the same error while tracing via logcat I get AttributeError; cv2.face
Can you please help me?

@SonofPoseidon1982
Copy link
Author

I need more information; what are you trying to do? If you are trying to use the face class you need import more than just the opencv recipe, but the extra classes which there now exists a recipe. Include opencv_extras in your list of buildozer recipes. The opencv extra classes were added to this recipe only last year.

@SonofPoseidon1982
Copy link
Author

I requested this last year and I had a part to play in testing it (at least superficially). https://github.com/kivy/python-for-android/tree/master/pythonforandroid/recipes/opencv_extras

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants