title: IP Camera stop streaming after some time
body: <p>I am working on one application where I want to use <code>IP camera</code> for displaying video streaming and and some other major operations on image captured by the <code>IP Camera</code>.</p>
  
  <p><strong>Libraries used in Camera capture</strong>
  For Camera Capture : <a href="http://www.emgu.com/wiki/index.php?title=Camera_Capture" rel="nofollow">Emgu.CV</a> Library</p>
  
  <p>Below is the code which I am using in C#.</p>
  
  <p><em>Variable Declaration</em></p>
  
  <pre><code>    private Capture capture;        //takes images from camera as image frames
      private Emgu.CV.UI.ImageBox img; // Dynamic Picture Controls
      private int nCam;               // no of cameras   
  </code></pre>
  
  <p><em>Code for Processing Image</em></p>
  
  <pre><code>  private void ProcessFrame(object sender, EventArgs arg)
    {
      try
            {                
        // Live Streaming Display
       Image&lt;Bgr, Byte&gt; ImageFrame = capture.QueryFrame();
  
      // If Ip camera try to reinitialize the IP camera
      if(ImageFrame == null)
     {
         capture.Dispose();
         capture = new Capture(URL);                              
          ImageFrame = capture.QueryFrame();
       }                
        ImageFrame = ImageFrame.Resize(img.Width, img.Height, Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR); 
  
       img.Image = ImageFrame;
  
      // Here I am doing some other operations like 
      // 1. Save Image captured from the IP Camera
      // 2. Detect faces in Image 
      // 3. Draw Face markers on Image
      // 4. Some database based on result of Face Detection
      // 4. Delete image File 
      // continue Looping for other Ip Cameras        
  
       }
        catch (NullReferenceException e)
         {
         }
      }
  </code></pre>
  
  <p>Now, The Problem is after some time the <code>QueryFrame()</code> provide <code>null</code> value and camera Stop streaming.</p>
  
  <p>Can any one tell me why this is happening?
  How I can resolve this problem?
  If any more information is needed Please Let me know.</p>
  
  <p>Thanks in Advance.</p>