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'?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 765 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.
  • M Offline
    M Offline
    Matiyash
    wrote on 31 Aug 2023, 07:50 last edited by
    #1

    3713196f-b669-49ea-ae76-b14ee3b46901-image.png

    J 1 Reply Last reply 31 Aug 2023, 08:06
    0
    • M Offline
      M Offline
      Matiyash
      wrote on 31 Aug 2023, 08:05 last edited by
      #2

      @Matiyash I read this answer, didn't help :(
      https://forum.qt.io/topic/123637/why-after-linking-the-opencv-libraries-mat-objects-are-still-undefined

      1 Reply Last reply
      0
      • M Matiyash
        31 Aug 2023, 07:50

        3713196f-b669-49ea-ae76-b14ee3b46901-image.png

        J Offline
        J Offline
        JonB
        wrote on 31 Aug 2023, 08:06 last edited by JonB
        #3

        @Matiyash
        This is C++ code, why are you posting in Qt for Python forum?

        I don't know anything about OpenCV. But your code shows a compilation error on the word Mat so far as I can see. That would have nothing to do with whether or not you are linking with something. It would imply you have not #included the right header file(s) or Mat is not right, e.g. perhaps it's defined in a namespace?

        UPDATE
        Looking at the link you just posted, by the end you can see they use cv::Mat mat;. That's just what I suggested: looks like Mat is defined in a cv:: namespace. Use cv::Mat QImage2MatColor() or maybe introduce using cv; into your file to use Mat without the namespace in front of it.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Matiyash
          wrote on 31 Aug 2023, 08:15 last edited by
          #4

          @JonB yes, I tried to include cv::, but what caused the expected namespace name errorb1780363-aba8-4526-9853-0c094d7adc87-image.png

          and also why the error with the name of the function, use of undeclared identifier

          J 1 Reply Last reply 31 Aug 2023, 08:18
          0
          • M Matiyash
            31 Aug 2023, 08:15

            @JonB yes, I tried to include cv::, but what caused the expected namespace name errorb1780363-aba8-4526-9853-0c094d7adc87-image.png

            and also why the error with the name of the function, use of undeclared identifier

            J Offline
            J Offline
            JonB
            wrote on 31 Aug 2023, 08:18 last edited by JonB
            #5

            @Matiyash
            Like I said, I don't use OpenCV. Check it uses a namespace and what that name is. Maybe it's cv2 now, or opencv? Surely it gives an example somewhere?

            What about trying the example at https://docs.opencv.org/3.0-beta/doc/tutorials/introduction/display_image/display_image.html (or equivalent for OpenCV 2.x if 3.0-beta is not suitable, it's what I came across Googling) to see if that works for you?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Matiyash
              wrote on 31 Aug 2023, 08:42 last edited by
              #6

              @JonB Thanks for the link, but probably not, it seems like Opencv is installed correctly, I probably have an error related to the paths to the libraries
              b90d94c5-5c6c-449b-8eaf-f98b522c714e-image.png

              J 1 Reply Last reply 31 Aug 2023, 08:45
              0
              • M Matiyash
                31 Aug 2023, 08:42

                @JonB Thanks for the link, but probably not, it seems like Opencv is installed correctly, I probably have an error related to the paths to the libraries
                b90d94c5-5c6c-449b-8eaf-f98b522c714e-image.png

                J Offline
                J Offline
                JonB
                wrote on 31 Aug 2023, 08:45 last edited by
                #7

                @Matiyash
                Since you show compilation errors only INCLUDEPATH is relevant, it has not got as far as LIBS yet. If your INCLUDEPATH were wrong you would get errors on #include lines but you do not. Your problem seems to be using namespace cv. Which is why I would test the sample code I linked, just to see whether it compiles.

                M 1 Reply Last reply 31 Aug 2023, 09:03
                0
                • J JonB
                  31 Aug 2023, 08:45

                  @Matiyash
                  Since you show compilation errors only INCLUDEPATH is relevant, it has not got as far as LIBS yet. If your INCLUDEPATH were wrong you would get errors on #include lines but you do not. Your problem seems to be using namespace cv. Which is why I would test the sample code I linked, just to see whether it compiles.

                  M Offline
                  M Offline
                  Matiyash
                  wrote on 31 Aug 2023, 09:03 last edited by
                  #8

                  @JonB well, what do you say?
                  fe22d3f9-d640-4010-8e90-9345d615c1de-image.png

                  J J 2 Replies Last reply 31 Aug 2023, 09:09
                  0
                  • M Matiyash
                    31 Aug 2023, 09:03

                    @JonB well, what do you say?
                    fe22d3f9-d640-4010-8e90-9345d615c1de-image.png

                    J Offline
                    J Offline
                    JonB
                    wrote on 31 Aug 2023, 09:09 last edited by
                    #9

                    @Matiyash
                    LOL, like I said, I don't use OpenCV or try that example. I know nothing about the other errors it reports. But the using namespace cv has gone through without complaint, and Mat is accepted, so you ought be able to adapt that/get it working for your code.

                    1 Reply Last reply
                    0
                    • M Matiyash
                      31 Aug 2023, 09:03

                      @JonB well, what do you say?
                      fe22d3f9-d640-4010-8e90-9345d615c1de-image.png

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 31 Aug 2023, 11:20 last edited by
                      #10

                      @Matiyash The first error message basically says that std::string is an int which is very strange. Did you redefine "string" somewhere? I would not use "use namespace", at least not for cv.

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

                      J 1 Reply Last reply 31 Aug 2023, 11:30
                      1
                      • J jsulm
                        31 Aug 2023, 11:20

                        @Matiyash The first error message basically says that std::string is an int which is very strange. Did you redefine "string" somewhere? I would not use "use namespace", at least not for cv.

                        J Offline
                        J Offline
                        JonB
                        wrote on 31 Aug 2023, 11:30 last edited by
                        #11

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

                        Did you redefine "string" somewhere?

                        That seems impossible since the whole of the source file is shown, and it has nothing other than system <...> includes. And the error message states it is matching against std::string.....

                        The OP was only supposed to be using that sample code to get either cv::Mat or using namespace vc; Mat working.

                        1 Reply Last reply
                        0
                        • SGaistS SGaist moved this topic from Qt for Python on 31 Aug 2023, 18:21

                        1/11

                        31 Aug 2023, 07:50

                        • Login

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