Pin*_*ani 1 c# wsdl visual-studio ip-camera onvif
我有一个 ONVIF 网络摄像机。
我想从相机捕获图像,以便可以处理该图像并将其保存到文件系统。
我发现有一个 onvif api,它提供了一种GetSnapshotUri应该为我提供图像快照的方法:
http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl
我设法通过添加服务引用来在 Visual Studio 中导入此 api:
如何构建一个客户端以GetSnapshotUri从此服务进行调用?
因此,经过大量搜索,我设法从相机中捕获了图像。
第一个问题是我使用了“添加服务引用->高级->添加 Web 引用”,而不是直接在“添加服务引用”框中键入服务地址。
在这里,我添加了地址:http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl
然后我可以使用MediaClientpepOS 在评论中正确指出的类,最终代码如下所示:
var messageElement = new TextMessageEncodingBindingElement();
messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic;
CustomBinding bind = new CustomBinding(messageElement, httpBinding);
EndpointAddress mediaAddress = new EndpointAddress("http://192.168.1.168:10001/onvif/Media");
MediaClient mediaClient = new MediaClient(bind, mediaAddress);
mediaClient.ClientCredentials.UserName.UserName = "admin";
mediaClient.ClientCredentials.UserName.Password = "admin";
Profile[] profiles = mediaClient.GetProfiles();
string profileToken = profiles[1].token;
MediaUri mediaUri = mediaClient.GetSnapshotUri(profileToken);
Run Code Online (Sandbox Code Playgroud)
MediaUri.Uri然后可以在该地址中找到图像的 uri
| 归档时间: |
|
| 查看次数: |
20044 次 |
| 最近记录: |