Emgucv为IP Camera的QueryFrame返回null图像

时间:2014-02-18 04:04:48

标签: c# opencv camera emgucv

我正在开发一个应用程序,我希望使用IP camera来显示视频流以及IP Camera捕获的图像上的其他一些主要操作。

相机捕获中使用的库 对于相机捕捉:Emgu.CV

以下是我在C#中使用的代码。

变量声明

    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   

处理图像的代码

  private void ProcessFrame(object sender, EventArgs arg)
  {
    try
          {                
      // Live Streaming Display
     Image<Bgr, Byte> 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)
       {
       }
    }

现在,问题是在一段时间后QueryFrame()提供null值并且相机停止流式传输。

任何人都可以告诉我为什么会这样吗? 我怎么解决这个问题? 如果需要更多信息,请告诉我。

这是IP Camera stop streaming after some time的重复问题。

但是,我无法通过这个问题得到答案。 在此先感谢。

0 个答案:

没有答案
相关问题