Regarding exmaples of Open CV

asked 2013-10-01 01:27:26 -0500

Harish gravatar image

Hi, I know this is basic question, but it would be helpfull if I get an answer:

include <opencv\cv.h>

include <opencv\highgui.h>

using namespace cv;

int main(int, char**) { int i=1; VideoCapture cap(0); if(!cap.isOpened()) return -1;

Mat frame, edges;
namedWindow("edges",1);
for(;;)
{
    cap >> frame;
    cvtColor(frame, edges, CV_BGR2GRAY);
    GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);

    Canny(edges, edges, 0, 30, 3);

        imshow("edges", edges);


    if(waitKey(30) >= 0) break;
}
return 0;

}

The above code executes but opens multiple windows. where the active window shows the camera video. the other windows have stills . I couldn't understand the problem here. I understand that imshow is the one which is used to show images, since it is in loop I get multiple windows. Imshow accepts 2 arguement and first one is window name and 2nd one is array. Since I have given name as "edges" in named window, so it should show camera video in only one window.

Could anyone help me what can be the problem? Thanks in advance....

edit retag flag offensive close merge delete

Comments

it does not here. is that the exact code ? what is int i=0; for ?

could you add your os / opencv version ?

berak gravatar imageberak ( 2013-10-01 04:33:01 -0500 )edit

Hi,

Please ignore variable i, because I used as a flag and tried to execute imshow for once. So please ignore that...

the rest code is exact same..... I am using Windows 8 (9200 build) and opencv version 2.4.6.. Visual studio 2012

Harish gravatar imageHarish ( 2013-10-01 05:22:44 -0500 )edit

I understood the problem... And fixed it.. I declared string and passed it as the name and it worked.........

Harish gravatar imageHarish ( 2013-10-01 08:40:25 -0500 )edit