资源简介
本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# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论