I've written this code
while (true)
{
cv::Mat frame1,frame2,dst,temp;
if (!input_video.read(frame1))
{
fprintf(stderr, "Video has Finished .\n");
getchar();
return -1;
}
if (!input_video.read(frame2))
{
fprintf(stderr, "Video has Finished .\n");
getchar();
return -1;
}
cv::cvtColor(frame1,frame1,CV_RGB2GRAY) ;
cv::cvtColor(frame2,frame2,CV_RGB2GRAY) ;
cv::subtract(frame2,frame1,dst);
cv::imshow("F1",frame1);
cv::imshow("F2",frame2);
cv::imshow("dst",dst);
cv::waitKey();
}
and When I'm reading a video (not from a camera but a video from my hard disk) frame1,frame2 are the same !!!
I don't know why "read" method returns the same frame for frame2 ? so the subtracted image is always an empty picture !!!
should I do something especial for reading sequential frames simultaneously ? for example every time I want to read another frame use this line to get to that frame :
input_video.set(CV_CAP_PROP_POS_FRAMES,current_frame+1);
if so, is there another way not doing this ?!
Thanks