看一看这个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