豪蓖康相機支持onvif協(xié)議,因此可以通過該協(xié)議來獲得視頻數(shù)據(jù)以及控制相機云臺殖卑,在正式寫代碼控制之前站削,先使用onvif測試工具進行簡單的測試,保證相機相關(guān)配置正確孵稽。
1.工具下載
測試工具使用ONVIF Device Test Tool许起,具體下載地址可自行百度,一路默認安裝即可菩鲜。
2.相機配置
我使用的涸跋福康球機型號為DS-2DE2402IW-DE3/W,默認是沒有打開ONVIF協(xié)議的接校,需要我們在配置中進行配置
進入好推担康相機設置平臺,選擇配置-高級配置-勾選啟用ONVIF-添加用戶-輸入登陸用戶名和密碼-保存
以上即可完成相機ONVIF的相關(guān)配置
3.連接設備
接下來可在ONVIF Devive Test Tool測試工具中測試相機了蛛勉,打開測試軟件
首先在NIC中選擇與相機同一網(wǎng)段的網(wǎng)卡鹿寻,點擊Discover Devices,即可搜索到在該網(wǎng)段支持ONVIF協(xié)議的網(wǎng)絡相機
首先在發(fā)現(xiàn)設備列表中選擇目標相機诽凌,在右側(cè)信息中會自動填寫相機的參數(shù)毡熏,然后填寫用戶名和密碼,點擊check侣诵,即可獲得相機的Brand痢法、Model等參數(shù)狱窘,即第4點鐘的信息填寫完成,表面設備配置成功
4.視頻測試
這一步我們使用測試工具獲得相機視頻财搁,首先切換到“Debug”選項卡蘸炸,點擊“Media”,“Get” Media URL妇拯,"Get" Media Profile幻馁,選擇“main Stream(Profile_1)”,即可自動獲得Video和Audio的相關(guān)參數(shù)越锈,點擊下方Play Video即可打卡相機視頻仗嗦,如圖所示
5.PTZ測試
云臺測試方法與視頻測試方法類似,切換到PTZ選項卡--Get URLs--Get Profile--選擇main Stream--PTZ Control
在PTZ Control中用多種控制模式甘凭,分別是絕對位置控制稀拐、相對位置控制和連續(xù)控制,可自行測試看看效果
6.Requests模式
除了使用上述方法來控制云臺外丹弱,我們還可以使用Requests的方式來發(fā)送指令德撬,同時收到Response
如圖所示為PTZ測試示例,有幾個地方要注意:
- 是要把Service和Service Address修改為要測試的模塊地址
- 是注意模板中的Porfile Token要修改為自己的Profile躲胳,默認的prof0
- 是注意修改設置x y的數(shù)值
設置完成后蜓洪,點擊Send Request,當返回200 OK時表明測試成功坯苹。
同樣的隆檀,我們可以使用類似的流程來測試其它功能,比如測試Device Management模塊的GetCapabilities功能粹湃,發(fā)送及接收如圖所示
6.1 測試FindRecordings功能
您將得到一個 SearchToken 響應恐仑,這個搜索條件是唯一的。
將 SearchToken 傳遞給 GetRecordingSearchResults为鳄,您將獲得與搜索條件對應的所有曲目的列裳仆,里面有recording token
和其錄像時間
- SendRequest
<?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
原文鏈接:https://blog.csdn.net/zong596568821xp/article/details/89632354
6.2 GetRecordings
<?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>