Skip to main content

Azure Video Analyzer Edge SDK Library for Python

Project description

Azure Video Analyzer Edge client library for Python

Azure Video Analyzer provides a platform to build intelligent video applications that span the edge and the cloud. The platform offers the capability to capture, record, and analyze live video along with publishing the results, video and video analytics, to Azure services in the cloud or the edge. It is designed to be an extensible platform, enabling you to connect different video analysis edge modules (such as Cognitive services containers, custom edge modules built by you with open-source machine learning models or custom models trained with your own data) to it and use them to analyze live video without worrying about the complexity of building and running a live video pipeline.

Use the client library for Video Analyzer Edge to:

  • Simplify interactions with the Microsoft Azure IoT SDKs
  • Programmatically construct pipeline topologies and live pipelines

Package (PyPI) | Product documentation | Direct methods | Pipelines | Source code | Samples

Getting started

Install the package

Install the Video Analyzer Edge client library for Python with pip:

pip install azure-media-videoanalyzer-edge

Prerequisites

  • Python 2.7, or 3.6 or later is required to use this package.

  • You need an active Azure subscription, and a IoT device connection string to use this package.

  • To interact with Azure IoT Hub you will need to run pip install azure-iot-hub

  • You will need to use the version of the SDK that corresponds to the version of the Video Analyzer Edge module you are using.

    SDK Video Analyzer edge module
    1.0.0b1 1.0

Creating a pipeline topology and making requests

Please visit the Examples for starter code.

Key concepts

Pipeline topology vs live pipeline

A pipeline topology is a blueprint or template for creating live pipelines. It defines the parameters of the pipeline using placeholders as values for them. A live pipeline references a pipeline topology and specifies the parameters. This way you are able to have multiple live pipelines referencing the same topology but with different values for parameters. For more information please visit pipeline topologies and live pipelines.

CloudToDeviceMethod

The CloudToDeviceMethod is part of the azure-iot-hub SDk. This method allows you to communicate one way notifications to a device in your IoT hub. In our case, we want to communicate various direct methods such as PipelineTopologySetRequest and PipelineTopologyGetRequest. To use CloudToDeviceMethod you need to pass in two parameters: method_name and payload.

The first parameter, method_name, is the name of the direct method request you are sending. Make sure to use each method's predefined method_name property. For example, PipelineTopologySetRequest.method_name.

The second parameter, payload, sends the entire serialization of the pipeline topology request. For example, PipelineTopologySetRequest.serialize()

Examples

Creating a pipeline topology

To create a pipeline topology you need to define sources and sinks.

#Parameters
user_name_param = ParameterDeclaration(name="rtspUserName",type="String",default="testusername")
password_param = ParameterDeclaration(name="rtspPassword",type="SecretString",default="testpassword")
url_param = ParameterDeclaration(name="rtspUrl",type="String",default="rtsp://www.sample.com")
hub_param = ParameterDeclaration(name="hubSinkOutputName",type="String")

#Source and Sink
source = RtspSource(name="rtspSource", endpoint=UnsecuredEndpoint(url="${rtspUrl}",credentials=UsernamePasswordCredentials(username="${rtspUserName}",password="${rtspPassword}")))
node = NodeInput(node_name="rtspSource")
sink = IotHubMessageSink("msgSink", nodeInput, "${hubSinkOutputName}")

pipeline_topology_properties = PipelineTopologyProperties()
pipeline_topology_properties.parameters = [user_name_param, password_param, url_param, hub_param]
pipeline_topology_properties.sources = [source]
pipeline_topology_properties.sinks = [sink]
pipeline_topology = PipelineTopology(name=pipeline_topology_name,properties=pipeline_topology_properties)

Creating a live pipeline

To create a live pipeline, you need to have an existing pipeline topology.

url_param = ParameterDefinition(name="rtspUrl", value=pipeline_url)
pass_param = ParameterDefinition(name="rtspPassword", value='testpass')
live_pipeline_properties = LivePipelineProperties(description="Sample pipeline description", topology_name=pipeline_topology_name, parameters=[url_param])

live_pipeline = LivePipeline(name=live_pipeline_name, properties=live_pipeline_properties)

Invoking a direct method

To invoke a direct method on your device you need to first define the request using the Video Analyzer Edge SDK, then send that method request using the IoT SDK's CloudToDeviceMethod.

set_method_request = PipelineTopologySetRequest(pipeline_topology=pipeline_topology)
direct_method = CloudToDeviceMethod(method_name=set_method_request.method_name, payload=set_method_request.serialize())
registry_manager = IoTHubRegistryManager(connection_string)

registry_manager.invoke_device_module_method(device_id, module_d, direct_method)

To try different pipeline topologies with the SDK, please see the official Samples.

Troubleshooting

  • When sending a method request using the IoT Hub's CloudToDeviceMethod remember to not type in the method request name directly. Instead use [MethodRequestName.method_name]
  • Make sure to serialize the entire method request before passing it to CloudToDeviceMethod

Next steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

If you encounter any issues, please open an issue on our Github.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Release History

1.0.0b2 (2021-05-24)

  • Updated title and description of the package and updates to readme

1.0.0b1 (2021-05-19)

Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure-media-videoanalyzer-edge-1.0.0b2.zip (56.2 kB view details)

Uploaded Source

Built Distribution

azure_media_videoanalyzer_edge-1.0.0b2-py2.py3-none-any.whl (41.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file azure-media-videoanalyzer-edge-1.0.0b2.zip.

File metadata

  • Download URL: azure-media-videoanalyzer-edge-1.0.0b2.zip
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for azure-media-videoanalyzer-edge-1.0.0b2.zip
Algorithm Hash digest
SHA256 9e96a1b82c147953706e796cbb28d55e27a99ccf146041f7f1a818405952ed32
MD5 5e743756e86dbe38a22fde2dd78f70fb
BLAKE2b-256 d9bf40027cbb5216c347876f72720777aa14c2ad01cf45862f833f53f086e4b3

See more details on using hashes here.

File details

Details for the file azure_media_videoanalyzer_edge-1.0.0b2-py2.py3-none-any.whl.

File metadata

  • Download URL: azure_media_videoanalyzer_edge-1.0.0b2-py2.py3-none-any.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for azure_media_videoanalyzer_edge-1.0.0b2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8c6faa7e59449ea9ac2f9adea713228d4b149b74ef6511fb5eb1cd4552a7f9e6
MD5 35308c374e7902dc2b4daa28fba44d68
BLAKE2b-256 050b75a63ec2d8f6fa698a62a6d548cb42000cd3004253834c641b17da87077d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page