title: C++ suddenly blocks on reading a frame from IP camera using VideoCapture
body: <p>I'm using OpenCV 3. Grabbing a frame using VideoCapture with an IP Camera is blocking if the camera goes disconnected from the network or there is an issue with a frame.
  I first check if <code>videoCapture.isOpened()</code>. If it is, I tried these methods but nothing seems to work:</p>
  
  <p><strong>1) grabber >> frame</strong></p>
  
  <pre><code>if(grabber.isOpened()) {
      grabber &gt;&gt; frame; 
      // DO SOMETHING WITH FRAME
  }
  </code></pre>
  
  <p><strong>2) read</strong></p>
  
  <pre><code>if(grabber.isOpened()) {
      if(!grabber.grab()){
        cout &lt;&lt; "failed to grab from camera" &lt;&lt; endl;
      } else {
        if (grabber.retrieve(frame,0) ){
          // DO SOMETHING WITH FRAME
        } else {
          // SHOW ERROR
        }
      }
  }
  </code></pre>
  
  <p><strong>3) grab/retrieve</strong></p>
  
  <pre><code>if(grabber.isOpened()) {
      if ( !grabber.read(frame) ) {
        cout &lt;&lt; "Unable to retrieve frame from video stream." &lt;&lt; endl;
      }
      else {
       // DO SOMETHING WITH FRAME
      } 
  }
  </code></pre>
  
  <p>The video stream gets stuck at some point grabbing a frame with all of the previous options, each one blocks but doesn't exit or returns any error.</p>
  
  <p>Do you know if there is a way to handle or solve this? Maybe some validations, try/catch or timer?</p>