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. OpenCV library in QT Creator

OpenCV library in QT Creator

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.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
    Shane00
    wrote on 14 Aug 2020, 02:59 last edited by Shane00
    #1

    Hello, i am new to QT and my job requires me to use opencv for some project. Right now i am having trouble setting up a simple hello world using opencv. This is my current setup
    OS:Windows10
    QT 5.15.0, Opencv 4.4.0, mingw810_64

    #include "opencv2/opencv.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include <opencv2/core/types_c.h>
    using namespace cv;
    
    int main() {
        //create a gui window:
        namedWindow("Output",1);
    
        //initialize a 120X350 matrix of black pixels:
        Mat output = Mat::zeros( 120, 350, CV_8UC3 );
    
        //write text on the matrix:
        putText(output,
                "Hello World :)",
                cvPoint(15,70),
                FONT_HERSHEY_PLAIN,
                3,
                cvScalar(0,255,0),
                4);
    
        //display the image:
        imshow("Output", output);
    
        //wait for the user to press any key:
        waitKey(0);
    
        return 0;
    
    }
    

    I get a blank screen with no hello world output. Build seems to work fine

    The process "C:\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited normally.
    

    When i run the program however, i get this.

    C:\Users\Shane\Desktop\Project Files\build-Test2-Desktop_Qt_5_15_0_MinGW_64_bit-Debug\debug\Test2.exe exited with code -1073741515
    

    Debugger works fine on simple programs without the need for opencv library. Debugger doesn't work at all on this opencv code.

    This is my .pro file
    pro_file.png

    Oh and btw, when i tried running the .exe file without qt creator, it says i have missing dll files. Don't know if this information will be useful but yeah.

    J 1 Reply Last reply 14 Aug 2020, 07:53
    0
    • S Shane00
      14 Aug 2020, 02:59

      Hello, i am new to QT and my job requires me to use opencv for some project. Right now i am having trouble setting up a simple hello world using opencv. This is my current setup
      OS:Windows10
      QT 5.15.0, Opencv 4.4.0, mingw810_64

      #include "opencv2/opencv.hpp"
      #include "opencv2/highgui/highgui.hpp"
      #include <opencv2/core/types_c.h>
      using namespace cv;
      
      int main() {
          //create a gui window:
          namedWindow("Output",1);
      
          //initialize a 120X350 matrix of black pixels:
          Mat output = Mat::zeros( 120, 350, CV_8UC3 );
      
          //write text on the matrix:
          putText(output,
                  "Hello World :)",
                  cvPoint(15,70),
                  FONT_HERSHEY_PLAIN,
                  3,
                  cvScalar(0,255,0),
                  4);
      
          //display the image:
          imshow("Output", output);
      
          //wait for the user to press any key:
          waitKey(0);
      
          return 0;
      
      }
      

      I get a blank screen with no hello world output. Build seems to work fine

      The process "C:\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited normally.
      

      When i run the program however, i get this.

      C:\Users\Shane\Desktop\Project Files\build-Test2-Desktop_Qt_5_15_0_MinGW_64_bit-Debug\debug\Test2.exe exited with code -1073741515
      

      Debugger works fine on simple programs without the need for opencv library. Debugger doesn't work at all on this opencv code.

      This is my .pro file
      pro_file.png

      Oh and btw, when i tried running the .exe file without qt creator, it says i have missing dll files. Don't know if this information will be useful but yeah.

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 14 Aug 2020, 07:53 last edited by
      #2

      @Shane00 said in OpenCV library in QT Creator:

      namedWindow

      you're not using Qt at all, neither Gui components nor core elements, nor an event loop, this is pure opencv

      So I would suggest asking in their forum for help. The number of people than use the opencv-gui part are rather sparse in a Qt-Forum
      I'm assuming of course, so anyone feel free to correct me :)


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      S 1 Reply Last reply 14 Aug 2020, 08:48
      1
      • J J.Hilk
        14 Aug 2020, 07:53

        @Shane00 said in OpenCV library in QT Creator:

        namedWindow

        you're not using Qt at all, neither Gui components nor core elements, nor an event loop, this is pure opencv

        So I would suggest asking in their forum for help. The number of people than use the opencv-gui part are rather sparse in a Qt-Forum
        I'm assuming of course, so anyone feel free to correct me :)

        S Offline
        S Offline
        Shane00
        wrote on 14 Aug 2020, 08:48 last edited by
        #3

        @J-Hilk Not quite sure why i need QT either. My company asked me to use it because of cross platform portability. Anyways i have managed to remedy the problem. I just needed to type setx -m OPENCV_DIR C:\OpenCV\Build\x64\vc14 at the command line. Not quite sure why that made it happen but its working now. Thanks anyways.

        J P 2 Replies Last reply 14 Aug 2020, 08:56
        1
        • S Shane00
          14 Aug 2020, 08:48

          @J-Hilk Not quite sure why i need QT either. My company asked me to use it because of cross platform portability. Anyways i have managed to remedy the problem. I just needed to type setx -m OPENCV_DIR C:\OpenCV\Build\x64\vc14 at the command line. Not quite sure why that made it happen but its working now. Thanks anyways.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 14 Aug 2020, 08:56 last edited by
          #4

          @Shane00 said in OpenCV library in QT Creator:

          Not quite sure why that made it happen but its working now. Thanks anyways

          that added opencv to the environment path, and generally a bad idea, especially if you don't know what you're doing 😉

          My company asked me to use it because of cross platform portability.

          Qt is generally known, for cross platform GUI framework, opencv is generally know for its image processing.

          You can combine these, do the processing in opencv do the Gui in Qt. And it's probably what your company want you to do ;)


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          S 1 Reply Last reply 14 Aug 2020, 15:54
          2
          • J J.Hilk
            14 Aug 2020, 08:56

            @Shane00 said in OpenCV library in QT Creator:

            Not quite sure why that made it happen but its working now. Thanks anyways

            that added opencv to the environment path, and generally a bad idea, especially if you don't know what you're doing 😉

            My company asked me to use it because of cross platform portability.

            Qt is generally known, for cross platform GUI framework, opencv is generally know for its image processing.

            You can combine these, do the processing in opencv do the Gui in Qt. And it's probably what your company want you to do ;)

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 14 Aug 2020, 15:54 last edited by
            #5

            @J-Hilk one of the OpenCV HighGUI backend uses Qt :-)

            @Shane00 what @J-Hilk wrote is correct. There are many projects that use Qt together with OpenCV. The usually combo is image acquisition/processing with OpenCV and then the GUI and more with Qt.

            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
            • S Shane00
              14 Aug 2020, 08:48

              @J-Hilk Not quite sure why i need QT either. My company asked me to use it because of cross platform portability. Anyways i have managed to remedy the problem. I just needed to type setx -m OPENCV_DIR C:\OpenCV\Build\x64\vc14 at the command line. Not quite sure why that made it happen but its working now. Thanks anyways.

              P Offline
              P Offline
              Pablo J. Rogina
              wrote on 14 Aug 2020, 16:42 last edited by
              #6

              @Shane00 said in OpenCV library in QT Creator:

              its working now

              great, 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

              2/6

              14 Aug 2020, 07:53

              topic:navigator.unread, 4
              • Login

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