Updated by Andrey Pavlenko about 12 years ago
Hey guys
I meet a problem which is really weird, and weird.And I think it might be a bug.
As soon as the program executes excutes the line @"cap "cap >> x"@ x" where @"x"@ x is a @Mat@, Mat, the @imshow()@ imshow() cannot show frames defined before this line.
Here is the test code:
1.The window "test" shows continous frames untill you press the "ENTER" key
2.Keep the last frame in procedure 1 and show it in Window "test frame_ref"
3.Excute @"cap "cap >> x"@, get x",get a new frame
4.Show frame: frame_ref// it actually shows the frame x,however my code wants to show frame_ref
<pre>
#include @#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char * argv[])
{
VideoCapture cap(0);//open camera
if( !cap.isOpened())
return -1;
Mat frame_test;
namedWindow( "test", 1 );
for(;;)
{
cap >> frame_test;
imshow( "test", frame_test );
if( waitKey(30) == 13) //if press "ENTER" key, jump out the loop
break;
}
const Mat frame_ref(frame_test);
namedWindow("test frame_ref");
imshow("test frame_ref",frame_ref);// show frame: "frame_ref"
cvWaitKey(30);
Mat x;
cap >> x;//if I comment this line, the problem will be gone
namedWindow("After cap >> frame");
imshow("After cap >> frame", frame_ref);// show frame: "frame_ref"
cvWaitKey(30);
system("pause");
}
</pre> }@
I meet a problem which is really weird, and weird.And I think it might be a bug.
As soon as the program executes excutes the line @"cap "cap >> x"@ x" where @"x"@ x is a @Mat@, Mat, the @imshow()@ imshow() cannot show frames defined before this line.
Here is the test code:
1.The window "test" shows continous frames untill you press the "ENTER" key
2.Keep the last frame in procedure 1 and show it in Window "test frame_ref"
3.Excute @"cap "cap >> x"@, get x",get a new frame
4.Show frame: frame_ref// it actually shows the frame x,however my code wants to show frame_ref
<pre>
#include @#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char * argv[])
{
VideoCapture cap(0);//open camera
if( !cap.isOpened())
return -1;
Mat frame_test;
namedWindow( "test", 1 );
for(;;)
{
cap >> frame_test;
imshow( "test", frame_test );
if( waitKey(30) == 13) //if press "ENTER" key, jump out the loop
break;
}
const Mat frame_ref(frame_test);
namedWindow("test frame_ref");
imshow("test frame_ref",frame_ref);// show frame: "frame_ref"
cvWaitKey(30);
Mat x;
cap >> x;//if I comment this line, the problem will be gone
namedWindow("After cap >> frame");
imshow("After cap >> frame", frame_ref);// show frame: "frame_ref"
cvWaitKey(30);
system("pause");
}
</pre> }@