diff --git a/examples/thermal_example.py b/examples/thermal_example.py new file mode 100644 index 0000000..07dc4ed --- /dev/null +++ b/examples/thermal_example.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 +""" +Example script demonstrating ONVIF Thermal Service usage. + +This script shows how to: +1. Connect to an ONVIF camera +2. Create a thermal service +3. Get thermal service capabilities +4. Get thermal configuration options +5. Get and set thermal configuration +6. Get and set radiometry configuration + +Usage: + python thermal_example.py + +Example: + python thermal_example.py 192.168.1.100 80 admin password123 +""" + +import sys +import os + +# Add the parent directory to the path so we can import the onvif module +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from onvif import ONVIFCamera + + +def main(): + if len(sys.argv) != 5: + print("Usage: python thermal_example.py ") + sys.exit(1) + + host = sys.argv[1] + port = int(sys.argv[2]) + username = sys.argv[3] + password = sys.argv[4] + + try: + # Create ONVIF camera instance + print(f"Connecting to camera at {host}:{port}...") + cam = ONVIFCamera(host, port, username, password) + + # Create thermal service + print("Creating thermal service...") + thermal_service = cam.create_thermal_service() + + # Get thermal service capabilities + print("\n=== Thermal Service Capabilities ===") + try: + capabilities = thermal_service.GetServiceCapabilities() + print(f"Radiometry supported: {capabilities.Capabilities.Radiometry}") + except Exception as e: + print(f"Error getting capabilities: {e}") + + # Get thermal configuration options + print("\n=== Thermal Configuration Options ===") + try: + # You'll need to get a video source token first + # This is just an example - you might need to get this from media service + video_source_token = "your_video_source_token_here" # Replace with actual token + + config_options = thermal_service.GetConfigurationOptions({ + 'VideoSourceToken': video_source_token + }) + print("Configuration options retrieved successfully") + print(f"Available color palettes: {len(config_options.ConfigurationOptions.ColorPalette)}") + + if hasattr(config_options.ConfigurationOptions, 'NUCTable'): + print(f"Available NUC tables: {len(config_options.ConfigurationOptions.NUCTable)}") + + if hasattr(config_options.ConfigurationOptions, 'CoolerOptions'): + print("Cooler options available") + + except Exception as e: + print(f"Error getting configuration options: {e}") + + # Get thermal configuration + print("\n=== Current Thermal Configuration ===") + try: + config = thermal_service.GetConfiguration({ + 'VideoSourceToken': video_source_token + }) + print("Current thermal configuration retrieved successfully") + print(f"Color palette: {config.Configuration.ColorPalette.Name}") + print(f"Polarity: {config.Configuration.Polarity}") + + except Exception as e: + print(f"Error getting configuration: {e}") + + # Get radiometry configuration options + print("\n=== Radiometry Configuration Options ===") + try: + radiometry_options = thermal_service.GetRadiometryConfigurationOptions({ + 'VideoSourceToken': video_source_token + }) + print("Radiometry configuration options retrieved successfully") + + except Exception as e: + print(f"Error getting radiometry options: {e}") + + # Get radiometry configuration + print("\n=== Current Radiometry Configuration ===") + try: + radiometry_config = thermal_service.GetRadiometryConfiguration({ + 'VideoSourceToken': video_source_token + }) + print("Current radiometry configuration retrieved successfully") + + except Exception as e: + print(f"Error getting radiometry configuration: {e}") + + print("\n=== Example completed ===") + print("Note: Some operations may fail if the camera doesn't support thermal features") + print("or if the video source token is not valid.") + + except Exception as e: + print(f"Error: {e}") + sys.exit(1) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/onvif/client.py b/onvif/client.py index 97c91cd..06a06d4 100644 --- a/onvif/client.py +++ b/onvif/client.py @@ -105,6 +105,7 @@ def __init__(self, xaddr, user, passwd, url, self.zeep_client.set_ns_prefix('tptz', 'http://www.onvif.org/ver20/ptz/wsdl') self.zeep_client.set_ns_prefix('ttr', 'http://www.onvif.org/ver10/media/wsdl') self.zeep_client.set_ns_prefix('ter', 'http://www.onvif.org/ver10/error') + self.zeep_client.set_ns_prefix('tth', 'http://www.onvif.org/ver10/thermal/wsdl') else: self.zeep_client = zeep_client self.ws_client = self.zeep_client.create_service(binding_name, self.xaddr) @@ -192,9 +193,9 @@ class ONVIFCamera(object): # Class-level variables services_template = {'devicemgmt': None, 'ptz': None, 'media': None, - 'imaging': None, 'events': None, 'analytics': None} + 'imaging': None, 'events': None, 'analytics': None, 'thermal': None} use_services_template = {'devicemgmt': True, 'ptz': True, 'media': True, - 'imaging': True, 'events': True, 'analytics': True} + 'imaging': True, 'events': True, 'analytics': True, 'thermal': True} def __init__(self, host, port, user, passwd, wsdl_dir=os.path.join(os.path.dirname(__file__), @@ -403,3 +404,6 @@ def create_notification_service(self, transport=None): def create_subscription_service(self, transport=None): return self.create_onvif_service('subscription', transport=transport) + + def create_thermal_service(self, transport=None): + return self.create_onvif_service('thermal', transport=transport) \ No newline at end of file diff --git a/onvif/definition.py b/onvif/definition.py index 24acbd3..fff98e7 100644 --- a/onvif/definition.py +++ b/onvif/definition.py @@ -8,6 +8,7 @@ 'events' : {'ns': 'http://www.onvif.org/ver10/events/wsdl', 'wsdl': 'events.wsdl', 'binding' : 'EventBinding'}, 'pullpoint' : {'ns': 'http://www.onvif.org/ver10/events/wsdl', 'wsdl': 'events.wsdl', 'binding' : 'PullPointSubscriptionBinding'}, 'notification' : {'ns': 'http://www.onvif.org/ver10/events/wsdl', 'wsdl': 'events.wsdl', 'binding' : 'NotificationProducerBinding'}, + 'thermal' : {'ns': 'http://www.onvif.org/ver10/thermal/wsdl', 'wsdl': 'thermal.wsdl', 'binding' : 'ThermalBinding'}, 'subscription' : {'ns': 'http://www.onvif.org/ver10/events/wsdl', 'wsdl': 'events.wsdl', 'binding' : 'SubscriptionManagerBinding'}, 'analytics' : {'ns': 'http://www.onvif.org/ver20/analytics/wsdl', 'wsdl': 'analytics.wsdl', 'binding' : 'AnalyticsEngineBinding'}, 'recording' : {'ns': 'http://www.onvif.org/ver10/recording/wsdl', 'wsdl': 'recording.wsdl', 'binding' : 'RecordingBinding'}, diff --git a/onvif/wsdl/thermal.wsdl b/onvif/wsdl/thermal.wsdl new file mode 100644 index 0000000..6626e0e --- /dev/null +++ b/onvif/wsdl/thermal.wsdl @@ -0,0 +1,777 @@ + + + + + + + + + + + + + + + + + + + Describes standard Color Palette types, used to facilitate Multi-language support and client display. + "Custom" Type shall be used when Color Palette Name does not match any of the types included in the standard classification. + + + + + + + + + + + + + + + + + + + Describes a Color Palette element. + + + + + + User readable Color Palette name. + + + + + + + + Unique identifier of this Color Palette. + + + + + Indicates Color Palette Type. Use tth:ColorPaletteType. + Used for multi-language support and display. + + + + + + + + Type describing a NUC Table element. + + + + + + User reabable name for the Non-Uniformity Correction (NUC) Table. + + + + + + + + Unique identifier of this NUC Table. + + + + + Low Temperature limit for application of NUC Table, in Kelvin. + + + + + High Temperature limit for application of NUC Table, in Kelvin. + + + + + + + + Type describing the Cooler settings. + + + + + + Indicates whether the Cooler is enabled (running) or not. + + + + + + + Number of hours the Cooler has been running (unit: hours). Read-only. + + + + + + + + + + Describes valid ranges for the thermal device cooler settings. + Only applicable to cooled thermal devices. + + + + + + Indicates the Device allows cooler status to be changed from running (Enabled) to stopped (Disabled), and viceversa. + + + + + + + + + + + + Holds default values that will be used in measurement modules when local parameters are not specified for the module (these are still required for valid temperature calculations). + Having ReflectedAmbientTemperature, Emissivity and DistanceToObject as mandatory ensures minimum parameters are available to obtain valid temperature values. + + + + + + + Reflected Ambient Temperature for the environment in which the thermal device and the object being measured is located. + + + + + + + Emissivity of the surface of the object on which temperature is being measured. + + + + + + + Distance from the thermal device to the measured object. + + + + + + + Relative Humidity in the environment in which the measurement is located. + + + + + + + Temperature of the atmosphere between the thermal device and the object being measured. + + + + + + + Transmittance value for the atmosphere between the thermal device and the object being measured. + + + + + + + Temperature of the optics elements between the thermal device and the object being measured. + + + + + + + Transmittance value for the optics elements between the thermal device and the object being measured. + + + + + + + + + + + + Describes valid ranges for the different radiometry parameters required for accurate temperature calculation. + + + + + + Valid range of temperature values, in Kelvin. + + + + + Valid range of emissivity values for the objects to measure. + + + + + Valid range of distance between camera and object for a valid temperature reading, in meters. + + + + + Valid range of relative humidity values, in percentage. + + + + + Valid range of temperature values, in Kelvin. + + + + + Valid range of atmospheric transmittance values. + + + + + Valid range of temperature values, in Kelvin. + + + + + Valid range of external optics transmittance. + + + + + + + + + + + + + + + Current Color Palette in use by the Thermal Device. + + + + + + + Polarity configuration of the Thermal Device. + + + + + + + Current Non-Uniformity Correction (NUC) Table in use by the Thermal Device. + + + + + + + Cooler settings of the Thermal Device. + + + + + + + + + + + + + + + + Current Thermal Settings for the VideoSource. + + + + + + + + + Reference token to the thermal VideoSource. + + + + + + + + + + + + + + Global Parameters for Radiometry Measurements. Shall exist if Radiometry Capability is reported, + and Global Parameters are supported by the device. + + + + + + + + + + + + + + + + List of Color Palettes available for the requested Thermal VideoSource. + + + + + + + List of Non-Uniformity Correction (NUC) Tables available for the requested Thermal VideoSource. + + + + + + + Specifies Cooler Options for cooled thermal devices. + + + + + + + + + + + + + + + Specifies valid ranges and options for the global radiometry parameters used as default parameter values + for temperature measurement modules (spots and boxes). + + + + + + + + + + + + + + + + + + + + The capabilities of the thermal service are returned in the Capabilities element. + + + + + + + + + + + + + Indicates whether or not radiometric thermal measurements are supported by the thermal device. + + + + + + + + + + + + + Reference token to the VideoSource for which the Thermal Configuration Options are requested. + + + + + + + + + + + + + + Valid ranges for the Thermal configuration parameters that are categorized as device specific. + + + + + + + + + + + + + + Reference token to the VideoSource for which the Thermal Settings are requested. + + + + + + + + + + + + + Thermal Settings for the VideoSource that was requested. + + + + + + + + + + + + + + + + + + + + + This element contains a list of thermal VideoSource configurations. + + + + + + + + + + + + + + + Reference token to the VideoSource for which the Thermal Settings are configured. + + + + + + + Thermal Settings to be configured. + + + + + + + + + + + + + + + + + + Reference token to the VideoSource for which the Thermal Radiometry Options are requested. + + + + + + + + + + + + + Valid ranges for the Thermal Radiometry parameters that are categorized as device specific. + + + + + + + + + + + + + + Reference token to the VideoSource for which the Radiometry Configuration is requested. + + + + + + + + + + + + + Radiometry Configuration for the VideoSource that was requested. + + + + + + + + + + + + + + Reference token to the VideoSource for which the Radiometry settings are configured. + + + + + + + Radiometry settings to be configured. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Returns the capabilities of the thermal service. The result is returned in a typed answer. + + + + + Gets the valid ranges for the Thermal parameters that have device specific ranges. + This command is mandatory for all devices implementing the Thermal service. The command shall return all supported parameters + and their ranges, such that these can be applied to the SetConfiguration command.
+
+ + +
+ + Gets the Thermal Configuration for the requested VideoSource. + + + + + + Gets the Thermal Configuration for all thermal VideoSources of the Device. + + + + + + Sets the Thermal Configuration for the requested VideoSource. + + + + + Gets the valid ranges for the Radiometry parameters that have device specific ranges. + The command shall return all supported parameters and their ranges, such that these can be applied + to the SetRadiometryConfiguration command.
+
+ + +
+ + Gets the Radiometry Configuration for the requested VideoSource. + + + + + Sets the Radiometry Configuration for the requested VideoSource. + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file