我是新的IP摄像机。我用carecam应用程序从https://www.fullhan.com/en/买了一个相机品牌Goviz。如果我使用应用程序,它可以控制led灯。所以我用python来控制它。我在Vifcamera上买的。尝试使用ptz:ptz_service.SetConfiguration(conf)打开和关闭led灯时引发的错误
我从以下位置安装python onvif zeep: https://github.com/quatanium/python-onvif/tree/master/exampleshttps://github.com/FalkTannhaeuser/python-onvif-zeep
from onvif import ONVIFCamera
mycam = ONVIFCamera('192.168.1.100', 6688, 'admin', '123456')
# Get Hostname
resp = mycam.devicemgmt.GetHostname()
print('My camera`s hostname: ' + str(resp.Name)) # OK
# Create ptz service
ptz_service = mycam.create_ptz_service()
# Get ptz configuration
ptzConfigurationsList = mycam.ptz.GetConfigurations()
ptzConfiguration = ptzConfigurationsList[0]
#Turn led on:
ptzConfiguration.Extension ={
'PTControlDirection': {
'Reverse': {
'Mode': 'ON'}
}}
print(ptzConfiguration)
conf = {'PTZConfiguration': ptzConfiguration,
'ForcePersistence': False
}
ptz_service.SetConfiguration(conf)
然后是错误:
My camera`s hostname: ygtek
{
'Name': 'PTZConfiguration',
'UseCount': 2,
'NodeToken': 'NODE_000',
'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 0.5,
'y': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': {
'x': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace'
}
},
'DefaultPTZTimeout': datetime.timedelta(seconds=5),
'PanTiltLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
},
'YRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'ZoomLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'XRange': {
'Min': 0.0,
'Max': 1.0
}
}
},
'Extension': {
'PTControlDirection': {
'Reverse': {
'Mode': 'ON'
}
}
},
'token': 'PTZConfigurationToken',
'_attr_1': {
}
}
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\onvif\client.py", line 23, in wrapped
return func(*args, **kwargs)
File "C:\Python37-64\lib\site-packages\onvif\client.py", line 153, in wrapped
return call(params, callback)
File "C:\Python37-64\lib\site-packages\onvif\client.py", line 140, in call
ret = func(**params)
File "C:\Python37-64\lib\site-packages\zeep\proxy.py", line 51, in __call__
kwargs,
File "C:\Python37-64\lib\site-packages\zeep\wsdl\bindings\soap.py", line 135, in send
return self.process_reply(client, operation_obj, response)
File "C:\Python37-64\lib\site-packages\zeep\wsdl\bindings\soap.py", line 229, in process_reply
return self.process_error(doc, operation)
File "C:\Python37-64\lib\site-packages\zeep\wsdl\bindings\soap.py", line 396, in process_error
subcodes=subcodes,
zeep.exceptions.Fault: Config Not Exist
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "camera1.py", line 27, in <module>
ptz_service.SetConfiguration(conf)
File "C:\Python37-64\lib\site-packages\onvif\client.py", line 26, in wrapped
raise ONVIFError(err)
**strong text**onvif.exceptions.ONVIFError: Unknown error: Config Not Exist
我确信我遵循了http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl的规范,因此没有任何问题。我尝试了2天来找出错误,但无法找到。我猜错误来自不正确的“token”:“PTZConfigurationToken”。但是这个值来自我的相机
如果我使用:
media_service.GetProfiles()
the result is:
[{
'Name': 'PROFILE_000',
'VideoSourceConfiguration': {
'Name': 'V_SRC_000',
'UseCount': 2,
'SourceToken': 'vstoken0',
'Bounds': {
'x': 0,
'y': 0,
'width': 1920,
'height': 1080
},
'_value_1': None,
'Extension': None,
'token': 'V_SRC_000',
'_attr_1': {
}
},
'AudioSourceConfiguration': {
'Name': 'A_SRC_000',
'UseCount': 2,
'SourceToken': 'AudioSourceToken',
'_value_1': None,
'token': 'A_SRC_000',
'_attr_1': {
}
},
'VideoEncoderConfiguration': {
'Name': 'V_ENC_000',
'UseCount': 1,
'Encoding': 'H264',
'Resolution': {
'Width': 1920,
'Height': 1080
},
'Quality': 70.0,
'RateControl': {
'FrameRateLimit': 16,
'EncodingInterval': 1,
'BitrateLimit': 768
},
'MPEG4': None,
'H264': {
'GovLength': 100,
'H264Profile': 'Baseline'
},
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '239.0.1.0',
'IPv6Address': None
},
'Port': 32002,
'TTL': 2,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=10),
'_value_1': None,
'token': 'V_ENC_000',
'_attr_1': {
}
},
'AudioEncoderConfiguration': {
'Name': 'A_ENC_000',
'UseCount': 2,
'Encoding': 'G711',
'Bitrate': 64,
'SampleRate': 8,
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '239.0.1.0',
'IPv6Address': None
},
'Port': 32002,
'TTL': 2,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=10),
'_value_1': None,
'token': 'A_ENC_000',
'_attr_1': {
}
},
'VideoAnalyticsConfiguration': {
'Name': 'VideoAnalytics',
'UseCount': 2,
'AnalyticsEngineConfiguration': {
'AnalyticsModule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'Sensitivity',
'Value': '50'
}
],
'ElementItem': [
{
'_value_1': <Element {http://www.onvif.org/ver10/schema}CellLayout at 0x25861ad46c8>,
'Name': 'Layout'
}
],
'Extension': None,
'_attr_1': None
},
'Name': 'YGCellMotionModule',
'Type': 'tt:CellMotionEngine'
}
],
'Extension': None,
'_attr_1': None
},
'RuleEngineConfiguration': {
'Rule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'MinCount',
'Value': '15'
},
{
'Name': 'AlarmOnDelay',
'Value': '1000'
},
{
'Name': 'AlarmOffDelay',
'Value': '1000'
},
{
'Name': 'ActiveCells',
'Value': '0P8A8A=='
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Name': 'YGMotionDetectorRule',
'Type': 'tt:CellMotionDetector'
}
],
'Extension': None,
'_attr_1': None
},
'_value_1': None,
'token': 'VideoAnalyticsToken',
'_attr_1': {
}
},
'PTZConfiguration': {
'Name': 'PTZConfiguration',
'UseCount': 2,
'NodeToken': 'NODE_000',
'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 0.5,
'y': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': {
'x': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace'
}
},
'DefaultPTZTimeout': datetime.timedelta(seconds=5),
'PanTiltLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
},
'YRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'ZoomLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'XRange': {
'Min': 0.0,
'Max': 1.0
}
}
},
'Extension': None,
'token': 'PTZConfigurationToken',
'_attr_1': {
}
},
'MetadataConfiguration': None,
'Extension': None,
'token': 'PROFILE_000',
'fixed': True,
'_attr_1': {
}
}, {
'Name': 'PROFILE_001',
'VideoSourceConfiguration': {
'Name': 'V_SRC_000',
'UseCount': 2,
'SourceToken': 'vstoken0',
'Bounds': {
'x': 0,
'y': 0,
'width': 1920,
'height': 1080
},
'_value_1': None,
'Extension': None,
'token': 'V_SRC_000',
'_attr_1': {
}
},
'AudioSourceConfiguration': {
'Name': 'A_SRC_000',
'UseCount': 2,
'SourceToken': 'AudioSourceToken',
'_value_1': None,
'token': 'A_SRC_000',
'_attr_1': {
}
},
'VideoEncoderConfiguration': {
'Name': 'V_ENC_001',
'UseCount': 1,
'Encoding': 'H264',
'Resolution': {
'Width': 640,
'Height': 360
},
'Quality': 70.0,
'RateControl': {
'FrameRateLimit': 16,
'EncodingInterval': 1,
'BitrateLimit': 384
},
'MPEG4': None,
'H264': {
'GovLength': 100,
'H264Profile': 'Main'
},
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '239.0.1.0',
'IPv6Address': None
},
'Port': 32002,
'TTL': 2,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=10),
'_value_1': None,
'token': 'V_ENC_001',
'_attr_1': {
}
},
'AudioEncoderConfiguration': {
'Name': 'A_ENC_000',
'UseCount': 2,
'Encoding': 'G711',
'Bitrate': 64,
'SampleRate': 8,
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '239.0.1.0',
'IPv6Address': None
},
'Port': 32002,
'TTL': 2,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=10),
'_value_1': None,
'token': 'A_ENC_000',
'_attr_1': {
}
},
'VideoAnalyticsConfiguration': {
'Name': 'VideoAnalytics',
'UseCount': 2,
'AnalyticsEngineConfiguration': {
'AnalyticsModule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'Sensitivity',
'Value': '50'
}
],
'ElementItem': [
{
'_value_1': <Element {http://www.onvif.org/ver10/schema}CellLayout at 0x25861b016c8>,
'Name': 'Layout'
}
],
'Extension': None,
'_attr_1': None
},
'Name': 'YGCellMotionModule',
'Type': 'tt:CellMotionEngine'
}
],
'Extension': None,
'_attr_1': None
},
'RuleEngineConfiguration': {
'Rule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'MinCount',
'Value': '15'
},
{
'Name': 'AlarmOnDelay',
'Value': '1000'
},
{
'Name': 'AlarmOffDelay',
'Value': '1000'
},
{
'Name': 'ActiveCells',
'Value': '0P8A8A=='
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Name': 'YGMotionDetectorRule',
'Type': 'tt:CellMotionDetector'
}
],
'Extension': None,
'_attr_1': None
},
'_value_1': None,
'token': 'VideoAnalyticsToken',
'_attr_1': {
}
},
'PTZConfiguration': {
'Name': 'PTZConfiguration',
'UseCount': 2,
'NodeToken': 'NODE_000',
'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 0.5,
'y': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': {
'x': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace'
}
},
'DefaultPTZTimeout': datetime.timedelta(seconds=5),
'PanTiltLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
},
'YRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'ZoomLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'XRange': {
'Min': 0.0,
'Max': 1.0
}
}
},
'Extension': None,
'token': 'PTZConfigurationToken',
'_attr_1': {
}
},
'MetadataConfiguration': None,
'Extension': None,
'token': 'PROFILE_001',
'fixed': True,
'_attr_1': {
}
}]
因此,在两个配置文件PROFILE_000和PROFILE_001中有两个“token”:“PTZConfigurationToken”。所以我猜选择代币会有系统混乱
但我不能确定它是否正确以及如何修复。 请帮忙。我非常感激
这是IP摄像头的响应:
oc = b'
<?xml version=\'1.0\' encoding=\'utf-8\'?>\n
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:e="http://www.w3.org/2003/05/soap-encoding"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2"
xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http"
xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
xmlns:tst="http://www.onvif.org/ver10/storage/wsdl"
xmlns:dn="http://www.onvif.org/ver10/network/wsdl"
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"
xmlns:axt="http://www.onvif.org/ver20/analytics"
xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
xmlns:ter="http://www.onvif.org/ver10/error">
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value>ter:InvalidArgVal</s:Value>
<s:Subcode>
<s:Value>ter:NoConfig</s:Value>
</s:Subcode>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en">Config Not Exist</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>'
上面写着:ter:InvalidArgVal,但是所有的值都来自IP摄像头,所以它必须是正确的。这一定是疯了。请帮忙
目前没有回答
相关问题 更多 >
编程相关推荐