Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Imshow produces many windows(c++, Visualstudio)

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 after compiling the program.

Any help would be apreciated.

Imshow produces many windows(c++, Visualstudio)

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.