Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过HTTP从MJPEG中提取JPEG?C#_C#_Stream_Ip Camera_Motion_Mjpeg - Fatal编程技术网

如何通过HTTP从MJPEG中提取JPEG?C#

如何通过HTTP从MJPEG中提取JPEG?C#,c#,stream,ip-camera,motion,mjpeg,C#,Stream,Ip Camera,Motion,Mjpeg,我有一个IP摄像头,它是一个安装了Motion的Raspberry PI。我想在使用C触发事件时获得一帧。C#中的编程代码如下: string sourceURL = "http://192.168.1.12:8081"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL); req.Credentials = new NetworkCredential("username", "pass"); WebRespo

我有一个
IP摄像头
,它是一个安装了
Motion
Raspberry PI
。我想在使用
C
触发事件时获得一帧。C#中的编程代码如下:

string sourceURL = "http://192.168.1.12:8081";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
req.Credentials = new NetworkCredential("username", "pass");

WebResponse resp = req.GetResponse();
using (Stream output = File.Create("some_image.jpeg"))
using (Stream input = resp.GetResponseStream())
{
    input.CopyTo(output); //<-- the code stops here 
}
string sourceURL=”http://192.168.1.12:8081";
HttpWebRequest req=(HttpWebRequest)WebRequest.Create(sourceURL);
请求凭证=新网络凭证(“用户名”、“通过”);
WebResponse resp=req.GetResponse();
使用(Stream output=File.Create(“some_image.jpeg”))
使用(流输入=resp.GetResponseStream())
{

input.CopyTo(output);/“作为对MJPEG文件或流的GET请求的响应,服务器通过HTTP流式传输JPEG帧序列。特殊的mime类型content-type multipart/x-mixed-replace;boundary=通知客户端需要几个部分(帧)作为由分隔的答案。此边界名称在MIME类型声明本身中明确披露。”(是的,我知道,维基百科…)=>尝试找出边界是什么,使用该边界从流中剪切jpeg。但如果我没记错,还应该有一个端点用于请求静态图像…为什么不将文件保存在内存中,然后转换它?请参阅获取操作/快照作为对MJPEG文件或流的GET请求的响应,服务器通过HTTP对JPEG帧序列进行流式传输。一个特殊的mime类型content type multipart/x-mixed-replace;boundary=通知客户端需要几个部分(帧)作为由分隔的答案。此边界名称在mime类型声明本身中明确披露(是的,我知道,Wikipedia…=>尝试找出边界是什么,使用该边界从流中剪切jpeg。但如果我没记错,还应该有一个端点来请求静态图像…为什么不将文件保存在内存中,然后转换它?请参阅获取操作/快照