【发布时间】:2022-08-19 23:35:11
【问题描述】:
我正在尝试通过 Python ONVIF 旋转所有 ONVIF 配置文件的视频源。我正在使用 Python 3.8.1 和 onvif_zeep library:here is the link to this library
在阅读了ONVIF homepage 上的文档后,我不清楚如何执行此操作。
我使用以下代码:
from onvif import ONVIFCamera
mycam = ONVIFCamera(Cam_ip,80,Onvif_User,Onvif_User_Pass) # the connection is done ok
media = mycam.create_media_service() # Media Service is ok
#Get The video source configurations
configurations_list = media.GetVideoSourceConfigurations() # Ok I get the Video Source configuration I wanted to select on id 0
video_source_configuration = configurations_list[0]
好的,现在我将视频源存储在 video_source_configuration 中。如果我打印它,我可以正确获取信息:
{
\'Name\': \'SOURCE_VIDEO\',
\'UseCount\': 5,
\'SourceToken\': \'0\',
\'Bounds\': {
\'x\': 0,
\'y\': 0,
\'width\': 1820,
\'height\': 720
},
\'_value_1\': None,
\'Extension\': None,
\'token\': \'0\',
\'_attr_1\': {
}
}
即使我修改例如宽度或高度,我也可以毫无问题地执行此操作
video_source_configuration.width = 640
video_source_configuration.height = 420
request = media.create_type(\'SetVideoSourceConfiguration\')
request.Configuration = video_source_configuration
request.ForcePersistence = True
media.SetVideoSourceConfiguration(request)
但我不知道如何修改Video_Source_Configuration 使其旋转90 或270 度。我已阅读函数media.GetVideoSourceConfigurationOptios() 并得到以下回复:
{
\'BoundsRange\': {
\'XRange\': {
\'Min\': 0,
\'Max\': 1280
},
\'YRange\': {
\'Min\': 0,
\'Max\': 720
},
\'WidthRange\': {
\'Min\': 0,
\'Max\': 1280
},
\'HeightRange\': {
\'Min\': 0,
\'Max\': 720
}
},
\'VideoSourceTokensAvailable\': [
\'0\'
],
\'Extension\': {
\'_value_1\': [
<Element {http://www.onvif.org/ver10/schema}Rotate at 0x243b6f4d2c0>
],
\'Rotate\': None,
\'Extension\': None
},
\'_attr_1\': None
}
我想我需要修改 Extension 字段和 Rotate 属性,但是阅读文档我不知道该怎么做。