I am capturing an avi file and processing it. My code has worked for sometime without problem but now it does not seem to stop after the last frame of the video is captured. Instead it keeps looping back to the beginning of the video. I do not understand why this is happening and I can not think of anything changing with regards to Eclipse or OpenCV. I have tried the same code on my Ubuntu pc with the same video and it works without problems. I have even tried as much as reinstalling the OS and apps without success.
using namespace std;
using namespace cv;
int main(int argc, char** argv)
const string inputVideo = argv;
getcwd( buff, PATH_MAX );
std::string fileName( buff );
capture >> frame;
printf(" --(!) No captured frame -- Break!");
int key = waitKey(10);
if((char)key == 'c')
The solution that I used was posted as a comment by @G B. I am creating a solution so that it may be marked as one.
capture.get(CV_CAP_PROP_POS_FRAMES) before and after frame grabbing, if the value "after" is less than the value "before", then I've reached the end of the video.