Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why after linking the OpenCV libraries, Mat objects are still 'undefined'?

Why after linking the OpenCV libraries, Mat objects are still 'undefined'?

Scheduled Pinned Locked Moved Solved General and Desktop
28 Posts 5 Posters 4.1k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 9 Feb 2021, 20:04 last edited by
    #18

    Did you notice the "opencv4" folder that is missing from your INCLUDEPATH statement ?

    Either add it there or to your include statements.

    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
    • G Offline
      G Offline
      georgiav
      wrote on 9 Feb 2021, 20:14 last edited by
      #19

      I tried that and it still doesn't work apparently

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 9 Feb 2021, 20:15 last edited by
        #20

        Please provide the information directly.
        What exactly did you try ?
        What is the error your get ?

        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
        • G Offline
          G Offline
          georgiav
          wrote on 9 Feb 2021, 20:26 last edited by
          #21

          26ceb0ba-dae5-4681-8b11-162566e5631e-image.png

          I changed the include statements to that and in the .pro file the INCLUDEPATH is /usr/local/include/opencv4

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 9 Feb 2021, 20:28 last edited by
            #22

            @SGaist said in Why after linking the OpenCV libraries, Mat objects are still 'undefined'?:

            Did you notice the "opencv4" folder that is missing from your INCLUDEPATH statement ?

            Either add it there or to your include statements.

            I wrote "either" which means one or the other, not both.

            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
            • G Offline
              G Offline
              georgiav
              wrote on 9 Feb 2021, 20:37 last edited by
              #23

              3f160844-42c9-4164-989a-ba6571a57158-image.png

              So I changed it in the main.cpp file because otherwise I got those errors . Now in the .pro file is /usr/local/include.
              I still get the same errors
              7c81d5f1-be9e-46f3-8e4f-cb4ea697577b-image.png

              The last error I don't understand because I wrote opencv2/core/core.hpp not opencv2/core.hpp and I cleaned the project again before

              J 1 Reply Last reply 10 Feb 2021, 05:48
              0
              • G georgiav
                9 Feb 2021, 20:37

                3f160844-42c9-4164-989a-ba6571a57158-image.png

                So I changed it in the main.cpp file because otherwise I got those errors . Now in the .pro file is /usr/local/include.
                I still get the same errors
                7c81d5f1-be9e-46f3-8e4f-cb4ea697577b-image.png

                The last error I don't understand because I wrote opencv2/core/core.hpp not opencv2/core.hpp and I cleaned the project again before

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 10 Feb 2021, 05:48 last edited by
                #24

                @georgiav Change INCLUDEPATH in your pro file so, that it points to /usr/local/include/opencv4 and change your includes like

                #include "opencv2/...
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply 10 Feb 2021, 13:22
                2
                • J jsulm
                  10 Feb 2021, 05:48

                  @georgiav Change INCLUDEPATH in your pro file so, that it points to /usr/local/include/opencv4 and change your includes like

                  #include "opencv2/...
                  
                  G Offline
                  G Offline
                  georgiav
                  wrote on 10 Feb 2021, 13:22 last edited by
                  #25

                  @jsulm Hi, I tried that before and I got those errors of 'file not found' ( photo above)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 10 Feb 2021, 15:43 last edited by
                    #26

                    Here is a minimal example adjusted to the paths you shown to us:

                    .pro file:

                    TEMPLATE = app
                    TARGET = test_opencv
                    INCLUDEPATH += .
                    INCLUDEPATH += /usr/local/include/opencv4
                     
                    LIBS += -L/usr/local/lib/ -lopencv_core
                    SOURCES += main.cpp
                    

                    main.cpp:

                     #include <opencv2/core.hpp>
                      
                     int main(int argc, char **argv)
                     {
                          cv::Mat mat;
                          return 0;
                     }
                    

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

                    G 1 Reply Last reply 11 Feb 2021, 15:22
                    1
                    • S SGaist
                      10 Feb 2021, 15:43

                      Here is a minimal example adjusted to the paths you shown to us:

                      .pro file:

                      TEMPLATE = app
                      TARGET = test_opencv
                      INCLUDEPATH += .
                      INCLUDEPATH += /usr/local/include/opencv4
                       
                      LIBS += -L/usr/local/lib/ -lopencv_core
                      SOURCES += main.cpp
                      

                      main.cpp:

                       #include <opencv2/core.hpp>
                        
                       int main(int argc, char **argv)
                       {
                            cv::Mat mat;
                            return 0;
                       }
                      
                      G Offline
                      G Offline
                      georgiav
                      wrote on 11 Feb 2021, 15:22 last edited by
                      #27

                      @SGaist Yes, this seems to work fine! Thank you very much!

                      P 1 Reply Last reply 11 Feb 2021, 15:49
                      0
                      • G georgiav
                        11 Feb 2021, 15:22

                        @SGaist Yes, this seems to work fine! Thank you very much!

                        P Offline
                        P Offline
                        Pablo J. Rogina
                        wrote on 11 Feb 2021, 15:49 last edited by
                        #28

                        @georgiav said in Why after linking the OpenCV libraries, Mat objects are still 'undefined'?:

                        this seems to work fine!

                        so please don't forget to mark your post as solved!

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        1 Reply Last reply
                        0
                        • M Matiyash referenced this topic on 31 Aug 2023, 08:05

                        27/28

                        11 Feb 2021, 15:22

                        • Login

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