简体   繁体   中英

ONVIF CreateOSD() returns 'Configuration Token does not exist'

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)

This is my whole code.

When I call GetServiceCapabilities(), OSD returns True so I think my camera does support OSD.

How can I fix this error?

Solved this by adding VideoSourceConfigurationToken .

Final code:

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM