Azure.Media.VideoAnalyzer.Edge 1.0.0-beta.5

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This is a prerelease version of Azure.Media.VideoAnalyzer.Edge.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Azure.Media.VideoAnalyzer.Edge --version 1.0.0-beta.5
NuGet\Install-Package Azure.Media.VideoAnalyzer.Edge -Version 1.0.0-beta.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.Media.VideoAnalyzer.Edge" Version="1.0.0-beta.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.Media.VideoAnalyzer.Edge --version 1.0.0-beta.5
#r "nuget: Azure.Media.VideoAnalyzer.Edge, 1.0.0-beta.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.Media.VideoAnalyzer.Edge as a Cake Addin
#addin nuget:?package=Azure.Media.VideoAnalyzer.Edge&version=1.0.0-beta.5&prerelease

// Install Azure.Media.VideoAnalyzer.Edge as a Cake Tool
#tool nuget:?package=Azure.Media.VideoAnalyzer.Edge&version=1.0.0-beta.5&prerelease

Azure Video Analyzer Edge client library for .NET

Azure Video Analyzer is an Azure Applied AI Service that provides a platform for you to build intelligent video applications that can span both edge and cloud infrastructures. The platform offers the capability to capture, record, and analyze live video along with publishing the results, video and video analytics, to Azure services at the edge or in the cloud. It is designed to be an extensible platform, enabling you to connect different video inferencing edge modules such as Cognitive services modules, or custom inferencing modules that have been trained with your own data using either open-source machine learning or Azure Machine Learning.

Use the client library for Video Analyzer Edge to:

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

Product documentation | Direct methods | Pipelines | Source code | Samples

Getting started

This is a models-only SDK. All client operations are done using the Microsoft Azure IoT SDKs. This SDK provides models you can use to interact with the Azure IoT SDKs.

Authenticate the client

The client is coming from Azure IoT SDK. You will need to obtain an IoT device connection string in order to authenticate the Azure IoT SDK. For more information please visit: https://github.com/Azure/azure-iot-sdk-csharp.

string connectionString = System.Environment.GetEnvironmentVariable("iothub_connectionstring", EnvironmentVariableTarget.User);
var serviceClient = ServiceClient.CreateFromConnectionString(connectionString);

Install the package

Install the Video Analyzer Edge client library for .NET with NuGet:

dotnet add package Azure.Media.VideoAnalyzer.Edge --prerelease

Install the Azure IoT Hub SDk for .NET with NuGet:

dotnet add package Microsoft.Azure.Devices

Prerequisites

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

  • 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.0-beta.5 1.1
    1.0.0-beta.4 1.0
    1.0.0-beta.3 1.0
    1.0.0-beta.2 1.0
    1.0.0-beta.1 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 instantiating 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 methods such as PipelineTopologySetRequest and PipelineTopologyGetRequest. To use CloudToDeviceMethod you need to pass in one parameter: MethodName and then set the JSON payload of that method.

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

To set the Json payload of the cloud method, use the pipeline request method's GetPayloadAsJson() function. For example, directCloudMethod.SetPayloadJson(PipelineTopologySetRequest.GetPayloadAsJson())

Thread safety

We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.

Additional concepts

Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime

Examples

Creating a pipeline topology

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

Define Parameters

pipelineTopologyProperties.Parameters.Add(new ParameterDeclaration("rtspUserName", ParameterType.String)
{
    Description = "rtsp source user name.",
    Default = "exampleUserName"
});
pipelineTopologyProperties.Parameters.Add(new ParameterDeclaration("rtspPassword", ParameterType.SecretString)
{
    Description = "rtsp source password.",
    Default = "examplePassword"
});
pipelineTopologyProperties.Parameters.Add(new ParameterDeclaration("rtspUrl", ParameterType.String)
{
    Description = "rtsp Url"
});

Define a Source

pipelineTopologyProps.Sources.Add(new RtspSource("rtspSource", new UnsecuredEndpoint("${rtspUrl}")
{
    Credentials = new UsernamePasswordCredentials("${rtspUserName}", "${rtspPassword}")
})
);

Define a Sink

var nodeInput = new List<NodeInput>
{
    new NodeInput("rtspSource")
};
pipelineTopologyProps.Sinks.Add(new VideoSink("videoSink", nodeInput, "video", "/var/lib/videoanalyzer/tmp/", "1024"));

Set the topology properties and create a topology

var pipelineTopologyProps = new PipelineTopologyProperties
{
    Description = "Continuous video recording to a Video Analyzer video",
};
SetParameters(pipelineTopologyProps);
SetSources(pipelineTopologyProps);
SetSinks(pipelineTopologyProps);
return new PipelineTopology("ContinuousRecording")
{
    Properties = pipelineTopologyProps
};

Creating a live pipeline

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

var livePipelineProps = new LivePipelineProperties
{
    Description = "Sample description",
    TopologyName = topologyName,
};

livePipelineProps.Parameters.Add(new ParameterDefinition("rtspUrl", "rtsp://sample.com"));

return new LivePipeline("livePIpeline")
{
    Properties = livePipelineProps
};

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.

var setPipelineTopRequest = new PipelineTopologySetRequest(pipelineTopology);

var directMethod = new CloudToDeviceMethod(setPipelineTopRequest.MethodName);
directMethod.SetPayloadJson(setPipelineTopRequest.GetPayloadAsJson());

var setPipelineTopResponse = await _serviceClient.InvokeDeviceMethodAsync(_deviceId, _moduleId, directMethod);

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.MethodName

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.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta.6 1,476 4/30/2022
1.0.0-beta.5 1,629 10/27/2021
1.0.0-beta.4 489 5/25/2021
1.0.0-beta.3 150 5/24/2021
1.0.0-beta.2 144 5/19/2021