c++ - imshow is not working -
i used loop reading 300 frames , accumulating them.i gave imshow command inside print frames continuously not printed during loop processing comes single image
here's code:
enter code here #include<iostream> #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include<stdlib.h> #include<stdio.h> using namespace cv; using namespace std; int main() { char k; int learningframes=300; videocapture cap(0); if(cap.isopened()==0) { cout<<"error"; return -1; } //while(1) //{ mat frame; cap>>frame; mat frameaccf,frameacc,framethr32,framehsv,framethr; frameaccf=mat::zeros(frame.size(),cv_32fc1); for(int i=0;i<=learningframes;i++) { cap>>frame; imshow("nn",frame); cvtcolor(frame,framehsv,cv_bgr2hsv); inrange(framehsv,scalar(0,30,0),scalar(50,150,255),framethr); framethr.convertto(framethr,cv_32f); accumulate(framethr,frameaccf); } frameaccf=frameaccf/300; frameaccf.convertto(frameaccf,cv_8u); imshow("frame",frame); imshow("frameacc",frameaccf); waitkey(0); //if(k=='q') //break; //} return 0; }
you need put waikey()
inside loop
for(int i=0;i<=learningframes;i++) { cap>>frame; imshow("nn",frame); cvtcolor(frame,framehsv,cv_bgr2hsv); inrange(framehsv,scalar(0,30,0),scalar(50,150,255),framethr); framethr.convertto(framethr,cv_32f); accumulate(framethr,frameaccf); waitkey(0); }
Comments
Post a Comment