如何捕获IP摄像机图像 [英] How to Capture IP Camera Image

查看:103
本文介绍了如何捕获IP摄像机图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



Hi everyone,

private void button2_Click(object sender, EventArgs e)
        {
            byte[] buffer = new byte[100000];
            int read, total = 0;
            try 
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://192.168.1.253/nphMotionJpeg?Resolution=320x240&Quality=Standard");
                req.Method = "POST";
                //req.Timeout = 500;
                NetworkCredential cred = new NetworkCredential("Administrator", "admintdx");
                req.Credentials = cred;
                WebResponse resp = req.GetResponse();
                // get response stream

                Stream stream = resp.GetResponseStream();
                // read data from stream

                while ((read = stream.Read(buffer, total, 1000)) != 0)
                {
                    total += read;
                }
                // get bitmap

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

            }
            catch (Exception ex)
            {
                MessageBox.Show("Grab Error:" + ex, "Error!!");
            }


        }





我正在研究一个项目样本来捕获来自IP摄像头的图像,但我收到此错误:服务器提交了协议违规。部分= ResponseHeader详细信息= CR必须后跟LF。有没有其他选项来读取我的scrape URL的响应。请告诉我怎么可能......有人可以帮忙吗?



I am working on a project sample to capture image from IP camera, but I got this error: "The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF". Is there any other option to read the response of my scrape URL. Please let me know how can it be possible... Could someone help?

推荐答案

这可能对你有所帮助 -



Camera Vision - C#上的视频监控 [ ^ ]
This might help you-

Camera Vision - video surveillance on C#[^]


以下是两个例子,都有现场演示。两者都是免费的。两者都是基于HTML / JavaScript的,但它们仍然可以用作参考。



对于基于MJPEG的IP摄像机:http://foscam.us/forum/free-generic-browser-interface-for-foscam-ip- mjpeg-cameras-t2522.html



对于基于H.264的IP摄像机: http://foscam.us/forum/free-generic-browser-interface-for-foscam-ip-h -264-cameras-t2686.html



注意:以上示例适用于在任何操作系统上运行的任何支持Internet浏览器的设备,使用任何浏览器。从电脑到平板电脑,再到手机,甚至是一些电视。



有10个Live Demos,其中一个包括使用你自己的相机和示例,不需要首先下载/安装任何东西。



也可以将上述接口嵌入到实际的Web UI相机固件中,以便不需要网络主机/切断为他们服务。将您的相机用作网络主机/迷你网站。



Don
Here are two examples, both with live demos. Both are free. Both are HTML/JavaScript based, but they still can be used for reference.

For MJPEG Based IP Cameras: http://foscam.us/forum/free-generic-browser-interface-for-foscam-ip-mjpeg-cameras-t2522.html

For H.264 Based IP Cameras: http://foscam.us/forum/free-generic-browser-interface-for-foscam-ip-h-264-cameras-t2686.html

Note: The above examples, work with ANY Internet browser capable device, that is running on ANY Operating System, using ANY browser. From Computers to Tablets to Phones and even some TVs.

There are 10 Live Demos, one of which includes using your own camera(s) with the example, without needing to download/install anything first.

It's also possible to embed the above Interfaces in the actual Web UI camera firmware, as well, as to not require a web host/sever to serve them. Using your camera as a web host/mini-website.

Don


试试这个

Try This
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>


这篇关于如何捕获IP摄像机图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆