onvif-rx icon indicating copy to clipboard operation
onvif-rx copied to clipboard

Vector2D with child elements instead of attributes

Open luchsamapparat opened this issue 2 years ago • 5 comments

Hey,

first of all, thanks for providing this library!

I was playing around with my camera (Reolink E1 Zoom) and noticed, that ContinuousMove was failing without an error, just no movement. To find out what's going wrong, I then tried node-onvif (Link) and it worked immediately.

When comparing the SOAP bodies of the two implementations, I noticed that onvif-rx defines x and y as child elements of tt:PanTilt while node-onvif uses attributes on the element itself:

<tptz:ContinuousMove><tptz:ProfileToken>000</tptz:ProfileToken><tptz:Velocity><tt:PanTilt><tt:x>1</tt:x><tt:y>0</tt:y></tt:PanTilt></tptz:Velocity><tptz:Timeout>PT1S</tptz:Timeout></tptz:ContinuousMove>

vs.

<tptz:ContinuousMove><tptz:ProfileToken>000</tptz:ProfileToken><tptz:Velocity><tt:PanTilt x="1" y="0"></tt:PanTilt></tptz:Velocity><tptz:Timeout>PT1S</tptz:Timeout></tptz:ContinuousMove>

The ONVIZ spec also requires attributes and does not mention child elements, as far as I can see:

image

http://www.onvif.org/specs/srv/ptz/ONVIF-PTZ-Service-Spec-v260.pdf (Page 41)

Is this something where other cameras are more tolerant?

luchsamapparat avatar Dec 16 '21 17:12 luchsamapparat

Did you use the latest version (v9.x.x)? I believe I helped address this issue in #46.

Mudrekh avatar Feb 15 '22 18:02 Mudrekh

Yes, ist was 9.0.1

luchsamapparat avatar Feb 15 '22 18:02 luchsamapparat

In pure JS, I use snippets like these to send a command which constructs the 'vectors' with _attributes.

const vector2D = (x, y) => ({
  _attributes: {
    x,
    y
  }
});

const vector1D = x => ({ _attributes: { x } });

onvifrx.api.PTZ.RelativeMove(token, { PanTilt: vector2D(0.1, 0.1), Zoom: vector1D(0.1)})

Can you try constructing an object like that so the library knows to interpret the properties as attributes and not sub nodes?

Mudrekh avatar Feb 15 '22 19:02 Mudrekh

@luchsamapparat Thanks for noting this issue. I didn't see it until just now. I haven't added any updates in awhile as I have been busy with other projects. I am exploring a rewrite at two levels.

  1. the core version for anyone to use in Node.js (similar in form to this library now)
  2. a new lib of a version built on top of the core library using NestJS. With extensions for running a full server to control arbitrary cameras via an exposed API.

The way this library is built is a bit of a hacky reaction to the lack of a full fledged SOAP provider in NodeJS. I could never get one working for these WSDL's. So I made a library that parses the WSDLs and attempts to build up a set of functions to interact with the cameras. I honestly do not know how well it is working for folks. I haven't tested it with many cameras.

patrickmichalina avatar Feb 16 '22 04:02 patrickmichalina

@patrickmichalina FWIW, I've tried a few different onvif modules and this one works the best and has the most support 'out of the box' for various ONVIF functions IMO. I came across the same issue in 2015 but decided I didn't have to time to write a SOAP parser like you mentioned and left the project for another day.

I've tested against Axis, Bosch, Hanwha, and Advidia cameras and had good results with each. Its more annoying that different cameras models have limitations on capabilities based on how they internally handle ONVIF functionalilty.

Mudrekh avatar Feb 17 '22 02:02 Mudrekh