Skip to content

Camera on android #75

Closed
Closed

Description

@alexsilva

Log error: http://pastebin.com/LwgjpMqQ

. / distribute.sh-m "pil Kivy pygame opencv"

error: Recipe opencv does not exit

opencv is not included in the "recipes dir".

How to fix it?
Thank you.

Activity

  1. tito commented on Dec 16, 2012

    @tito
    Member

    There is no camera implementation in Kivy right now. And we never said than opencv was available on python-for-android too.

    The list of available recipes can be retrieved with ./distribute.sh -l
    Or browisng https://github.com/kivy/python-for-android/tree/master/recipes

    The fix is... to do it.

  2. alexsilva commented on Dec 16, 2012

    @alexsilva
    Author

    So if I only include "opencv" the process of compiling the camera will work?
    Keep in mind that I started using "Kivy" very recently.

  3. alexsilva commented on Dec 16, 2012

    @alexsilva
    Author

    I disagree with this statement:

    I agree with the statement:

    • "And we never said than opencv was available on python-for-android too"

    Ok, no problem.

    • "The fix is... to do it."
  4. tito commented on Dec 16, 2012

    @tito
    Member

    There is no camera implementation in Kivy "for android platform". :) You are on the python/android project, so the context was implies.

    The issue is not only to get opencv compiled for ARM/android, but also implement a provider for android. It seem that OpenCV have now a camera support for android, but it need a closer look to see how it need to be integrated into our java code, and if it's still possible to use their Python API. Or another way.

  5. barius commented on Mar 4, 2014

    @barius

    WRT OpenCV for Android, I managed to compile it for Python and successfully imported it in Python. However camera functionality in OpenCV is somehow broken in Kitkat 4.4.2.

  6. venthur commented on May 22, 2014

    @venthur

    Do you mean you compiled the OpenCV Python library for arm/android using python-for-android? If yes, would you mind sharing the recipe?

  7. barius commented on May 23, 2014

    @barius

    Hi Bastian Venthur,

    I did compiled the OpenCV Python library for Android(ARM). However, I
    didn't write any recipe files to achieve this. It was done by creating a
    new Android project in ADT, and feeding everything the cross compiler
    needed into the project.
    More specifically, the OpenCV building environment uses some automatic
    wrapper for Python library generation. During compile time, some header
    files are generated by the wrapper to provide C++-Python interoperability
    and functionality. However the OpenCV CMake environment disables Python
    library generation for Android, so these header files are not created.
    One can simply put the generated headers from a Linux OpenCV for Python
    build into the Android project, and put the pre-compiled opencv_java.so
    library for Android into the same project and compile. Then you can get a
    fully-functional cv2.so for Android (or partially-functional for it doesn't
    support HighGUI).
    I can send you a copy of the Eclipse project I used to build the library,
    if you need.

    Regards,

    Peng

    2014-05-23 6:21 GMT+08:00 Bastian Venthur notifications@github.com:

    Do you mean you compiled the OpenCV Python library for arm/android
    using python-for-android? If yes, would you mind sharing the recipe?

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/75#issuecomment-43951254
    .

  8. AshokEmrys commented on Jul 23, 2014

    @AshokEmrys

    Hi barius,

    I am trying to do the same, wrap opencv with python for android.
    I am relatively new to android, it would be much helpful if you could share the procedure you followed and the required project files.

    Regards,
    Ashok

  9. barius commented on Jul 24, 2014

    @barius

    @ParokshaX @venthur
    Here I attach the Eclipse project I have made to build libcv2.so for Python on Android. It is a little bit messy because I really had a headache working it out, and I'm short on time right now.
    Just import it into Eclipse (I use ADT 22.0 and NDK r9c) and it should compile. I took libopencv_java.so into the project so it shall be a dependency. Also libpython2.7.so is a dependency too.
    If anyone can make this into a Python for Android recipe then that would be awesome.

    The link:
    https://drive.google.com/file/d/0B7iBG-Vnm4w1SjFhXzItSmQ5OG8/edit?usp=sharing

    Regards,

    Peng

  10. AshokEmrys commented on Jul 24, 2014

    @AshokEmrys

    @barius
    Thanks, I managed to build it by using opencv's cmake, however I have problem with the numpy recipe!

  11. barius commented on Jul 24, 2014

    @barius

    @ParokshaX
    Glad to hear that you worked it out.
    About numpy, AFAIK you cannot build P4A w/o Kivy, e.g.this works fine
    ./distribute.sh -d dist1 -m numpy pil kivy
    but
    ./distribute.sh -d dist1 -m numpy pil
    does not.
    No idea what your case is, just trying to help.

  12. AshokEmrys commented on Jul 24, 2014

    @AshokEmrys

    @barius
    I used ./distribute.sh -m openssl pil kivy numpy but it failed with numpy as it is trying to build lapack library which requires gfortran for arm which is not provided by android-ndk, the patch provided in the recipe doesn't seem to work, could be relative to the distro (arch linux) i am using. Have to dig into it further to find where it went wrong.

    Is it possible that you could share the numpy-android which you built, so I can test run the opencv I built using cmake and verify its integrity?

  13. barius commented on Jul 24, 2014

    @barius

    try put numpy in front of kivy first 😁
    2014-7-25 上午12:20于 "Ashok Kumar P (ParokshaX)" notifications@github.com写道:

    @barius https://github.com/barius
    I used ./distribute.sh -m openssl pil kivy numpy but it failed with numpy
    as it is trying to build lapack library which requires gfortran for arm
    which is not provided by android-ndk, the patch provided in the recipe
    doesn't seem to work, could be relative to the distro (arch linux) i am
    using. Have to dig into it further to find where it went wrong.

    Is it possible that you could share the numpy-android which you built, so
    I can test run the opencv I built using cmake and verify its integrity?

    —
    Reply to this email directly or view it on GitHub
    #75 (comment)
    .

  14. AshokEmrys commented on Jul 24, 2014

    @AshokEmrys

    @barius
    tried, still the same error

  15. barius commented on Jul 25, 2014

    @barius

    @ParokshaX
    sorry for the delay, here is the numpy library I compiled. have fun
    https://drive.google.com/file/d/0B7iBG-Vnm4w1WmxVQS1JREwtRzQ/edit?usp=sharing

  16. 1 remaining item

  17. barius commented on Jul 25, 2014

    @barius

    @ParokshaX
    It worked like a charm :P
    As long as major interfaces are the same between numpy 1.7.1 and 1.8.1 the interop between OpenCV and numpy could be stable, I guess :P

  18. AshokEmrys commented on Jul 25, 2014

    @AshokEmrys

    @barius weird!,
    Runtime Error: Module is built for API 9 but the version of numpy is 7
    while importing cv2,
    I patched the numpy-1.8.1 and have built one, let me check and report

    On 7/25/14, barius notifications@github.com wrote:

    @ParokshaX
    It worked like a charm :P
    As long as major interfaces are the same between numpy 1.7.1 and 1.8.1 the
    interop between OpenCV and numpy could be stable, I guess :P


    Reply to this email directly or view it on GitHub:
    #75 (comment)

  19. barius commented on Jul 25, 2014

    @barius

    @ParokshaX
    FYI I used OpenCV 2.4.7 with numpy 1.7.1, and they work fine. Really weird.

  20. AshokEmrys commented on Jul 25, 2014

    @AshokEmrys

    I patched the numpy1.8.1 for python-for-android, now I have a working
    opencv in my android :-D

    On 7/25/14, barius notifications@github.com wrote:

    @ParokshaX
    FYI I used OpenCV 2.4.7 with numpy 1.7.1, and they work fine. Really weird.


    Reply to this email directly or view it on GitHub:
    #75 (comment)

  21. barius commented on Jul 25, 2014

    @barius

    @ParokshaX
    congratz :D
    hope we can get an official OpenCV from P4A :P

  22. AshokEmrys commented on Jul 25, 2014

    @AshokEmrys

    I have a plan of writing a recipe for it, not now, currently I am
    quite overwhelmed by others ;-)

    On 7/25/14, barius notifications@github.com wrote:

    @ParokshaX
    congratz :D
    hope we can get an official OpenCV from P4A :P


    Reply to this email directly or view it on GitHub:
    #75 (comment)

  23. gorgonaut04 commented on Feb 1, 2015

    @gorgonaut04

    Has there been any update on this? Would it be possible to get an official recipe for OpenCV in the near future? I would be extremely grateful! Coffees, all around!

  24. jxai commented on Feb 11, 2015

    @jxai
    Contributor

    I created a recipe for OpenCV and submitted it as PR #327. The recipe patches OpenCV v2.4.10.1, builds a fully working Python module cv2.so, as well as installs native camera libraries. The Java library (libopencv_java.so) is actually not needed.

    I don't have the resource to test the camera functionality on many different devices. It works fine on one phone running Android 4.1, but failed on another phone running 4.4 (as @barius mentioned earlier).

  25. gorgonaut04 commented on Feb 23, 2015

    @gorgonaut04

    Hi again, Jason. Do you have any tips for using the Android camera feature of OpenCV within kivy? This seems to be uncharted territory.

  26. cbenhagen commented on Apr 4, 2015

    @cbenhagen
    Contributor

    @jasonxunxu thank you very much for the recipe! Do you mind giving a small example on how one would use the camera? If it should be as simple as

    cap = cv2.VideoCapture(0)

    it might just not work on my nexus 5. This is the whole code i used to test: https://gist.github.com/cbenhagen/457af62752fba44fff47

  27. cbenhagen commented on Apr 4, 2015

    @cbenhagen
    Contributor

    oh never mind.. i just found your kivy fork and its camera-android branch

  28. jxai commented on Apr 5, 2015

    @jxai
    Contributor

    @cbenhagen Thanks for digging out my branch, I just posted a PR for Kivy. Please let me know how it works for you.

    @gorgonaut04 I hope it does the trick for you too.

  29. gorgonaut04 commented on Apr 6, 2015

    @gorgonaut04

    @jasonxunxu it looks to me as if this code is good for streaming video data, but can it also be used to actually take full-resolution photo using the shutter? I apologize if I'm just completely missing this, but are there any usage examples for this code? Thanks!

  30. jxai commented on Apr 7, 2015

    @jxai
    Contributor

    It is a standard camera provider so works transparently with the Camera widget on Android. In addition it has a read_frame method to fetch current frame data (of same resolution as the preview image). It is not designed to take full resolution pictures, for which Plyer camera might be what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions