onvif device test tool使用

海康相机支持onvif协议,因此可以通过该协议来获得视频数据以及控制相机云台,在正式写代码控制之前,先使用onvif测试工具进行简单的测试,保证相机相关配置正确。

1.工具下载

测试工具使用ONVIF Device Test Tool,具体下载地址可自行百度,一路默认安装即可。

2.相机配置

我使用的海康球机型号为DS-2DE2402IW-DE3/W,默认是没有打开ONVIF协议的,需要我们在配置中进行配置

image.png

进入海康相机设置平台,选择配置-高级配置-勾选启用ONVIF-添加用户-输入登陆用户名和密码-保存

以上即可完成相机ONVIF的相关配置

3.连接设备

接下来可在ONVIF Devive Test Tool测试工具中测试相机了,打开测试软件

image.png

首先在NIC中选择与相机同一网段的网卡,点击Discover Devices,即可搜索到在该网段支持ONVIF协议的网络相机

image.png

首先在发现设备列表中选择目标相机,在右侧信息中会自动填写相机的参数,然后填写用户名和密码,点击check,即可获得相机的Brand、Model等参数,即第4点钟的信息填写完成,表面设备配置成功

4.视频测试

这一步我们使用测试工具获得相机视频,首先切换到“Debug”选项卡,点击“Media”,“Get” Media URL,"Get" Media Profile,选择“main Stream(Profile_1)”,即可自动获得Video和Audio的相关参数,点击下方Play Video即可打卡相机视频,如图所示

image.png

5.PTZ测试

云台测试方法与视频测试方法类似,切换到PTZ选项卡--Get URLs--Get Profile--选择main Stream--PTZ Control

在PTZ Control中用多种控制模式,分别是绝对位置控制、相对位置控制和连续控制,可自行测试看看效果

image.png

6.Requests模式

除了使用上述方法来控制云台外,我们还可以使用Requests的方式来发送指令,同时收到Response

image.png

如图所示为PTZ测试示例,有几个地方要注意:

  1. 是要把Service和Service Address修改为要测试的模块地址
  2. 是注意模板中的Porfile Token要修改为自己的Profile,默认的prof0
  3. 是注意修改设置x y的数值

设置完成后,点击Send Request,当返回200 OK时表明测试成功。

同样的,我们可以使用类似的流程来测试其它功能,比如测试Device Management模块的GetCapabilities功能,发送及接收如图所示

image.png

6.1 测试FindRecordings功能

image.png

您将得到一个 SearchToken 响应,这个搜索条件是唯一的。

将 SearchToken 传递给 GetRecordingSearchResults,您将获得与搜索条件对应的所有曲目的列,里面有recording token和其录像时间

  • SendRequest
image.png
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
  <soap:Body>
    <tse:GetRecordingSearchResults>
      <tse:SearchToken>search_session_481642959_0xb6666f28</tse:SearchToken>
    </tse:GetRecordingSearchResults>
  </soap:Body>
</soap:Envelope>
  • Response
HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 3648
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime4="http://www.w3.org/2004/11/xmlmime" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:tes-e="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tes-nc="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:tes-np="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:tes-sm="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:xmime="http://www.w3.org/2004/06/xmlmime" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tan-ae="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan-re="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:tpl="http://www.onvif.org/ver10/plus/wsdl" xmlns:tplt="http://www.onvif.org/ver10/plus/schema" xmlns:ns1="GenetecPtzPatterns">
  <SOAP-ENV:Body>
    <tse:GetRecordingSearchResultsResponse>
      <tse:ResultList>
        <tt:SearchState>Searching</tt:SearchState>
        <tt:RecordingInformation>
          <tt:RecordingToken>Record_001</tt:RecordingToken>
          <tt:Source>
            <tt:SourceId>00100 channel of device</tt:SourceId>
            <tt:Name>00100 channel</tt:Name>
            <tt:Location>local Camera</tt:Location>
            <tt:Description>recording of 00100 channel</tt:Description>
            <tt:Address>recording adress of 00100 channel</tt:Address>
          </tt:Source>
          <tt:EarliestRecording>2021-07-18T19:11:50Z</tt:EarliestRecording>n //录像时间
          <tt:LatestRecording>2021-07-19T07:11:37Z</tt:LatestRecording>
          <tt:Content>recording of 00100 channel Camera</tt:Content>
          <tt:Track>
            <tt:TrackToken>VIDEO001</tt:TrackToken>
            <tt:TrackType>Video</tt:TrackType>
            <tt:Description>VIDEO TRACK</tt:Description>
            <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
            <tt:DataTo>2021-07-19T07:11:37Z</tt:DataTo>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>AUDIO001</tt:TrackToken>
            <tt:TrackType>Audio</tt:TrackType>
            <tt:Description>AUDIO TRACK</tt:Description>
            <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
            <tt:DataTo>2021-07-19T07:11:37Z</tt:DataTo>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>META001</tt:TrackToken>
            <tt:TrackType>Metadata</tt:TrackType>
            <tt:Description>METADATA TRACK</tt:Description>
            <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
            <tt:DataTo>2021-07-19T07:11:37Z</tt:DataTo>
          </tt:Track>
          <tt:RecordingStatus>Stopped</tt:RecordingStatus>
        </tt:RecordingInformation>
      </tse:ResultList>
    </tse:GetRecordingSearchResultsResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

GetRecordingInformation接口:将Record_001填入,可以获取信息

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
  <soap:Body>
    <tse:GetRecordingInformation>
      <tse:RecordingToken>Record_001</tse:RecordingToken>
    </tse:GetRecordingInformation>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 3571
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime4="http://www.w3.org/2004/11/xmlmime" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:tes-e="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tes-nc="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:tes-np="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:tes-sm="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:xmime="http://www.w3.org/2004/06/xmlmime" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tan-ae="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan-re="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:tpl="http://www.onvif.org/ver10/plus/wsdl" xmlns:tplt="http://www.onvif.org/ver10/plus/schema" xmlns:ns1="GenetecPtzPatterns">
  <SOAP-ENV:Body>
    <tse:GetRecordingInformationResponse>
      <tse:RecordingInformation>
        <tt:RecordingToken>Record_001</tt:RecordingToken>
        <tt:Source>
          <tt:SourceId>00100 channel of device</tt:SourceId>
          <tt:Name>00100 channel</tt:Name>
          <tt:Location>local Camera</tt:Location>
          <tt:Description>recording of 00100 channel</tt:Description>
          <tt:Address>recording adress of 00100 channel</tt:Address>
        </tt:Source>
        <tt:EarliestRecording>2021-07-18T19:11:50Z</tt:EarliestRecording>
        <tt:LatestRecording>2021-07-19T08:05:01Z</tt:LatestRecording>
        <tt:Content>recording of 00100 channel Camera</tt:Content>
        <tt:Track>
          <tt:TrackToken>VIDEO001</tt:TrackToken>
          <tt:TrackType>Video</tt:TrackType>
          <tt:Description>VIDEO TRACK</tt:Description>
          <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
          <tt:DataTo>2021-07-19T08:05:01Z</tt:DataTo>
        </tt:Track>
        <tt:Track>
          <tt:TrackToken>AUDIO001</tt:TrackToken>
          <tt:TrackType>Audio</tt:TrackType>
          <tt:Description>AUDIO TRACK</tt:Description>
          <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
          <tt:DataTo>2021-07-19T08:05:01Z</tt:DataTo>
        </tt:Track>
        <tt:Track>
          <tt:TrackToken>META001</tt:TrackToken>
          <tt:TrackType>Metadata</tt:TrackType>
          <tt:Description>METADATA TRACK</tt:Description>
          <tt:DataFrom>2021-07-18T19:11:50Z</tt:DataFrom>
          <tt:DataTo>2021-07-19T08:05:01Z</tt:DataTo>
        </tt:Track>
        <tt:RecordingStatus>Stopped</tt:RecordingStatus>
      </tse:RecordingInformation>
    </tse:GetRecordingInformationResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
  • GetReplayUri


    image.png

原文链接:https://blog.csdn.net/zong596568821xp/article/details/89632354

6.2 GetRecordings

image.png
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
  <soap:Body>
    <trc:GetRecordings />
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/soap+xml
Content-Length: 3800

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:trec="http://www.onvif.org/ver10/recording/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
  <soap:Body>
    <trec:GetRecordingsResponse>
      <trec:RecordingItem>
        <tt:RecordingToken>RecordingToken001</tt:RecordingToken>
        <tt:Configuration>
          <tt:Source>
            <tt:SourceId>SourceId_1</tt:SourceId>
            <tt:Name>IPCamera33</tt:Name>
            <tt:Location>Location</tt:Location>
            <tt:Description>Description of source</tt:Description>
            <tt:Address>http://www.onvif.org/ver10/schema/Profile</tt:Address>
          </tt:Source>
          <tt:Content>RecordContent</tt:Content>
          <tt:MaximumRetentionTime>PT0S</tt:MaximumRetentionTime>
        </tt:Configuration>
        <tt:Tracks>
          <tt:Track>
            <tt:TrackToken>VIDEO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Video</tt:TrackType>
              <tt:Description>VideoTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>AUDIO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Audio</tt:TrackType>
              <tt:Description>AudioTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
        </tt:Tracks>
      </trec:RecordingItem>
      <trec:RecordingItem>
        <tt:RecordingToken>RecordingToken003</tt:RecordingToken>
        <tt:Configuration>
          <tt:Source>
            <tt:SourceId>SourceId_3</tt:SourceId>
            <tt:Name>IPCamera35</tt:Name>
            <tt:Location>Location</tt:Location>
            <tt:Description>Description of source</tt:Description>
            <tt:Address>http://www.onvif.org/ver10/schema/Profile</tt:Address>
          </tt:Source>
          <tt:Content>RecordContent</tt:Content>
          <tt:MaximumRetentionTime>PT0S</tt:MaximumRetentionTime>
        </tt:Configuration>
        <tt:Tracks>
          <tt:Track>
            <tt:TrackToken>VIDEO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Video</tt:TrackType>
              <tt:Description>VideoTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>AUDIO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Audio</tt:TrackType>
              <tt:Description>AudioTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
        </tt:Tracks>
      </trec:RecordingItem>
      <trec:RecordingItem>
        <tt:RecordingToken>RecordingToken004</tt:RecordingToken>
        <tt:Configuration>
          <tt:Source>
            <tt:SourceId>SourceId_4</tt:SourceId>
            <tt:Name>IPCamera36</tt:Name>
            <tt:Location>Location</tt:Location>
            <tt:Description>Description of source</tt:Description>
            <tt:Address>http://www.onvif.org/ver10/schema/Profile</tt:Address>
          </tt:Source>
          <tt:Content>RecordContent</tt:Content>
          <tt:MaximumRetentionTime>PT0S</tt:MaximumRetentionTime>
        </tt:Configuration>
        <tt:Tracks>
          <tt:Track>
            <tt:TrackToken>VIDEO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Video</tt:TrackType>
              <tt:Description>VideoTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>AUDIO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Audio</tt:TrackType>
              <tt:Description>AudioTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
        </tt:Tracks>
      </trec:RecordingItem>
      <trec:RecordingItem>
        <tt:RecordingToken>RecordingToken006</tt:RecordingToken>
        <tt:Configuration>
          <tt:Source>
            <tt:SourceId>SourceId_6</tt:SourceId>
            <tt:Name>IPCamera38</tt:Name>
            <tt:Location>Location</tt:Location>
            <tt:Description>Description of source</tt:Description>
            <tt:Address>http://www.onvif.org/ver10/schema/Profile</tt:Address>
          </tt:Source>
          <tt:Content>RecordContent</tt:Content>
          <tt:MaximumRetentionTime>PT0S</tt:MaximumRetentionTime>
        </tt:Configuration>
        <tt:Tracks>
          <tt:Track>
            <tt:TrackToken>VIDEO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Video</tt:TrackType>
              <tt:Description>VideoTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
          <tt:Track>
            <tt:TrackToken>AUDIO001</tt:TrackToken>
            <tt:Configuration>
              <tt:TrackType>Audio</tt:TrackType>
              <tt:Description>AudioTrack</tt:Description>
            </tt:Configuration>
          </tt:Track>
        </tt:Tracks>
      </trec:RecordingItem>
    </trec:GetRecordingsResponse>
  </soap:Body>
</soap:Envelope>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容