Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved]How do I configure Qt 5.3 for Android opencv 2.4.9 ? (on mac os x)
QtWS25 Last Chance

[solved]How do I configure Qt 5.3 for Android opencv 2.4.9 ? (on mac os x)

Scheduled Pinned Locked Moved Mobile and Embedded
21 Posts 4 Posters 12.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ismail_gz
    wrote on last edited by
    #1

    Hi everyone,
    I want to develop Opencv for Android in Qt 5.3 but I don't know how do it.
    I try configure .pro file but did not work.

    Please help me..

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What exactly did not work ? Did you get an OpenCV version prebuilt for Android ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ismail_gz
        wrote on last edited by
        #3

        Thanks,
        I downloaded opencv here: "Opencv Android":http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip/download
        then I extract to /home/ismail/

        My .pro file:
        @QT += core
        QT -= gui
        TEMPLATE = app
        SOURCES += main.cpp
        ANDROID_OPENCV = /Users/ismail/OpencvAndroid/OpenCV-2.4.9-android-sdk/sdk/native
        LIBS +=
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_calib3d.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_flann.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_objdetect.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_contrib.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_video.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_ml.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_legacy.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_highgui.a
        $$ANDROID_OPENCV/3rdparty/libs/armeabi-v7a/liblibjpeg.a
        $$ANDROID_OPENCV/3rdparty/libs/armeabi-v7a/liblibpng.a
        $$ANDROID_OPENCV/3rdparty/libs/armeabi-v7a/liblibtiff.a
        $$ANDROID_OPENCV/3rdparty/libs/armeabi-v7a/liblibjasper.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_ts.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_imgproc.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_core.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_androidcamera.a
        $$ANDROID_OPENCV/libs/armeabi-v7a/libopencv_features2d.a
        INCLUDEPATH += $$ANDROID_OPENCV/jni/include/opencv/
        INCLUDEPATH += $$ANDROID_OPENCV/jni/include/opencv2/
        INCLUDEPATH += $$ANDROID_OPENCV/jni/include/
        CONFIG+=link_pkgconfig PKGCONFIG+=opencv
        @

        My compile output:
        16:44:26: Running steps for project OpencvAndroTest...
        16:44:26: Configuration unchanged, skipping qmake step.
        16:44:26: Starting: "/usr/bin/make"
        /Users/ismail/Qt/5.3/android_armv7/bin/qmake -spec android-g++ CONFIG+=debug -o Makefile ../OpencvAndroTest/OpencvAndroTest.pro
        make: Nothing to be done for `first'.
        16:44:28: The process "/usr/bin/make" exited normally.
        16:44:28: Removing directory /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-build
        16:44:28: Starting: "/usr/bin/make" INSTALL_ROOT=/Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-build install
        install -m 755 -p "libOpencvAndroTest.so" "/Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-build/libs/armeabi-v7a/libOpencvAndroTest.so"
        16:44:28: The process "/usr/bin/make" exited normally.
        16:44:28: Starting: "/Users/ismail/Qt/5.3/android_armv7/bin/androiddeployqt" --input /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-libOpencvAndroTest.so-deployment-settings.json --output /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-build --deployment bundled --install --ant /Users/ismail/Android/apache-ant-1.9.4/bin/ant --android-platform android-19 --jdk /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home --device LGOTMS5076533
        16:44:28: Pulling files necessary for debugging.
        16:44:28: Package deploy: Running command '/Users/ismail/Android/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb -s LGOTMS5076533 pull /system/bin/app_process /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/app_process'.
        16:44:28: Package deploy: Running command '/Users/ismail/Android/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb -s LGOTMS5076533 pull /system/lib/libc.so /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/libc.so'.
        No platform plugin, neither libqtforandroid.so or libqtforandroidGL.so, included in package. Please include one.
        Generating Android Package
        Input file: /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-libOpencvAndroTest.so-deployment-settings.json
        Output directory: /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/android-build
        Application binary: /Users/ismail/Documents/QtWorkspace/OpencvAndroTest/build-OpencvAndroTest-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug/libOpencvAndroTest.so
        Android build platform: android-19
        Install to device: LGOTMS5076533
        16:44:29: The process "/Users/ismail/Qt/5.3/android_armv7/bin/androiddeployqt" exited with code 12.
        Error while building/deploying project OpencvAndroTest (kit: Android for armeabi-v7a (GCC 4.8, Qt 5.3.0))
        When executing step 'Deploy to Android device'
        16:44:29: Elapsed time: 00:03.

        How should I do?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          AFAIK, you can't currently run an application that doesn't link to the QtGui library since you need the platform plugin to start your application

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ismail_gz
            wrote on last edited by
            #5

            I corrected some errors. Now deploying project but did not work application.
            This is my application output:

            Starting remote process.D/dalvikvm( 7123): Zygote::ForkAndSpecialize : 0
            E/cutils ( 7123): to chown(/mnt/shell/emulated/0, 0, 0)
            E/cutils ( 7123): to chown(/mnt/shell/emulated/obb, 0, 0)
            E/cutils ( 7123): to chown(/storage/emulated/0/Android, 0, 0)
            E/cutils ( 7123): to chown(/storage/emulated/0/Android/obb, 0, 0)
            D/dalvikvm( 7123): zygote get new systemTid : 7123
            D/dalvikvm( 7123): Late-enabling CheckJNI
            D/dalvikvm( 7123): threadid=2: interp stack at 0x4f6f6000
            D/dalvikvm( 7123): threadid=3: interp stack at 0x4f7fe000
            D/jdwp ( 7123): prepping for JDWP over ADB
            D/jdwp ( 7123): ADB transport startup
            D/dalvikvm( 7123): Elevating priority from 0 to -8
            D/dalvikvm( 7123): threadid=4: interp stack at 0x4f906000
            D/jdwp ( 7123): JDWP: thread running
            D/jdwp ( 7123): acceptConnection
            D/jdwp ( 7123): trying to receive file descriptor from ADB
            D/dalvikvm( 7123): threadid=5: interp stack at 0x54646000
            D/dalvikvm( 7123): zygote get thread init done
            D/dalvikvm( 7123): create interp thread : stack size=32KB
            D/dalvikvm( 7123): create new thread
            D/dalvikvm( 7123): new thread created
            D/dalvikvm( 7123): update thread list
            D/dalvikvm( 7123): threadid=6: interp stack at 0x5464e000
            D/dalvikvm( 7123): threadid=6: created from interp
            D/dalvikvm( 7123): start new thread
            D/dalvikvm( 7123): create interp thread : stack size=32KB
            D/dalvikvm( 7123): create new thread
            D/dalvikvm( 7123): new thread created
            D/dalvikvm( 7123): update thread list
            D/dalvikvm( 7123): threadid=6: notify debugger
            D/dalvikvm( 7123): threadid=6 (ReferenceQueueDaemon): calling run()
            D/dalvikvm( 7123): threadid=7: interp stack at 0x54756000
            D/dalvikvm( 7123): threadid=7: created from interp
            D/dalvikvm( 7123): start new thread
            D/dalvikvm( 7123): create interp thread : stack size=32KB
            D/dalvikvm( 7123): create new thread
            D/dalvikvm( 7123): new thread created
            D/dalvikvm( 7123): update thread list
            D/dalvikvm( 7123): threadid=7: notify debugger
            D/dalvikvm( 7123): threadid=7 (FinalizerDaemon): calling run()
            D/dalvikvm( 7123): threadid=8: interp stack at 0x5485e000
            D/dalvikvm( 7123): threadid=8: created from interp
            D/dalvikvm( 7123): start new thread
            D/dalvikvm( 7123): threadid=8: notify debugger
            D/dalvikvm( 7123): threadid=8 (FinalizerWatchdogDaemon): calling run()
            D/dalvikvm( 7123): threadid=9: interp stack at 0x54c64000
            D/dalvikvm( 7123): threadid=10: interp stack at 0x54d6c000
            D/dalvikvm( 7123): open_cached_dex_file : /data/app/org.qtproject.example.OpencvAndroTest2-1.apk /data/dalvik-cache/data@app@org.qtproject.example.OpencvAndroTest2-1.apk@classes.dex
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/skia ( 7123): Flag is not 10
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libgnustl_shared.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libgnustl_shared.so 0x414215c8
            D/dalvikvm( 7123): No JNI_OnLoad found in /data/data/org.qtproject.example.OpencvAndroTest2/lib/libgnustl_shared.so 0x414215c8, skipping init
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libopencv_java.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libopencv_java.so 0x414215c8
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libopencv_info.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libopencv_info.so 0x414215c8
            D/dalvikvm( 7123): No JNI_OnLoad found in /data/data/org.qtproject.example.OpencvAndroTest2/lib/libopencv_info.so 0x414215c8, skipping init
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libQt5Core.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libQt5Core.so 0x414215c8
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libQt5Gui.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/lib/libQt5Gui.so 0x414215c8
            D/dalvikvm( 7123): No JNI_OnLoad found in /data/data/org.qtproject.example.OpencvAndroTest2/lib/libQt5Gui.so 0x414215c8, skipping init
            D/dalvikvm( 7123): Trying to load lib /data/data/org.qtproject.example.OpencvAndroTest2/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/data/org.qtproject.example.OpencvAndroTest2/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0x414215c8
            I/Qt ( 7123): qt start
            D/dalvikvm( 7123): Trying to load lib /data/app-lib/org.qtproject.example.OpencvAndroTest2-1/libOpencvAndroTest2.so 0x414215c8
            D/dalvikvm( 7123): Added shared lib /data/app-lib/org.qtproject.example.OpencvAndroTest2-1/libOpencvAndroTest2.so 0x414215c8
            D/dalvikvm( 7123): No JNI_OnLoad found in /data/app-lib/org.qtproject.example.OpencvAndroTest2-1/libOpencvAndroTest2.so 0x414215c8, skipping init
            E/cv::error()( 7123): OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/highgui/src/window.cpp, line 483
            F/libc ( 7123): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 7139 (pencvAndroTest2)
            D/libEGL ( 7123): loaded /vendor/lib/egl/libEGL_mtk.so
            D/libEGL ( 7123): loaded /vendor/lib/egl/libGLESv1_CM_mtk.so
            D/libEGL ( 7123): loaded /vendor/lib/egl/libGLESv2_mtk.so

            Unable to start "org.qtproject.example.OpencvAndroTest2".

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              There's something that puzzles me, why do you have

              @CONFIG+=link_pkgconfig PKGCONFIG+=opencv@

              since you already link to the static libraries ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • I Offline
                I Offline
                ismail_gz
                wrote on last edited by
                #7

                You're right but I already deleted that line. Despite this occurred error.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Did you do a full rebuild ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    ismail_gz
                    wrote on last edited by
                    #9

                    Yes, I did

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Re-reading your error, it seems you are using a method that is not implement for android. Can you share the OpenCV code you are using ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        ismail_gz
                        wrote on last edited by
                        #11

                        it's a simple code:

                        @#include "opencv2/opencv.hpp"
                        #include "opencv2/highgui/highgui.hpp"

                        using namespace cv;

                        int main(int argc, char *argv[])
                        {
                        namedWindow("output",1);
                        Mat output = Mat::zeros(120,350,CV_8UC3);
                        putText(output,"Hello world :)", cvPoint(15,70), FONT_HERSHEY_PLAIN,3,cvScalar(0,255,0),4);
                        imshow("Output",output);
                        waitKey(0);
                        return 0;
                        }@

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Wild guess but I'd say that either namedWindow, imshow or both are not implemented for android

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • I Offline
                            I Offline
                            ismail_gz
                            wrote on last edited by
                            #13

                            Could you recommend a sample code.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              Not really, since you are currently using OpenCV only code, you should rather ask on the OpenCV forum for their support on android

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • J Offline
                                J Offline
                                johnthesoftware
                                wrote on last edited by
                                #15

                                Did you resolve this? I'm about to try the same thing on Fedora.

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  johnthesoftware
                                  wrote on last edited by
                                  #16

                                  Did you resolve this? I'm about to try the same thing on Fedora.

                                  1 Reply Last reply
                                  0
                                  • I Offline
                                    I Offline
                                    ismail_gz
                                    wrote on last edited by
                                    #17

                                    No, I couldn't yet. My main problem is sample code at the moment. I couldn't find sample code about this subject. But I found configurations from this "link":http://stackoverflow.com/questions/27562311/how-to-integrate-opencv-into-qt-creator-android-project
                                    I hope that helps.

                                    1 Reply Last reply
                                    0
                                    • I Offline
                                      I Offline
                                      ismail_gz
                                      wrote on last edited by
                                      #18

                                      No, I couldn't yet. My main problem is sample code at the moment. I couldn't find sample code about this subject. But I found configurations from this "link":http://stackoverflow.com/questions/27562311/how-to-integrate-opencv-into-qt-creator-android-project
                                      I hope that helps.

                                      1 Reply Last reply
                                      0
                                      • I Offline
                                        I Offline
                                        ismail_gz
                                        wrote on last edited by
                                        #19

                                        Finally, I found it. Configurations are my previous reply. And you must copy libnative_camera_r4.2.0.so(must be compatible with the your android version(this is important)) to project_root/android/libs/armeabi-v7a/ .
                                        Then you can watch "this":https://www.youtube.com/watch?v=0ONxIy8itRA video for source code.

                                        1 Reply Last reply
                                        0
                                        • I Offline
                                          I Offline
                                          ismail_gz
                                          wrote on last edited by
                                          #20

                                          Finally, I found it. Configurations are my previous reply. And you must copy libnative_camera_r4.2.0.so(must be compatible with the your android version(this is important)) to project_root/android/libs/armeabi-v7a/ .
                                          Then you can watch "this":https://www.youtube.com/watch?v=0ONxIy8itRA video for source code.

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved