I'm trying to make a video start at the beginning just after the video has reached frame number 50(e.i repeat the first 50 frames indefinitely). I read about a previous question were one of the responders says that the only practical way of doing it is to save the frames and then re display them. But, can I just set a counter to the beginning of the VideoCapture object and just keep grabbing frames with the >> operator? This is what I tried so far:
VideoCapture cap;//I select the video by passing it as an argument though the terminal.
while(1){
if (FrameIndex == 50){
//cap.set(CV_CAP_PROP_POS_FRAMES, 0);
cap.set(CV_CAP_PROP_POS_AVI_RATIO , 0);
cap >> frame;
}
else{
cap >> frame;
}
//####################################
//# Rest of the code inside the loop #
//####################################
FrameIndex++;
FrameIndex = FrameIndex%50;
}