看一看這個API文檔:http://www.camarasip.es/descarga/IP_Camera_CGI_(SDK).pdf
嘗試一下在你的選擇,例如的瀏覽器與:
http://XXX.XXX.XXX.XXX:XX/cgi-bin/CGIProxy.fcgi?usr=YOURUSER&pwd=YOURPASS&cmd=snapPicture2
這將返回在您的瀏覽器中的相機JPG快照。也可以使用PTZ控制,例如,
http://XXX.XXX.XXX.XXX:XX/cgi-bin/CGIProxy.fcgi?usr=YOURUSER&pwd=YOURPASS&cmd=ptzMoveUp
如果成功的話,你應該看到的相機移動,你應該得到的迴應是這樣的:
<CGI_Result>
<result>0</result>
</CGI_Result>
下一步,這種直接HTTP接口的R2顯然也內置了ONVIF支持。有一個node.js模塊(https://github.com/futomi/node-onvif),我已經可以使用它來連接以獲取一些相機信息,並且我已經能夠使用它來進行一些PTZ控制,但是如果它仍然認爲不會退出。
到目前爲止,我最大的障礙是我找不到任何東西,只能將RTSP視頻流集成到網頁中。以前的Foscam相機,例如8910W具有這種能力。
這裏是ONVIF的代碼,對我來說,到目前爲止的工作:
onvif.startDiscovery(function(info) {
// Show the device name and the URL of the end point
console.log('\n********* Retrieved Discovery Info ***********');
console.log(JSON.stringify(info, null, ' '));
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: info.xaddrs[0],
user: 'YOURUSER',
pass: 'YOURPASS'
});
// Initialize the OnvifDevice object
device.init(function(error) {
if (error) {
console.log('[ERROR] ' + error.message);
} else {
// Get the detailed device information
var device_info = device.getInformation();
// Show the result
console.log('\n********* Retrieved Discovery Info ***********');
console.log(JSON.stringify(device_info, null, ' '));
var url = device.getUdpStreamUrl();
console.log('UDP Stream URL: ' + url);
var profile_list = device.getProfileList();
for (var i = 0; i < profile_list.length; i++) {
console.log('\n********* Retrieved Profile ***********');
console.log(profile_list[i]);
console.log('\nPTZ:');
console.log(profile_list[i].ptz);
}
// The OnvifServicePtz object
var ptz = device.services.ptz;
if (ptz) {
console.log('Current Token: ' + device.getCurrentProfile()['token']);
var params = {
'ProfileToken': device.getCurrentProfile()['token'],
'Position': {
x: .5,
y: 0,
z: 0
},
'Timeout': 1
};
ptz.absoluteMove(params, function(error, result) {
{
if (error) {
console.log('[ERROR] ' + error.message);
} else {
console.log(JSON.stringify(result.data, null, ' '));
}
});
} else {
console.log('[ERROR] Your ONVIF network camera does not support the PTZ service.');
}
}
});
});
嗨,它工作? – Delta