onvif ptz 处理

简单记录下onvif 如何集成ptz 进行控制

参考代码

const onvif = require('node-onvif');
// Create an OnvifDevice object
let device = new onvif.OnvifDevice({
 xaddr: 'http://xxxxxxxxx/onvif/device_service',
  user : 'xxxxx',
  pass : 'xxxxxxx'
});
 
// Initialize the OnvifDevice object
device.init().then(() => {
  // Move the camera
  return device.ptzMove({
    'speed': {
      x: 1.0, // Speed of pan (in the range of -1.0 to 1.0)
      y: 0.0, // Speed of tilt (in the range of -1.0 to 1.0)
      z: 0.0 // Speed of zoom (in the range of -1.0 to 1.0)
    },
    'timeout': 1 // seconds
  });
}).then(() => {
  console.log('Done!');
}).catch((error) => {
  console.error(error);
});

说明

当前支持onvif 协议的包不少都比较老,但是基本够用,同时部分可能因为一些服务升级问题,造成并不能使用了,注意取舍以及修改(比如海康onvif 处理snaoshot的)

参考资料

https://www.npmjs.com/package/node-onvif

https://github.com/GuilhermeC18/node-onvif

https://www.onvif.org/ch/

https://github.com/onvif/specs/

posted on 2025-10-26 08:00  荣锋亮  阅读(8)  评论(0)    收藏  举报

导航