ONVIF CreateOSD() 返回“配置令牌不存在”

问题描述

from onvif import ONVIFCamera

camera = ONVIFCamera(<host>,<port>,<user>,<passwd>,adjust_time=True)
camera.create_media_service()
osd = camera.media.create_type('CreateOSD')
osd.OSD = {
    'token': 'token0','Position': {
        'Type': 'UpperLeft',},'TextString': {
        'PlainText': 'TEST','Type': 'Plain','Type': 'Text','VideoSourceConfigurationToken': 'token1',}
response = camera.media.CreateOSD(osd)
print(response)

这是我的全部代码

当我调用 GetServiceCapabilities() 时,OSD 返回 True,所以我认为我的相机确实支持 OSD。

我该如何解决这个错误

解决方法

通过添加 VideoSourceConfigurationToken 解决了这个问题。

最终代码:

from onvif import ONVIFCamera

camera = ONVIFCamera(<host>,<port>,<user>,<passwd>,adjust_time=True)

camera.create_media_service()

profiles = camera.media.GetProfiles()

osd = camera.media.create_type('CreateOSD')
osd.OSD = {
    'token': 'token0','Position': {
        'Type': 'UpperLeft',},'TextString': {
        'PlainText': 'TEST','Type': 'Plain','Type': 'Text','VideoSourceConfigurationToken': profiles[0].VideoSourceConfiguration.token,}
response = camera.media.CreateOSD(osd)
print(response)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...