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. problem opencv, qt, c++, win10
Qt 6.11 is out! See what's new in the release blog

problem opencv, qt, c++, win10

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 5 Posters 6.1k Views 2 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.
  • CHRISTIANo.C CHRISTIANo.

    my program compile sucessfull, but in the moment for appear the img that upload, not appear nothing.

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt

    SOURCES += main.cpp

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d

    INCLUDEPATH += $$PWD/../../build/include
    DEPENDPATH += $$PWD/../../build/include/opencv2

    
    my program :
    
    

    #include <iostream>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/video/video.hpp>
    #include <opencv2/features2d/features2d.hpp>
    #include <opencv2/nonfree/nonfree.hpp>

    using namespace std;
    using namespace cv;

    Mat frame,imagen;

    int main()
    {

    imagen = imread("C:\\opencv\\programas\\2\\cris.png");
    imshow("imagen",imagen);
    

    }

    joeQJ Offline
    joeQJ Offline
    joeQ
    wrote on last edited by
    #2

    @CHRISTIANo. hi,friend,welcoem.

    add below snippet to you main function test it again.
    /** your some code ...*/

    int main()
    {
         imagen = imread("C:\\opencv\\programas\\2\\cris.png");
         imshow("imagen",imagen);
    
         waitKey(0); ///< Note this 
         return 0;
    }
    

    to see the more information from refrence.

    Reference

    waitKey

    Just do it!

    1 Reply Last reply
    2
    • CHRISTIANo.C Offline
      CHRISTIANo.C Offline
      CHRISTIANo.
      wrote on last edited by
      #3

      i have the same error...!!!
      if you can review this generla messag...
      can be this problem?

      alt text

      jsulmJ 1 Reply Last reply
      0
      • CHRISTIANo.C CHRISTIANo.

        i have the same error...!!!
        if you can review this generla messag...
        can be this problem?

        alt text

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @CHRISTIANo. You should first make sure you could open the image successfully as shown here: http://docs.opencv.org/2.4/doc/tutorials/introduction/display_image/display_image.html

        There is even a whole example without Qt:

        #include <opencv2/core/core.hpp>
        #include <opencv2/highgui/highgui.hpp>
        #include <iostream>
        
        using namespace cv;
        using namespace std;
        
        int main( int argc, char** argv )
        {
            if( argc != 2)
            {
             cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
             return -1;
            }
        
            Mat image;
            image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file
        
            if(! image.data )                              // Check for invalid input
            {
                cout <<  "Could not open or find the image" << std::endl ;
                return -1;
            }
        
            namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
            imshow( "Display window", image );                   // Show our image inside it.
        
            waitKey(0);                                          // Wait for a keystroke in the window
            return 0;
        }
        

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

        1 Reply Last reply
        2
        • CHRISTIANo.C Offline
          CHRISTIANo.C Offline
          CHRISTIANo.
          wrote on last edited by
          #5

          I DON'T HAVE ERROR....

          compiled sucessfull.... and i have the same result.... no upload the image :(

          mrjjM jsulmJ 2 Replies Last reply
          0
          • CHRISTIANo.C CHRISTIANo.

            I DON'T HAVE ERROR....

            compiled sucessfull.... and i have the same result.... no upload the image :(

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @CHRISTIANo.

            Did you try the code @jsulm showed ?
            it contains check if image can load which your code did not have.

             if(! image.data )                              // Check for invalid input
                {
                    cout <<  "Could not open or find the image" << std::endl ;
                    return -1;
                }
            
            1 Reply Last reply
            0
            • CHRISTIANo.C CHRISTIANo.

              I DON'T HAVE ERROR....

              compiled sucessfull.... and i have the same result.... no upload the image :(

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @CHRISTIANo. I'm not talking about compiler errors. I'm talking about this:

              if(! image.data )                              // Check for invalid input
                  {
                      cout <<  "Could not open or find the image" << std::endl ;
                      return -1;
                  }
              

              to make sure the image was loaded.
              And you should start with the example I provided without Qt. If it is working then add it to your Qt app.

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

              1 Reply Last reply
              2
              • CHRISTIANo.C Offline
                CHRISTIANo.C Offline
                CHRISTIANo.
                wrote on last edited by CHRISTIANo.
                #8

                This is my code, i don´t find the solution..?

                #include <opencv2/core/core.hpp>
                #include <opencv2/highgui/highgui.hpp>
                #include <iostream>
                
                using namespace cv;
                using namespace std;
                
                int main( int argc, char** argv )
                {
                    if( argc != 2)
                    {
                     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
                     return -1;
                    }
                
                    Mat image;
                    image = imread("C:\\opencv\\programas\\2\\cris.png");   // Read the file
                
                    if(! image.data )                              // Check for invalid input
                    {
                        cout <<  "Could not open or find the image" << std::endl ;
                        return -1;
                    }
                
                    namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
                    imshow( "Display window", image );                   // Show our image inside it.
                
                    waitKey(0);                                          // Wait for a keystroke in the window
                    return 0;
                }
                
                

                her the .PRO

                TEMPLATE = app
                CONFIG += console c++11
                CONFIG -= app_bundle
                CONFIG -= qt
                
                SOURCES += main.cpp
                
                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                
                INCLUDEPATH += $$PWD/../../build/include
                DEPENDPATH += $$PWD/../../build/include/opencv2
                
                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                
                INCLUDEPATH += $$PWD/../../build/include
                DEPENDPATH += $$PWD/../../build/include/opencv2
                
                
                

                WIN10
                64BITS
                OPENCV 2.4.9
                CMAKE 3.1.0
                VSIUAL STUDIO 2012

                joeQJ jsulmJ 2 Replies Last reply
                0
                • CHRISTIANo.C CHRISTIANo.

                  This is my code, i don´t find the solution..?

                  #include <opencv2/core/core.hpp>
                  #include <opencv2/highgui/highgui.hpp>
                  #include <iostream>
                  
                  using namespace cv;
                  using namespace std;
                  
                  int main( int argc, char** argv )
                  {
                      if( argc != 2)
                      {
                       cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
                       return -1;
                      }
                  
                      Mat image;
                      image = imread("C:\\opencv\\programas\\2\\cris.png");   // Read the file
                  
                      if(! image.data )                              // Check for invalid input
                      {
                          cout <<  "Could not open or find the image" << std::endl ;
                          return -1;
                      }
                  
                      namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
                      imshow( "Display window", image );                   // Show our image inside it.
                  
                      waitKey(0);                                          // Wait for a keystroke in the window
                      return 0;
                  }
                  
                  

                  her the .PRO

                  TEMPLATE = app
                  CONFIG += console c++11
                  CONFIG -= app_bundle
                  CONFIG -= qt
                  
                  SOURCES += main.cpp
                  
                  win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                  else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                  
                  INCLUDEPATH += $$PWD/../../build/include
                  DEPENDPATH += $$PWD/../../build/include/opencv2
                  
                  win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                  else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                  
                  INCLUDEPATH += $$PWD/../../build/include
                  DEPENDPATH += $$PWD/../../build/include/opencv2
                  
                  
                  

                  WIN10
                  64BITS
                  OPENCV 2.4.9
                  CMAKE 3.1.0
                  VSIUAL STUDIO 2012

                  joeQJ Offline
                  joeQJ Offline
                  joeQ
                  wrote on last edited by
                  #9

                  @CHRISTIANo. hi,

                  can you show me your example png file ? is it transparent ?

                  did you test another image file, like jpeg.

                  or modify the \\ to / try it.

                  imread("C:/opencv/programas/2/cris.png");
                  

                  Just do it!

                  1 Reply Last reply
                  0
                  • CHRISTIANo.C CHRISTIANo.

                    This is my code, i don´t find the solution..?

                    #include <opencv2/core/core.hpp>
                    #include <opencv2/highgui/highgui.hpp>
                    #include <iostream>
                    
                    using namespace cv;
                    using namespace std;
                    
                    int main( int argc, char** argv )
                    {
                        if( argc != 2)
                        {
                         cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
                         return -1;
                        }
                    
                        Mat image;
                        image = imread("C:\\opencv\\programas\\2\\cris.png");   // Read the file
                    
                        if(! image.data )                              // Check for invalid input
                        {
                            cout <<  "Could not open or find the image" << std::endl ;
                            return -1;
                        }
                    
                        namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
                        imshow( "Display window", image );                   // Show our image inside it.
                    
                        waitKey(0);                                          // Wait for a keystroke in the window
                        return 0;
                    }
                    
                    

                    her the .PRO

                    TEMPLATE = app
                    CONFIG += console c++11
                    CONFIG -= app_bundle
                    CONFIG -= qt
                    
                    SOURCES += main.cpp
                    
                    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x64/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                    
                    INCLUDEPATH += $$PWD/../../build/include
                    DEPENDPATH += $$PWD/../../build/include/opencv2
                    
                    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
                    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/x86/vc11/lib/ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d lopencv_highgui249d
                    
                    INCLUDEPATH += $$PWD/../../build/include
                    DEPENDPATH += $$PWD/../../build/include/opencv2
                    
                    
                    

                    WIN10
                    64BITS
                    OPENCV 2.4.9
                    CMAKE 3.1.0
                    VSIUAL STUDIO 2012

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @CHRISTIANo. What exactly happens with this code? Is the image not shown? Is "Could not open or find the image" printed?
                    Can you open this PNG file in an image viewer?

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

                    1 Reply Last reply
                    0
                    • mrdebugM Offline
                      mrdebugM Offline
                      mrdebug
                      wrote on last edited by
                      #11

                      Please use this standard approach

                      imagen = imread("C:/opencv/programas/2/cris.png");

                      Try

                      while (1) {
                          Mat imagen = imagen = imread("C:/opencv/programas/2/cris.png");
                          imshow("imagen",imagen);
                          if (waitKey(30) == 27); //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
                      }
                      

                      Need programmers to hire?
                      www.labcsp.com
                      www.denisgottardello.it
                      GMT+1
                      Skype: mrdebug

                      1 Reply Last reply
                      0
                      • CHRISTIANo.C Offline
                        CHRISTIANo.C Offline
                        CHRISTIANo.
                        wrote on last edited by CHRISTIANo.
                        #12

                        well...
                        the specific problem is that my code compiled sucessfull, but when run this program, not appear nothig , only "Press <RETURN> to close this window...", as that has been finally
                        I BELIEVE that is my QT 4.4.0 that not function with my VISUAL STUDIO 2012

                        in disk C.... "C:\Qt\5.2.1\msvc2012_64 " can you help..!!

                        here can provide this imag
                        i test with a camera and nothing....
                        i test with "/" and nothing
                        2_1506533649371_ff.png 1_1506533649371_3.png 0_1506533649370_2.png

                        jsulmJ 1 Reply Last reply
                        0
                        • mrdebugM Offline
                          mrdebugM Offline
                          mrdebug
                          wrote on last edited by
                          #13

                          Have you build opencv yourself? If I remember correctly opencv is built with msvc 2015 and your Qt package is so outdated...

                          Need programmers to hire?
                          www.labcsp.com
                          www.denisgottardello.it
                          GMT+1
                          Skype: mrdebug

                          1 Reply Last reply
                          1
                          • mrdebugM Offline
                            mrdebugM Offline
                            mrdebug
                            wrote on last edited by
                            #14

                            I suggest you to upgrade yout visual studio installation, to check to have msvc 2015, the already built opencv package and Qt 5.9.1 built with msvc 2015.

                            Need programmers to hire?
                            www.labcsp.com
                            www.denisgottardello.it
                            GMT+1
                            Skype: mrdebug

                            1 Reply Last reply
                            0
                            • CHRISTIANo.C CHRISTIANo.

                              well...
                              the specific problem is that my code compiled sucessfull, but when run this program, not appear nothig , only "Press <RETURN> to close this window...", as that has been finally
                              I BELIEVE that is my QT 4.4.0 that not function with my VISUAL STUDIO 2012

                              in disk C.... "C:\Qt\5.2.1\msvc2012_64 " can you help..!!

                              here can provide this imag
                              i test with a camera and nothing....
                              i test with "/" and nothing
                              2_1506533649371_ff.png 1_1506533649371_3.png 0_1506533649370_2.png

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @CHRISTIANo. You should check which compiler was used to build OpenCV. You need a build done with same compiler.

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

                              1 Reply Last reply
                              1

                              • Login

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