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. Opencv in Android
Forum Updated to NodeBB v4.3 + New Features

Opencv in Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
12 Posts 3 Posters 5.2k Views 3 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    That's a bit vague. What did you try ? What errors are you getting ? Can you make a "pure" OpenCV sample application run on your Android device ?

    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
    1
    • OliveiraNTO Offline
      OliveiraNTO Offline
      OliveiraNT
      wrote on last edited by OliveiraNT
      #3

      I just followed this tutorial but when a try it I'm still not able to include OpenCV libraries in my project and I receive the message "No such file or directory"

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

        Can you share you .pro file and what file isn't found ?

        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
        1
        • OliveiraNTO Offline
          OliveiraNTO Offline
          OliveiraNT
          wrote on last edited by OliveiraNT
          #5

          Sure, actually my .pro file is

          TEMPLATE = app
          
          QT += qml quick
          CONFIG += c++11
          
          SOURCES += main.cpp \
              imagerecog.cpp
          
          INCLUDEPATH += /usr/local/include/opencv
          LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui
          
          RESOURCES += qml.qrc
          
          
          # Additional import path used to resolve QML modules in Qt Creator's code model
          QML_IMPORT_PATH =
          
          # Default rules for deployment.
          include(deployment.pri)
          
          DISTFILES += \
              android/AndroidManifest.xml \
              android/gradle/wrapper/gradle-wrapper.jar \
              android/gradlew \
              android/res/values/libs.xml \
              android/build.gradle \
              android/gradle/wrapper/gradle-wrapper.properties \
              android/gradlew.bat
          
          ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
          
          HEADERS += \
              imagerecog.h
          
          

          And the error happens when I try to include the OpenCV libs

          Ex: #include <opencv2/opencv.hpp>

          And its not found

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

            Shouldn't that rather be INCLUDEPATH += /usr/local/include/ ?

            IIRC, the opencv and opencv2 folder are in the same directory.

            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
            1
            • OliveiraNTO Offline
              OliveiraNTO Offline
              OliveiraNT
              wrote on last edited by
              #7

              When I try this I can include the libs but in build I receive this errors
              this erros:
              :-1: error: error: cannot find -lopencv_core
              :-1: error: error: cannot find -lopencv_imgcodecs
              :-1: error: error: cannot find -lopencv_highgui
              :-1: error: collect2: error: ld returned 1 exit status

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

                What are the exact name of the libraries you have there ?

                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
                1
                • OliveiraNTO Offline
                  OliveiraNTO Offline
                  OliveiraNT
                  wrote on last edited by
                  #9

                  In the usr/local/lib folder -> libopencv_core.so, libopencv_highgui.so, libopencv_imgcodecs.so;

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

                    No version number ?

                    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
                    1
                    • OliveiraNTO OliveiraNT

                      In the usr/local/lib folder -> libopencv_core.so, libopencv_highgui.so, libopencv_imgcodecs.so;

                      benlauB Offline
                      benlauB Offline
                      benlau
                      Qt Champions 2016
                      wrote on last edited by
                      #11

                      @OliveiraNT said:

                      In the usr/local/lib folder -> libopencv_core.so, libopencv_highgui.so, libopencv_imgcodecs.so;

                      Are you really using opencv for Android? The prebuilt package should only contains .a file for the library above.

                      1 Reply Last reply
                      2
                      • OliveiraNTO Offline
                        OliveiraNTO Offline
                        OliveiraNT
                        wrote on last edited by
                        #12

                        @benlau and @SGaist tanks for the help, I didn't know there is an openCV just for android.
                        I solved my problem adding the openCV sdk for android at my project with this:

                        TEMPLATE = app
                        
                        QT += qml quick
                        CONFIG += c++11
                        
                        SOURCES += main.cpp \
                            processaimagem.cpp \
                            provedorimagem.cpp
                        
                        INCLUDEPATH += /home/gpca/Qt/OpenCV-android-sdk/sdk/native/jni/include
                        OPENCV3RDPARTYLIBS = /home/gpca/Qt/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a
                        OPENCVNATIVELIBS = /home/gpca/Qt/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a
                        LIBS += $$OPENCV3RDPARTYLIBS/liblibtiff.a
                        $$OPENCV3RDPARTYLIBS/liblibjpeg.a
                        $$OPENCV3RDPARTYLIBS/liblibjasper.a
                        $$OPENCV3RDPARTYLIBS/liblibpng.a
                        $$OPENCV3RDPARTYLIBS/libtbb.a
                        $$OPENCV3RDPARTYLIBS/libIlmImf.a
                        LIBS += $$OPENCVNATIVELIBS/libopencv_core.a
                        $$OPENCVNATIVELIBS/libopencv_androidcamera.a
                        $$OPENCVNATIVELIBS/libopencv_flann.a
                        $$OPENCVNATIVELIBS/libopencv_imgproc.a
                        $$OPENCVNATIVELIBS/libopencv_highgui.a
                        $$OPENCVNATIVELIBS/libopencv_features2d.a
                        $$OPENCVNATIVELIBS/libopencv_calib3d.a
                        $$OPENCVNATIVELIBS/libopencv_ml.a
                        $$OPENCVNATIVELIBS/libopencv_objdetect.a
                        $$OPENCVNATIVELIBS/libopencv_photo.a
                        $$OPENCVNATIVELIBS/libopencv_stitching.a
                        $$OPENCVNATIVELIBS/libopencv_superres.a
                        $$OPENCVNATIVELIBS/libopencv_ts.a
                        $$OPENCVNATIVELIBS/libopencv_video.a
                        $$OPENCVNATIVELIBS/libopencv_videostab.a
                        $$OPENCVNATIVELIBS/libopencv_java.so
                        
                        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
                        
                        RESOURCES += qml.qrc
                        
                        
                        # Additional import path used to resolve QML modules in Qt Creator's code model
                        QML_IMPORT_PATH =
                        
                        # Default rules for deployment.
                        include(deployment.pri)
                        
                        DISTFILES += \
                            android/AndroidManifest.xml \
                            android/gradle/wrapper/gradle-wrapper.jar \
                            android/gradlew \
                            android/res/values/libs.xml \
                            android/build.gradle \
                            android/gradle/wrapper/gradle-wrapper.properties \
                            android/gradlew.bat
                        
                        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
                        
                        HEADERS += \
                            processaimagem.h \
                            provedorimagem.h
                        
                        

                        Again, thank you both for the help.

                        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