资源简介
本demo,基于vs2017开发,采用C#开发语言,实现了onvif协议之抓图功能
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Discovery;
using System.Text;
using System.Threading.Tasks;
using TestOnvifClient.devicemgmt;
using TestOnvifClient.Media;
using static System.Net.Mime.MediaTypeNames;
namespace TestOnvifClient
{
class Program
{
static void Main(string[] args)
{
Test();
Console.Read();
}
static void Test()
{
string username = “admin“;
string password = “Admin123“;
string ip = “10.10.14.172“;
int port = 80;
EndpointAddress serviceAddress = new EndpointAddress(string.Format(“http://{0}:{1}/onvif/Media“ ip port));
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
httpBinding.KeepAliveEnabled = false;
var messageElement = new TextMessageEncodingBindingElement();
messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12 AddressingVersion.None);
CustomBinding bind = new CustomBinding(messageElement httpBinding);
//DeviceClient deviceClient = new DeviceClient(bind serviceAddress);
MediaClient mediaClient = new MediaClient(bind serviceAddress);
if (username != string.Empty)
{
// Handles adding of SOAP Security header containing User Token (user nonce pwd digest)
PasswordDigestBehavior behavior = new PasswordDigestBehavior(username password);
mediaClient.Endpoint.Behaviors.Add(behavior);
}
Profile[] mProfiles = mediaClient.GetProfiles();
if (mProfiles.Length > 0)
{
var ttt = mediaClient.GetSnapshotUri(mProfiles[0].token);
if(SavePhotoFromUrl(“pictest.JPEG“ ttt.Uri))
{
Console.WriteLine(“success“);
}
}
Console.WriteLine(“11111“);
}
public static bool SavePhotoFromUrl(string FileName string Url)
{
bool Value = false;
WebResponse response = null;
Stream stream = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Credentials = new NetworkCredential(“admin“ “Admin123“);
//request.
response = request.GetResponse();
stream = response.GetResponseStream();
if (!response.ContentType.ToLower().StartsWith(“text/“))
{
Value = SaveBinaryFile(response FileName);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 709 2018-04-25 09:05 TestOnvifClient\App.config
文件 18201 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\b-2.xsd
文件 2467 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\bf-2.xsd
文件 6457 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\common.xsd
文件 743 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\configuration.svcinfo
文件 15690 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\configuration91.svcinfo
文件 186573 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\devicemgmt.wsdl
文件 547 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\include.xsd
文件 4405 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\item.xsd
文件 377663 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\onvif.xsd
文件 826058 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\Reference.cs
文件 3417 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\Reference.svcmap
文件 5705 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\t-1.xsd
文件 657 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.AddScopesResponse.datasource
文件 643 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.BackupFile.datasource
文件 643 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.BinaryData.datasource
文件 647 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.Capabilities.datasource
文件 645 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.Certificate.datasource
文件 667 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.CertificateInformation.datasource
文件 657 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.CertificateStatus.datasource
文件 673 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.CreateCertificateResponse.datasource
文件 661 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.CreateUsersResponse.datasource
文件 675 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DeleteCertificatesResponse.datasource
文件 687 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DeleteDot1XConfigurationResponse.datasource
文件 673 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DeleteGeoLocationResponse.datasource
文件 661 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DeleteUsersResponse.datasource
文件 673 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DeviceServiceCapabilities.datasource
文件 649 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DiscoveryMode.datasource
文件 651 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.DNSInformation.datasource
文件 667 2018-04-23 11:35 TestOnvifClient\Connected Services\devicemgmt\TestOnvifClient.devicemgmt.Dot11AvailableNetworks.datasource
............此处省略151个文件信息
相关资源
- C# 调用win32 api函数-user32.dll详细说明
- C# 调用BarTender打印条码DEMO
- 大型比赛竞赛抽签系统 可打印 c# vs
- C#编写的Gerber查看器
- lua C# .Net4.0 vs2010 LuaInterface
- C#十六进制编辑器
- 明华URF-35H读卡器 C#读写源码 为大家
- C#文件流读取CSV文件
- c#读写PDF文件sql
- C# winform Socket大文件传输
- c#车牌识别系统附30张测试图片
- 《C#面向对象程序设计》源代码(CS)
- 金旭亮《C#面向对象程序设计》教案
- 试题库管理系统毕业论文(C#)源程序
- 学校网站原代码(C#.NET)
- C#-数据库操作技术-员工管理系统
- c#web开发入门经典
- C#与Matlab混合编程的几种方式
- c# 开发与 mysql数据库实现的增删改查
- C#异步操作 异步查询数据库 异步处理
- Basler相机通过IO触发源码
- [源代码] 《领域驱动设计 (C# 2008 实
- 松下PLC与C#通讯串口调试入门教程.z
- USB 继电器控制器 LCUS-1 保证能用 c#
- C# AES加密解密小工具
- C#圆形按钮,非常漂亮动态~~
- [精]C#仿QQ右下角弹出提示框()
- C#进程间通信-共享内存代码
- 有史以来最简单的三层(C#)
- vb调用c#编写的串口DLL文件(vb源码
评论
共有 条评论