title: How to tell if video reached end in opencv?
body: <p>I am trying to get the video to play in a loop. I want to check if it reached the end of the video so that I can reinstantiate it; How do I make it loop?</p>
  
  <pre><code> VideoStream::VideoStream(Filters* f, char* fileNam):
              filter(f),
              fileName(fileNam){
      TestON = true;
      cap = new VideoCapture(fileNam);
  };
  
  
  void VideoStream::readFrame(){
      if(!cap-&gt;isOpened())  // check if we succeeded
      cerr&lt;&lt;"cannot open video file";
      if(cap-&gt;get(CV_CAP_PROP_POS_AVI_RATIO==1)){
            cap = new VideoCapture(fileName);
      }
      Mat image;
      cap-&gt;read(image);
      if(!image.empty())
          imshow("haha", image);
      waitKey(1);
      image.release();
  };
  </code></pre>