Imshow produces many windows(c++, Visualstudio)

asked 2017-11-16 07:55:49 -0500

esconda gravatar image

updated 2017-11-16 07:57:46 -0500

I just would like to run opencv project in Visual Studio.I set all necessarry variables , directory include files and succesfully builded example project.

The only problem is; Imshow command produces many window when I run the program.I try to get frames as a Video using videocapture and I am using opencv 2412 x86 version for windows.

My example code:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include<iostream>
#include<stdio.h>

using namespace std;
using namespace cv;

int main()
{
Mat kernel;
Mat_<float> kernel1(3, 3);
int kernel_size;
int ind = 0;
VideoCapture cap(0); // open the default camera
if (!cap.isOpened())  // check if we succeeded
    return -1;

Mat edges;
Mat frame;
while (true)
{

    cap>>frame; // get a new frame from camera


    imshow("Livestream", frame);

    if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;

}

After compiling(Pictures):

image description

As you see, Imshow produces many frame and window with different names(strange window names) after compiling the program.

Any help would be apreciated.

edit retag flag offensive close merge delete

Comments

mostly, problems like this are due to linking the wrong libs. (e.g. debug libs with release build of your prog)

" I am using opencv 2412 x86 version for windows." -- did you build those, locally ? (to my knowledge the prebuild libs are for vs2015, x64 ONLY)

berak gravatar imageberak ( 2017-11-16 08:03:14 -0500 )edit

I will use another version and inform you about that.

esconda gravatar imageesconda ( 2017-11-16 08:20:03 -0500 )edit

I chose opencv 3.0 version for visualstudio and I built opencv with "cmake -gui" for visualstudio2013,It created 2 types of files which is x64 and x86 version to be used in Visual studio.Then I correctly linked everything like libraries, include file etc(opencv_world300.lib , opencv_ts300.lib ,opencv_ts300d.lib opencv_world300d.lib) .It shows nothing now, no window appears.The program succesfully builded but , it shows nothing after I run the program.The program directly closes itself with exit code : -1073741515 (0xc0000135) 'A dependent dll was not found'.

esconda gravatar imageesconda ( 2017-11-16 08:51:03 -0500 )edit

please link either opencv_world300.lib or opencv_world300d.lib, but never both !

(and you do not need the ts libs at all, they're only for building unit tests)

berak gravatar imageberak ( 2017-11-16 09:28:16 -0500 )edit

Hi berak, I tried all solution for this operation.But unfortunately it gives me same error.Visual studio directly close my program with exit code : 'BarcodeRecognition.exe' (Win32): Loaded 'C:\Windows\SysWOW64\tmumh\20019\TmMon\2.5.0.2070\tmmon.dll'. Cannot find or open the PDB file. The program '[7440] BarcodeRecognition.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.

esconda gravatar imageesconda ( 2017-11-17 01:11:05 -0500 )edit
  • Loaded 'C:\Windows\SysWOW64\tmumh\20019\TmMon\2.5.0.2070\tmmon.dll' -- 32 / 64 bit mismatch.
  • Cannot find or open the PDB file. -- that's a warning, not an error.

in the end: -- your problems are all about setting up your project, and using your ide correctly.

berak gravatar imageberak ( 2017-11-17 01:19:51 -0500 )edit

I solved it copying dll files for opencv libraries to inside of my main Visual studio application file.Thank you for your help, it works very well now

esconda gravatar imageesconda ( 2017-11-18 15:17:55 -0500 )edit