-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Media] Added new LVA Edge SDK #15375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
cd6487b
added lva sdk package
hivyas 114b57e
removing tests and hardcoded strings
hivyas d5c5730
fixed tox errors
hivyas 3badfa8
modifying readme to pass tests
hivyas 8b91e11
fixed missing tests error
hivyas 2419d1b
fixing dev requirments
hivyas 34cd455
fixing readme and dev requirment
hivyas 637974d
renaming readme file
hivyas 99a9c27
fixed casing in read me file
hivyas 86ec46b
fixing dependency requirments
hivyas ca8ce7d
updating README file
hivyas ca812fc
fixed broken links
hivyas b90a28a
fixed broken link
hivyas 67d9f15
updated readme with examples
hivyas 584198d
updating readme based on comments
hivyas f2b12d5
changing package name
hivyas aacf22a
fixing broken link
hivyas 773fff7
missed one namespace update'
hivyas 8c46e02
missed more namespace changes
hivyas 250b393
changes based off PR comments
hivyas 46e4fa5
sample changes and removing hardcoded strings
hivyas 2cd1cd7
updated generated code
hivyas 9d5573b
updating swagger and import statement
hivyas 5acee23
Improve import system
lmazuel 0909a8a
regenerated using public swagger
hivyas b3d6445
renaming package and folder
hivyas 1f0a22c
updating ci file with new folder name
hivyas 9b01c04
Merge remote-tracking branch 'upstream/master'
hivyas 618a51e
updated package name correctly and test
hivyas 96406a1
updating test with missing parameter and sampels with better placehol…
hivyas 379967c
updating ci file
hivyas 9297d4f
updating ci file
hivyas 2d51142
removing tests and hardcoded strings
hivyas 6363648
fixed tox errors
hivyas 0507a37
modifying readme to pass tests
hivyas d197f20
fixed missing tests error
hivyas 92f256a
fixing dev requirments
hivyas 31826c3
fixing readme and dev requirment
hivyas a3df331
renaming readme file
hivyas 9b38847
fixed casing in read me file
hivyas a9cbd5e
fixing dependency requirments
hivyas 88913a7
updating README file
hivyas a7e4e39
fixed broken links
hivyas 4249244
fixed broken link
hivyas 14a5809
updated readme with examples
hivyas cd0cc32
updating readme based on comments
hivyas 5314dd9
changing package name
hivyas 5b9149f
fixing broken link
hivyas 656f445
missed one namespace update'
hivyas c8f67d4
missed more namespace changes
hivyas 1182a3c
changes based off PR comments
hivyas 0a826b3
sample changes and removing hardcoded strings
hivyas 0b6ae58
updated generated code
hivyas 7993cfb
updating swagger and import statement
hivyas d41e14f
Improve import system
lmazuel bf7e61b
regenerated using public swagger
hivyas cfd53fd
renaming package and folder
hivyas 5a6dade
updating ci file with new folder name
hivyas b78b798
updated package name correctly and test
hivyas a955d9f
updating test with missing parameter and sampels with better placehol…
hivyas a14b4ce
updating ci file
hivyas 0cbefcf
merged nspkg
hivyas bde520e
fixing merge conflicts
hivyas 0ae914e
addressing PR comments
hivyas 0a9c549
fixing typo
hivyas 439e9dc
adding media to nspkg ref
hivyas f8d218e
adding media-mspkg to shared_requirements
hivyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
|
|
||
| # Release History | ||
|
|
||
| ------------------- | ||
|
|
||
| ## 0.0.1 (Unreleased) | ||
|
|
||
| - Training day! | ||
hivyas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| recursive-include tests *.py | ||
| include *.md | ||
| include azure/__init__.py | ||
| recursive-include samples *.py *.md |
135 changes: 135 additions & 0 deletions
135
sdk/media/azure-media-livevideoanalytics-edge/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| # Azure Live Video Analytics for IoT Edge client library for Python | ||
|
|
||
| Live Video Analytics on IoT Edge 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 Live Video Analytics on IoT Edge to: | ||
|
|
||
| - Simplify interactions with the [Microsoft Azure IoT SDKs](https://github.com/azure/azure-iot-sdks) | ||
| - Programatically construct media graph topologies and instances | ||
|
|
||
| [Package (PyPi)][package] | [Product documentation][doc_product] | [Direct methods][doc_direct_methods] | [Media graphs][doc_media_graph] | [Source code][source] | [Samples][samples] | ||
hivyas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Getting started | ||
|
|
||
| ### Install the package | ||
|
|
||
| Install the Live Video Analytics client library for Python with pip: | ||
|
|
||
| ```bash | ||
| pip install azure-media-livevideoanalytics--edge | ||
hivyas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| ### Prerequisites | ||
|
|
||
| * Python 2.7, or 3.5 or later is required to use this package. | ||
| * You need an active [Azure subscription][azure_sub], and a [IoT device connection string][iot_device_connection_string] to use this package. | ||
|
|
||
| ### Creating a graph topology and making requests | ||
| Please visit the [Examples](#examples) for starter code | ||
| ## Key concepts | ||
|
|
||
| ### MediaGraph Topology vs MediaGraph Instance | ||
| A _graph topology_ is a blueprint or template of a graph. It defines the parameters of the graph using placeholders as values for them. A _graph instance_ references a graph topology and specifies the parameters. This way you are able to have multiple graph instances referencing the same topology but with different values for parameters. For more information please visit [Media graph topologies and instances][doc_media_graph] | ||
|
|
||
| ### CloudToDeviceMethod | ||
|
|
||
| The `CloudToDeviceMethod` is part of the [azure-iot-hub SDk][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 graph methods such as `MediaGraphTopologySetRequest` and `MediaGraphTopologyGetRequest`. To use `CloudToDeviceMethod` you need to pass in two parameters: `method_name` and `payload`. | ||
|
|
||
| The first parameter, `method_name`, is the name of the media graph request you are sending. Make sure to use each method's predefined `method_name` property. For example, `MediaGraphTopologySetRequest.method_name`. | ||
|
|
||
| The second parameter, `payload`, sends the entire serialization of the media graph request. For example, `MediaGraphTopologySetRequest.serialize()` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Creating a graph topology | ||
| To create a graph topology you need to define parameters, sources, and sinks. | ||
| ``` | ||
| #Parameters | ||
| user_name_param = MediaGraphParameterDeclaration(name="rtspUserName",type="String",default="dummyusername") | ||
| password_param = MediaGraphParameterDeclaration(name="rtspPassword",type="String",default="dummypassword") | ||
| url_param = MediaGraphParameterDeclaration(name="rtspUrl",type="String",default="rtsp://rtspsim:554/media/camera-300s.mkv") | ||
|
|
||
| #Source and Sink | ||
| source = MediaGraphRtspSource(name="rtspSource", endpoint=MediaGraphUnsecuredEndpoint(url="${rtspUrl}",credentials=MediaGraphUsernamePasswordCredentials(username="${rtspUserName}",password="${rtspPassword}"))) | ||
| node = MediaGraphNodeInput(node_name="rtspSource") | ||
| sink = MediaGraphAssetSink(name="assetsink", inputs=[node],asset_name_pattern='sampleAsset-${System.GraphTopologyName}-${System.GraphInstanceName}', segment_length="PT0H0M30S",local_media_cache_maximum_size_mi_b=2048,local_media_cache_path="/var/lib/azuremediaservices/tmp/") | ||
|
|
||
| graph_properties = MediaGraphTopologyProperties(parameters=[user_name_param, password_param, url_param], sources=[source], sinks=[sink], description="Continuous video recording to an Azure Media Services Asset") | ||
|
|
||
| graph_topology = MediaGraphTopology(name=graph_topology_name,properties=graph_properties) | ||
|
|
||
| ``` | ||
|
|
||
| ### Creating a graph instance | ||
| To create a graph instance, you need to have an existing graph topology. | ||
| ``` | ||
| url_param = MediaGraphParameterDefinition(name="rtspUrl", value=graph_url) | ||
| graph_instance_properties = MediaGraphInstanceProperties(description="Sample graph description", topology_name=graph_topology_name, parameters=[url_param]) | ||
|
|
||
| graph_instance = MediaGraphInstance(name=graph_instance_name, properties=graph_instance_properties) | ||
|
|
||
| ``` | ||
|
|
||
| ### Invoking a graph method request | ||
| To invoke a graph method on your device you need to first define the request using the lva sdk. Then send that method request using the iot sdk's `CloudToDeviceMethod` | ||
| ``` | ||
| set_method_request = MediaGraphTopologySetRequest(graph=graph_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 media graph topologies with the SDK, please see the official [Samples][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 | ||
|
|
||
| - [Samples][samples] | ||
| - [Azure IoT Device SDK][iot-device-sdk] | ||
| - [Azure IoTHub Service SDK][iot-hub-sdk] | ||
|
|
||
| ## 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][github-page-issues]. | ||
|
|
||
| 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][code_of_conduct]. For more information, | ||
| see the Code of Conduct FAQ or contact [email protected] with any | ||
| additional questions or comments. | ||
|
|
||
| <!-- LINKS --> | ||
| [azure_cli]: https://docs.microsoft.com/cli/azure | ||
| [azure_sub]: https://azure.microsoft.com/free/ | ||
|
|
||
| [cla]: https://cla.microsoft.com | ||
| [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ | ||
| [coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ | ||
| [coc_contact]: mailto:[email protected] | ||
|
|
||
| [package]: TODO://link-to-published-package | ||
| [source]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/media | ||
| [samples]: https://github.com/Azure-Samples/live-video-analytics-iot-edge-python | ||
|
|
||
| [doc_direct_methods]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/direct-methods | ||
| [doc_media_graph]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/media-graph-concept#media-graph-topologies-and-instances | ||
| [doc_product]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/ | ||
|
|
||
| [iot-device-sdk]: https://pypi.org/project/azure-iot-device/ | ||
| [iot-hub-sdk]: https://pypi.org/project/azure-iot-hub/ | ||
| [iot_device_connection_string]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/get-started-detect-motion-emit-events-quickstart | ||
|
|
||
| [github-page-issues]: https://github.com/Azure/azure-sdk-for-python/issues | ||
7 changes: 7 additions & 0 deletions
7
sdk/media/azure-media-livevideoanalytics-edge/azure/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # coding=utf-8 | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| __path__ = __import__("pkgutil").extend_path(__path__, __name__) |
1 change: 1 addition & 0 deletions
1
sdk/media/azure-media-livevideoanalytics-edge/azure/media/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) |
1 change: 1 addition & 0 deletions
1
sdk/media/azure-media-livevideoanalytics-edge/azure/media/livevideoanalytics/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) |
21 changes: 21 additions & 0 deletions
21
...media/azure-media-livevideoanalytics-edge/azure/media/livevideoanalytics/edge/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore | ||
| from azure.media.livevideoanalytics.edge._generated.models import (MediaGraphTopologySetRequestBody, | ||
| MediaGraphTopologySetRequest, MediaGraphInstanceSetRequest, MediaGraphInstanceSetRequestBody) | ||
|
|
||
| def _OverrideTopologySetRequestSerialize(self): | ||
| graph_body = MediaGraphTopologySetRequestBody(name=self.graph.name) | ||
| graph_body.system_data = self.graph.system_data | ||
| graph_body.properties = self.graph.properties | ||
|
|
||
| return graph_body.serialize() | ||
|
|
||
| MediaGraphTopologySetRequest.serialize = _OverrideTopologySetRequestSerialize | ||
|
|
||
| def _OverrideInstanceSetRequestSerialize(self): | ||
| graph_body = MediaGraphInstanceSetRequestBody(name=self.instance.name) | ||
| graph_body.system_data = self.instance.system_data | ||
| graph_body.properties = self.instance.properties | ||
|
|
||
| return graph_body.serialize() | ||
|
|
||
| MediaGraphInstanceSetRequest.serialize = _OverrideInstanceSetRequestSerialize |
1 change: 1 addition & 0 deletions
1
...-media-livevideoanalytics-edge/azure/media/livevideoanalytics/edge/_generated/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
9 changes: 9 additions & 0 deletions
9
...-media-livevideoanalytics-edge/azure/media/livevideoanalytics/edge/_generated/_version.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # coding=utf-8 | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # Code generated by Microsoft (R) AutoRest Code Generator. | ||
| # Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| VERSION = "1.0" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lmazuel, do we have a policy on what version to use for internal generated packages? Technically, I don't think it matters (it isn't part of the public API surface area), but I wasn't sure if we use it for any kind of internal bookkeeping. |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.