Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Something goes wrong with OpenCV in QtCreator
QtWS25 Last Chance

Something goes wrong with OpenCV in QtCreator

Scheduled Pinned Locked Moved 3rd Party Software
opencvqtcreator
9 Posts 3 Posters 2.7k 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.
  • D Offline
    D Offline
    Duino
    wrote on 8 Mar 2015, 06:06 last edited by
    #1

    I want to use OpenCV in QtCreator and I edit the .pro file.When I use OpenCV 1.0 lib,code is showed below:

    •   IplImage* pFrame = NULL;
        CvCapture* capture = cvCreateCameraCapture(1);
        cvNamedWindow("video", 1);
        while (1){
            pFrame = cvQueryFrame(capture);
            if (!pFrame) break;
            cvShowImage("video", pFrame);
            char c = cvWaitKey(33);
            if(c == 27) break;
        }
        cvReleaseCapture(&capture);
        cvDestroyWindow("video");
        return 0;
      

    It could open the camera and show it in a window.But when I use OpenCV 2.x lib,code is showed below:

    •  Mat pFrame;
       VideoCapture capture(1);
       if (!capture.isOpened()){
           cout << "open camera failed!";
           return -1;
       }
       namedWindow("test", 1);
       while (1){
           capture >> pFrame;
           if (pFrame.empty()) break;
           imshow("test", pFrame);
           char c = cvWaitKey(33);
           if (c == 27) break;
       }
       destroyWindow("test");
       return 0;
      

    It just keeps creating new windows,though every window could show one image from the camera.
    But when I use VS2013 to do the samething, it all work out fine.
    Thank you for reading my question.

    Just enjoy coding.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Mar 2015, 15:23 last edited by
      #2

      Hi and welcome to devnet,

      Are you using the exact same code in VS and Qt Creator ?

      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
      • D Offline
        D Offline
        Duino
        wrote on 8 Mar 2015, 23:34 last edited by
        #3

        Yes,exactly the same. I just copy the code from VS to Qt Creator.

        Just enjoy coding.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Mar 2015, 22:17 last edited by
          #4

          Are you using the same project for Visual Studio and Qt Creator ?

          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
          • D Offline
            D Offline
            Duino
            wrote on 11 Mar 2015, 11:41 last edited by
            #5

            No, just use the same code in different projects.

            Just enjoy coding.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 11 Mar 2015, 21:55 last edited by
              #6

              Then are you using the same version of OpenCV for both projects ?

              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
              • D Offline
                D Offline
                Duino
                wrote on 12 Mar 2015, 00:36 last edited by
                #7

                Of course,I use the same OpenCV lib for VS2013 and QtCreator. What do you think might go wrong?

                Just enjoy coding.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 12 Mar 2015, 23:40 last edited by
                  #8

                  IIRC, OpenCV has a Qt backend so I was wondering if there was a mix somewhere that could trigger that bug

                  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
                  • S Offline
                    S Offline
                    stereomatchingkiss
                    wrote on 4 Jun 2015, 06:10 last edited by
                    #9

                    Could you send us the minimum projects which could reproduce the bugs(.hpp, .cpp and your .pro), if you could put it on github, it would be even better(easier for us to download and test it)
                    I have a long time haven't played with openCV2, but I do have some experience about it

                    By the way, since you are using Qt, why not just use QLabel or graphicsview framework to show the image?If you need to convert the QImage and cv::Mat, you could look at here.

                    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