What is problem? [closed]

asked 2018-02-04 12:04:18 -0600

I started learning opencv and faced such a problem. When I load an ordinary picture and try to bring it to the screen, two windows are created in one image and in the other just a window with a gray background. If I use the C version, then everything works well (one window is created in which this image is located) What can be the problem. I downloaded the image download code from the documentation and in the example they create one window with a picture. Version of OpenCV 3.4

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

#include <iostream>
#include <string>
using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    Mat image = imread("image.jpg");  

    if (!image.data)                              
    {
        cout << "Could not open or find the image" << std::endl;
        cv::waitKey(5000);
        return -1;
    }

    namedWindow("Display window", WINDOW_AUTOSIZE);
    imshow("Display window", image);
    waitKey();
    system("pause");
    return 0;
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2018-02-04 12:54:15.051723

Comments

" If C version, then everything works well " -- oh dear, please check your linker settings, thrice.

most likely, you're using debug libs with a release build, or the other way round (or, hell, -- even both)

berak gravatar imageberak ( 2018-02-04 12:30:51 -0600 )edit

хахахахаха I really used both of them. I connected as it is written on the Internet

Timur A gravatar imageTimur A ( 2018-02-04 12:41:44 -0600 )edit

yea, just don't. use release libs with your release project, and debug libs with your debug project., but never both.

berak gravatar imageberak ( 2018-02-04 12:47:06 -0600 )edit

the "long answer" (if you want to know) is:

release and debug libs have differnt vtables for the std:: classes (think: vector or string). if you mismatch those, your program is essentially doing "undefined behaviour", anything (including the infamous "nasal demons") might happen !

berak gravatar imageberak ( 2018-02-04 12:51:21 -0600 )edit
1

Yes, I understand, I made a mistake when I set up. Did not put in the studio the meaning of "all configurations"

Timur A gravatar imageTimur A ( 2018-02-04 12:52:05 -0600 )edit