This is my code to get frame from video. I want to show 2 frame in video with looping and condition.
int main( int argc, char** argv )
{
string fileName = "E:\\Tugas Akhir\\Video Master\\city_1.avi";
Mat image1;
Mat image2;
Mat frame;
cv::Mat result;
VideoCapture cap(fileName);
if(!cap.isOpened())
return -1;
Mat edges;
for(int loop=0;;loop++)
{
//std::cout<<loop<<endl;
cap >> frame; // get a new frame from camera
if(loop>0 && (loop%20)==0){
//std::cout<<"frame 2"<<endl;
image2=frame;
**imshow("image2",image2);**
break;
}else if(loop==0){
image1=frame;
**imshow("image1",image1);**
//std::cout<<"frame 1"<<endl;
}
//loop++;
if(waitKey(30) >= 0) break;
}
waitKey(0);
return 0;
}
And here's the result, 2 windows with 2 different image
but when i change imshow("image1",image1) method position ...
if(loop>0 && (loop%20)==0){
//std::cout<<"frame 2"<<endl;
image2=frame;
**imshow("image1",image1);**
**imshow("image2",image2);**
break;
}else if(loop==0){
image1=frame;
//std::cout<<"frame 1"<<endl;
}
image1 windows show same picture with image2,
i don't know why it show strange result, please tell me how to fix it, thank you