如何从IP摄像机获取更高Fps的JPEG格式的图像

|| 大家好! 从JPEG格式的Panasonic IP摄像机中抓取图像时遇到问题,实际上是fps的问题,因为fps始终保持不超过1或2,但实际上摄像机最多支持30个,凸轮型号为Panasonic WV-SP302E我正在使用以下C#代码抓取图像并将其显示在我的winforms应用程序中
public partial class Form1 : Form
{
    // indicates wether to prevent caching in case of a proxy server or not
    private bool preventCaching = false;                

    public Form1()
    {
        InitializeComponent();
    }

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        while (true)
        {
            this.pictureBox1.Image = this.GetSingleFrame(@\"http://ipaddress/SnapshotJPEG?Resolution=320x240&Quality=Standard\");                
        }
    }

    /// <summary>
    /// Get a single JPEG frame from the camera
    /// </summary>
    /// <param name=\"source\">JPEG Stream source</param>
    /// <exception cref=\"WebException\">If the IP camera is not receable or an error is occured</exception>
    /// <exception cref=\"Exception\">If an unknown error occured</exception>
    public Bitmap GetSingleFrame(string source)
    {
        byte[] buffer = new byte[512 * 1024];   // buffer to read stream
        HttpWebRequest req = null;
        WebResponse resp = null;
        Stream stream = null;
        Random rnd = new Random((int)DateTime.Now.Ticks);

        try
        {
            int read, total = 0;

            // create request
            if (!preventCaching)
            {
                req = (HttpWebRequest)WebRequest.Create(source);
            }
            else
            {
                req = (HttpWebRequest)WebRequest.Create(source + ((source.IndexOf(\'?\') == -1) ? \'?\' : \'&\') + \"fake=\" + rnd.Next().ToString());
            }
            // set login and password                
            req.Credentials = new NetworkCredential(\"root\", \"a\");                

            req.Timeout = -1;

            resp = req.GetResponse();

            // get response stream
            stream = resp.GetResponseStream();

            // loop
            do
            {
                read = stream.Read(buffer, total, 1024);

                total += read;
            }
            while (read != 0);

            Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0, total));

            return bmp;
        }
        catch (WebException ex)
        {
            string s = ex.ToString();
            return null;
        }
        catch (Exception ex)
        {
            string s = ex.ToString();
            return null;
        }
        finally
        {
            // abort request
            if (req != null)
            {
                req.Abort();
                req = null;
            }
            // close response stream
            if (stream != null)
            {
                stream.Close();
                stream = null;
            }
            // close response
            if (resp != null)
            {
                resp.Close();
                resp = null;
            }
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        this.backgroundWorker1.RunWorkerAsync();
    }
}
我什至使用backgrounworker组件在另一个线程中抓取图像,但仍为2 fps。任何想法如何增加fps     
已邀请:
自问这个问题以来已经有一段时间了,但是从那以后仍然是一样的。 相机在流传输模式下每秒最多可提供30帧,但是这不一定适用于JPEG快照帧速率。根据相机型号的不同,有效JPEG速率可能会比全速流更快或更慢。 您实际上无能为力(对于MPEG-4 / H.264摄像机来说,以较低的速率发送JPEG通常是这样),您可以选择: 通过接收视频提要(可以是RTSP之类的标准协议,也可以是通过SDK的专有协议或相机供应商提供的ActiveX控件)从相机获取图像 用更合适的型号替换相机,每秒可获得更多的JPEG快照     
通常,从IP摄像机查询的jpeg图像/秒不超过每秒。如果您想要30fps的视频流,则需要查询运动jpeg之类的\“ video \”流,而不是快照流。     
看起来您已经进行了很多设置,以使该流继续进行。从那里取出分配,这样您就不会不断分配和释放资源会有所帮助。 一旦流完成,读取多个帧可能会有所帮助(即从数据采集循环中产生位图)。仅供参考,您不应该从非GUI线程调用GUI操作。使用ReportProgress将数据发送回去。 您确定是花些时间而不是displaynig来捕获它吗?您是否尝试过删除绘图代码进行测试?     
确保您充分照明了场景。简单且有点不准确的解释是,处于自动曝光模式的数码相机将等待,直到它们捕获了足够的光线,而在黑暗的场景中(例如夜晚的黑暗房间),传感器效率低下将花费一段时间。在更明亮的房间或白天在室外尝试使用相机,看看帧频是否提高。     

要回复问题请先登录注册