Python ONVIF GotoPreset 设置全局移动速度失败

Python ONVIF GotoPreset failed to set global movment Speed

我正在尝试以定义明确的速度设置名为“Preset001”的点,但我做不到,因为我在控制台上收到以下错误:

My camera's hostname: MYCAM
gotoPreset:
{
    'ProfileToken': 'MainStreamProfileToken',
    'PresetToken': 'Preset001',
    'Speed': 0.1
}
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 140, in call
    ret = func(**params)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 123, in send
    envelope, http_headers = self._create(
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 73, in _create
    serialized = operation_obj.create(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/definitions.py", line 222, in create
    return self.input.serialize(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/messages/soap.py", line 79, in serialize
    self.body.render(body, body_value)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
    self._render_value_item(parent, value, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
    element.render(node, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
    element.render(parent, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
    self._render_value_item(parent, value, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
    element.render(node, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
    element.render(parent, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
    self._render_value_item(parent, value, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 266, in render
    attr_value = value[name] if name in value else NotSet
TypeError: argument of type 'float' is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 23, in wrapped
    return func(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 153, in wrapped
    return call(params, callback)
  File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 143, in call
    ret = func(params)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 123, in send
    envelope, http_headers = self._create(
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 73, in _create
    serialized = operation_obj.create(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/definitions.py", line 222, in create
    return self.input.serialize(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/messages/soap.py", line 79, in serialize
    self.body.render(body, body_value)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
    self._render_value_item(parent, value, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
    element.render(node, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
    element.render(parent, element_value, child_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
    self._render_value_item(parent, value, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/simple.py", line 96, in render
    node.text = self.xmlvalue(value)
  File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/builtins.py", line 27, in _wrapper
    raise ValueError(
ValueError: The ReferenceToken type doesn't accept collections as value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Script/onvif_test.py", line 35, in <module>
    print(ptz.GotoPreset(request))
  File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 26, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: The ReferenceToken type doesn't accept collections as value

这是执行预设命令的脚本(不设置速度,这个命令完美运行):

#!/usr/bin/python3

from functions import *


from onvif import ONVIFCamera

mycam = ONVIFCamera('xxx.xxx.xxx.xxx', 8080, 'admin', 'password', '/home/pi/.local/lib/python3.4/site-packages/wsdl/')

# Get Hostname
resp = mycam.devicemgmt.GetHostname()
print("My camera's hostname: " + str(resp.Name))

# Create media service object
media = mycam.create_media_service()

# Get target profile
media_profile = media.GetProfiles()[0]
#print(media_profile)

# Create ptz service object
ptz = mycam.create_ptz_service()

request = ptz.create_type('GotoPreset')

request.ProfileToken = media_profile.token

request.PresetToken = "Preset001"

request.Speed = 0.1

print("gotoPreset:")
print(request)

print(ptz.GotoPreset(request))

我在 RaspberryPi 4 上使用以下“ONVIF Python LIbrary”。

感谢任何人!

我找到了解决办法。正确的数据传递方式是:

request.Speed = {'PanTilt': {'x': 0.1, 'y': 0.1}, 'Zoom': 0.1} # The camera seems to ignore the PanTilt and Zoom speeds I give it

即使不幸的是我的 ptz 没有达到我告诉他去的速度 cge .. 所以这东西没用 .. : '(

谢谢大家