首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自onvif的方法产生"AnySimpleType.pytonvalue() not implemented“

来自onvif的方法产生"AnySimpleType.pytonvalue() not implemented“
EN

Stack Overflow用户
提问于 2020-11-16 18:14:32
回答 1查看 127关注 0票数 1

当我试图从我的IP摄像头获取ONVIF格式的实况流时,我使用了streaming.py (https://github.com/FalkTannhaeuser/python-onvif-zeep)。

不幸的是,我得到的错误是"AnySimpleType.pytonvalue()没有实现“。我还可以通过使用以下命令获得最新的zeep实现

代码语言:javascript
复制
pip install --upgrade onvif_zeep

我不知道为什么示例代码中的方法没有实现。下面是完整的代码:

代码语言:javascript
复制
    from onvif import ONVIFCamera

def media_profile_configuration():
    '''
    A media profile consists of configuration entities such as video/audio
    source configuration, video/audio encoder configuration,
    or PTZ configuration. This use case describes how to change one
    configuration entity which has been already added to the media profile.
    '''

    # Create the media service
    mycam = ONVIFCamera('****', ****, '****', '****')
    media_service = mycam.create_media_service()

    profiles = media_service.GetProfiles()

    # Use the first profile and Profiles have at least one
    token = profiles[0]._token

    # Get all video encoder configurations
    configurations_list = media_service.GetVideoEncoderConfigurations()

    # Use the first profile and Profiles have at least one
    video_encoder_configuration = configurations_list[0]

    # Get video encoder configuration options
    options = media_service.GetVideoEncoderConfigurationOptions({'ProfileToken':token})

    # Setup stream configuration
    video_encoder_configuration.Encoding = 'H264'
    # Setup Resolution
    video_encoder_configuration.Resolution.Width = \
                    options.H264.ResolutionsAvailable[0].Width
    video_encoder_configuration.Resolution.Height = \
                    options.H264.ResolutionsAvailable[0].Height
    # Setup Quality
    video_encoder_configuration.Quality = options.QualityRange.Min
    # Setup FramRate
    video_encoder_configuration.RateControl.FrameRateLimit = \
                                    options.H264.FrameRateRange.Min
    # Setup EncodingInterval
    video_encoder_configuration.RateControl.EncodingInterval = \
                                    options.H264.EncodingIntervalRange.Min
    # Setup Bitrate
    video_encoder_configuration.RateControl.BitrateLimit = \
                            options.Extension.H264[0].BitrateRange[0].Min[0]

    # Create request type instance
    request = media_service.create_type('SetVideoEncoderConfiguration')
    request.Configuration = video_encoder_configuration
    # ForcePersistence is obsolete and should always be assumed to be True
    request.ForcePersistence = True

    # Set the video encoder configuration
    media_service.SetVideoEncoderConfiguration(request)

if __name__ == '__main__':
    media_profile_configuration()

有人知道为什么我不能访问配置摄像头的方法吗?

EN

回答 1

Stack Overflow用户

发布于 2021-04-01 12:21:21

基于OP对他的问题的评论,以及试验和错误,我设法修复了这个错误。

在您的.py中,添加以下代码:

代码语言:javascript
复制
import zeep

def zeep_pythonvalue(self,xmlvalue):
    return xmlvalue

zeep.xsd.AnySimpleType.pythonvalue = zeep_pythonvalue
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64856135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档