problem opencv, qt, c++, win10



  • 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);
    

    }



  • @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



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

    alt text


  • Moderators

    @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;
    }
    


  • I DON'T HAVE ERROR....

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


  • Qt Champions 2016

    @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;
        }
    

  • Moderators

    @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.



  • 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



  • @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");
    

  • Moderators

    @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?



  • 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
    }


  • 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



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



  • 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.


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.