metadataonvifpython-onvif

How to get Metadata in python ONVIF?


1

Currently, I'm looking for metadata access functions using the in Python-onvif. I want to get the coordinates of "BoundingBox" inside the red box. How to i access data?

https://www.onvif.org/ver20/analytics/wsdl/analytics.wsdl#op.GetSupportedMetadata This function was used, but an AttributeError occurred.

from onvif import ONVIFCamera

cam = ONVIFCamera('192.168.100.133', 80, 'ID', 'P/W')
cam.create_analytics_service()

meta = cam.analytics.GetSupportedMetadata()
print(meta)

result:

Traceback (most recent call last):
  File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 97, in __getitem__
    return self._operations[key]
KeyError: 'GetSupportedMetadata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\meta_data.py", line 24, in <module>
    meta = cam.analytics.GetSupportedMetadata()
  File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\onvif\client.py", line 167, in __getattr__
    return self.service_wrapper(getattr(self.ws_client, name))
  File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 88, in __getattr__
    return self[key]
  File "C:\Users\User\anaconda3\envs\py310\lib\site-packages\zeep\proxy.py", line 99, in __getitem__
    raise AttributeError("Service has no operation %r" % key)
AttributeError: Service has no operation 'GetSupportedMetadata'

I need your help.


Solution

  • I'm not exactly using the same onvif package you are, and I'm not so sure myself how to achieve this, but this is what I've got so far:

    Both the package python-onvif, that you are using, and the Valkka inspired implementation I'm using, rely on a folder WSDL which contains pretty old versions of Onvif operations. It seems we both were using version 2.2 while the current version is 20.12.

    So what I did was to download the newer versions at their repository and replace the contents of the WSDL folder with the content of the new WSDL folder. I also had to replace how the paths were built since now there is some folder hierarchy inplace to reach the WSDL files, but after that I was able to call GetSupportedMetadata successfully.