快速入门:检测运动并发出事件Quickstart: Detect motion and emit events

本快速入门将引导你完成开始使用 IoT Edge 上的实时视频分析的步骤。This quickstart walks you through the steps to get started with Live Video Analytics on IoT Edge. 它将 Azure VM 用作 IoT Edge 设备和模拟的实时视频流。It uses an Azure VM as an IoT Edge device and a simulated live video stream. 完成设置步骤后,你将能通过媒体图运行模拟实时视频流,该媒体图可检测和报告该流中的任何运动。After completing the setup steps, you'll be able to run a simulated live video stream through a media graph that detects and reports any motion in that stream. 下图显示了该媒体图的图形表示形式。The following diagram shows a graphical representation of that media graph.

基于运动检测的实时视频分析

本文基于用 C# 编写的示例代码This article is based on sample code written in C#.

先决条件Prerequisites

  • 具有活动订阅的 Azure 帐户。An Azure account that has an active subscription. 如果没有帐户,可以创建试用帐户Create an account for trial if you don't already have one.

    备注

    你将需要一个具有服务主体创建权限(所有者角色提供此权限)的 Azure 订阅。You will need an Azure subscription with permissions for creating service principals (owner role provides this). 如果你没有正确的权限,请联系帐户管理员,让其授予你适当的权限。If you do not have the right permissions, please reach out to your account administrator to grant you the right permissions.

  • 包含以下扩展的 Visual Studio CodeVisual Studio Code with the following extensions:
  • .NET Core 3.1 SDK.NET Core 3.1 SDK.

提示

安装 Azure IoT Tools 扩展时,系统可能会提示你安装 Docker。You might be prompted to install Docker while you're installing the Azure IoT Tools extension. 可以忽略该提示。You can ignore the prompt.

观看示例视频Review the sample video

设置 Azure 资源时,一个高速公路车流量短视频被复制到 Azure 中用作 IoT Edge 设备的 Linux VM 上。When you set up the Azure resources, a short video of highway traffic is copied to the Linux VM in Azure that you're using as the IoT Edge device. 此快速入门使用视频文件来模拟实时流。This quickstart uses the video file to simulate a live stream.

打开一个应用程序,例如 VLC 媒体播放器Open an application such as VLC media player. 选择 Ctrl+N,然后粘贴指向高速公路交叉口示例视频的链接以开始播放。Select Ctrl+N and then paste a link to the highway intersection sample video to start playback. 可以看到许多车辆在高速公路上行驶的镜头。You see the footage of many vehicles moving in highway traffic.

设置 Azure 资源Set up Azure resources

本教程需要以下 Azure 资源:This tutorial requires the following Azure resources:

  • IoT 中心IoT Hub
  • 存储帐户Storage account
  • Azure 媒体服务帐户Azure Media Services account
  • Azure 中的 Linux VM,已安装 IoT Edge 运行时Linux VM in Azure, with IoT Edge runtime installed

在本快速入门中,我们建议你使用实时视频分析资源设置脚本在 Azure 订阅中部署所需资源。For this quickstart, we recommend that you use the Live Video Analytics resources setup script to deploy the required resources in your Azure subscription. 为此,请执行下列步骤:To do so, follow these steps:

  1. 运行以下 Bash 命令。Run the following Bash command.

    bash -c "$(curl -sL https://aka.ms/lva-edge/setup-resources-for-samples)"
    

    在脚本成功完成后,你应可在订阅中看到所有所需资源。Upon successful completion of the script, you should see all of the required resources in your subscription. 脚本将设置总共 12 种资源:A total of 12 resources will be setup by the script:

    1. 流式处理终结点 - 这将有助于播放记录的 AMS 资产。Streaming Endpoint - This will help in the playing the recorded AMS asset.
    2. 虚拟机 - 这是将充当边缘设备的虚拟机。Virtual machine - This is a virtual machine that will act as your edge device.
    3. 磁盘 - 这是连接到虚拟机来存储媒体和项目的存储磁盘。Disk - This is a storage disk that is attached to the virtual machine to store media and artifacts.
    4. 网络安全组 - 这用于筛选 Azure 虚拟网络中出入 Azure 资源的网络流量。Network security group - This is used to filter network traffic to and from Azure resources in an Azure virtual network.
    5. 网络接口 - Azure 虚拟机可通过它与 Internet、Azure 和其他资源进行通信。Network interface - This enables an Azure Virtual Machine to communicate with internet, Azure, and other resources.
    6. 堡垒连接 - 你可通过它使用浏览器和 Azure 门户连接到虚拟机。Bastion connection - This lets you connect to your virtual machine using your browser and the Azure portal.
    7. 公共 IP 地址 - Azure 资源可通过它与 Internet 和面向公众的 Azure 服务通信Public IP address - This enables Azure resources to communicate to Internet and public-facing Azure services
    8. 虚拟网络 - 通过它,许多类型的 Azure 资源(例如虚拟机)可以安全方式彼此通信、与 Internet 通信,以及与本地网络通信。Virtual network - This enables many types of Azure resources, such as your virtual machine, to securely communicate with each other, the internet, and on-premises networks. 详细了解虚拟网络Learn more about Virtual networks
    9. IoT 中心 - 这充当消息中心,用于在 IoT 应用程序、IoT Edge 模块以及它管理的设备之间进行双向通信。IoT Hub - This acts as a central message hub for bi-directional communication between your IoT application, IoT Edge modules and the devices it manages.
    10. 媒体服务帐户 - 这有助于在 Azure 中管理和流式传输媒体内容。Media service account - This helps with managing and streaming media content in Azure.
    11. 存储帐户 - 你必须具有一个主存储帐户,而且可拥有任意数量与媒体服务帐户关联的辅助存储帐户。Storage account - You must have one Primary storage account and you can have any number of Secondary storage accounts associated with your Media Services account. 有关详细信息,请参阅 Azure 存储帐户与 Azure 媒体服务帐户For more information, see Azure Storage accounts with Azure Media Services accounts.
    12. 容器注册表 - 这有助于存储和管理专用 Docker 容器映像及相关项目。Container registry - This helps in storing and managing your private Docker container images and related artifacts.
  2. 脚本完成后,选择大括号即可公开文件夹结构。After the script finishes, select the curly brackets to expose the folder structure. 你将看到一些文件。You'll see a few files. 与本快速入门相关的文件如下:Of interest in this quickstart are:

    • edge-deployment/.env - 此文件包含 Visual Studio Code 用来将模块部署到边缘设备的属性。edge-deployment/.env - This file contains properties that Visual Studio Code uses to deploy modules to an edge device.
    • appsetting.json - Visual Studio Code 使用此文件来运行示例代码。appsetting.json - Visual Studio Code uses this file to run the sample code.

    在下一节的 Visual Studio Code 中设置开发环境时,你需要这些文件。You'll need these files when you set up your development environment in Visual Studio Code in the next section. 现在需要将它们复制到本地文件中。You might want to copy them into a local file for now.

    应用设置

提示

如果在创建 Azure 资源时遇到问题,请查看故障排除指南来解决一些常见问题。If you run into issues with Azure resources that get created, please view our troubleshooting guide to resolve some commonly encountered issues.

设置开发环境Set up your development environment

  1. 从此位置克隆存储库: https://github.com/Azure-Samples/live-video-analytics-iot-edge-csharpClone the repo from this location: https://github.com/Azure-Samples/live-video-analytics-iot-edge-csharp.

  2. 在 Visual Studio Code 中,打开下载的存储库所在的文件夹。In Visual Studio Code, open the folder where the repo has been downloaded.

  3. 在 Visual Studio Code 中,转到 src/cloud-to-device-console-app 文件夹。In Visual Studio Code, go to the src/cloud-to-device-console-app folder. 在该文件中,创建一个文件并将其命名为 appsettings.json。There, create a file and name it appsettings.json. 该文件将包含运行程序所需的设置。This file will contain the settings needed to run the program.

  4. 复制之前在本快速入门中生成的 appsettings.json 文件中的内容。Copy the contents from the appsettings.json file that you generated earlier in this quickstart.

    文本应类似于以下输出。The text should look like the following output.

    {  
        "IoThubConnectionString" : "HostName=xxx.azure-devices.cn;SharedAccessKeyName=iothubowner;SharedAccessKey=XXX",  
        "deviceId" : "lva-sample-device",  
        "moduleId" : "lvaEdge"  
    }
    
  5. 转到 src/edge 文件夹并创建一个名为 .env 的文件 。Go to the src/edge folder and create a file named .env.

  6. 复制 edge-deployment/.env 文件的内容。Copy the contents of the edge-deployment/.env file. 文本应类似于以下代码。The text should look like the following code.

    SUBSCRIPTION_ID="<Subscription ID>"  
    RESOURCE_GROUP="<Resource Group>"  
    AMS_ACCOUNT="<AMS Account ID>"  
    IOTHUB_CONNECTION_STRING="HostName=xxx.azure-devices.cn;SharedAccessKeyName=iothubowner;SharedAccessKey=xxx"  
    AAD_TENANT_ID="<AAD Tenant ID>"  
    AAD_SERVICE_PRINCIPAL_ID="<AAD SERVICE_PRINCIPAL ID>"  
    AAD_SERVICE_PRINCIPAL_SECRET="<AAD SERVICE_PRINCIPAL ID>"  
    VIDEO_INPUT_FOLDER_ON_DEVICE="/home/lvaedgeuser/samples/input"  
    VIDEO_OUTPUT_FOLDER_ON_DEVICE="/var/media"
    APPDATA_FOLDER_ON_DEVICE="/var/local/mediaservices"
    CONTAINER_REGISTRY_USERNAME_myacr="<your container registry username>"  
    CONTAINER_REGISTRY_PASSWORD_myacr="<your container registry password>"      
    

检查示例文件Examine the sample files

  1. 在 Visual Studio Code 中,转到 src/edge。In Visual Studio Code, go to src/edge. 你将看到 .env 文件以及一些部署模板文件。You'll see the .env file and a few deployment template files.

    部署模板是指边缘设备的部署清单,其中使用变量指定某些属性。The deployment template refers to the deployment manifest for the edge device, where variables are used for some properties. 该 .env 文件包含这些变量的值。The .env file contains the values for those variables.

  2. 转到 src/cloud-to-device-console-app 文件夹。Go to the src/cloud-to-device-console-app folder. 你可在此处看到 appsettings.json 文件和一些其他文件:Here you see the appsettings.json file and a few other files:

    • c2d-console-app.csproj - Visual Studio Code 的项目文件。c2d-console-app.csproj - The project file for Visual Studio Code.

    • operations.json - 希望程序运行的操作的列表。operations.json - A list of the operations that you want the program to run.

    • Program.cs - 示例程序代码。Program.cs - The sample program code. 此代码:This code:

      • 加载应用设置。Loads the app settings.
      • 在 IoT Edge 模块上调用实时视频分析公开的直接方法。Invokes direct methods that are exposed by the Live Video Analytics on IoT Edge module. 可以通过调用模块的直接方法来使用该模块分析实时视频流。You can use the module to analyze live video streams by invoking its direct methods.
      • 暂停以检查“终端”窗口中程序的输出,并检查“输出”窗口中模块生成的事件 。Pauses so you can examine the program's output in the TERMINAL window and examine the events generated by the module in the OUTPUT window.
      • 调用直接方法以清理资源。Invokes direct methods to clean up resources.

生成并部署部署清单Generate and deploy the deployment manifest

部署清单定义要部署到边缘设备的模块。The deployment manifest defines what modules are deployed to an edge device. 它还定义了这些模块的配置设置。It also defines configuration settings for those modules.

请按照以下步骤从模板文件生成清单,然后将其部署到边缘设备。Follow these steps to generate the manifest from the template file and then deploy it to the edge device.

  1. 打开 Visual Studio Code。Open Visual Studio Code.

  2. 在“AZURE IOT 中心”窗格旁,选择“更多操作”图标以设置 IoT 中心连接字符串 。Next to the AZURE IOT HUB pane, select the More actions icon to set the IoT Hub connection string. 可以从 src/cloud-to-device-console-app/appsettings.json 文件复制该字符串。You can copy the string from the src/cloud-to-device-console-app/appsettings.json file.

    设置 IoT 连接字符串

备注

系统可能会要求你提供 IoT 中心的内置终结点信息。You might be asked to provide Built-in endpoint information for the IoT Hub. 若要获取此信息,请在 Azure 门户中导航到 IoT 中心,然后在左侧导航窗格中查找“内置终结点”选项。To get that information, in Azure portal, navigate to your IoT Hub and look for Built-in endpoints option in the left navigation pane. 单击此处,在“与事件中心兼容的终结点”部分下查找“与事件中心兼容的终结点” 。Click there and look for the Event Hub-compatible endpoint under Event Hub compatible endpoint section. 复制并使用框中的文本。Copy and use the text in the box. 终结点将如下所示:The endpoint will look something like this:
Endpoint=sb://iothub-ns-xxx.servicebus.chinacloudapi.cn/;SharedAccessKeyName=iothubowner;SharedAccessKey=XXX;EntityPath=<IoT Hub name>

  1. 右键单击“src/edge/deployment.template.json”并选择“生成 IoT Edge 部署清单”。Right-click src/edge/deployment.template.json and select Generate IoT Edge Deployment Manifest.

    生成 IoT Edge 部署清单

    此操作应在 src/edge/config 文件夹中创建一个名为“deployment.amd64.json”的清单文件 。This action should create a manifest file named deployment.amd64.json in the src/edge/config folder.

  2. 右键单击“src/edge/config/deployment.amd64.json”,选择“为单个设备创建部署”,然后选择边缘设备的名称 。Right-click src/edge/config/deployment.amd64.json, select Create Deployment for Single Device, and then select the name of your edge device.

    创建单个设备的部署

  3. 如果系统提示你选择 IoT 中心设备,请从下拉菜单中选择“lva-sample-device”。When you're prompted to select an IoT Hub device, choose lva-sample-device from the drop-down menu.

  4. 大约 30 秒后,在该窗口的左下角刷新 Azure IoT 中心。After about 30 seconds, in the lower-left corner of the window, refresh Azure IoT Hub. 边缘设备现在显示以下已部署的模块:The edge device now shows the following deployed modules:

    • IoT Edge 上的实时视频分析(模块名称为 lvaEdgeLive Video Analytics on IoT Edge (module name lvaEdge)
    • 实时流式处理协议 (RTSP) 模拟器(模块名称为 rtspsimReal-Time Streaming Protocol (RTSP) simulator (module name rtspsim)

RTSP 模拟器模块使用视频文件模拟实时视频流,该文件已在运行实时视频分析资源设置脚本时复制到边缘设备。The RTSP simulator module simulates a live video stream by using a video file that was copied to your edge device when you ran the Live Video Analytics resources setup script.

备注

如果使用的是自己的边缘设备,而不是设置脚本预配的边缘设备,请转到你的边缘设备并使用管理员权限运行以下命令,以拉取并存储该快速入门所使用的示例视频文件:If you are using your own edge device instead of the one provisioned by our setup script, go to your edge device and run the following commands with admin rights, to pull and store the sample video file used for this quickstart:

mkdir /home/lvaedgeuser/samples      
mkdir /home/lvaedgeuser/samples/input    
curl https://lvamedia.blob.core.windows.net/public/camera-300s.mkv > /home/lvaedgeuser/samples/input/camera-300s.mkv  
chown -R lvalvaedgeuser:localusergroup /home/lvaedgeuser/samples/  

在此阶段,模块已部署,但没有媒体图处于活动状态。At this stage, the modules are deployed but no media graphs are active.

准备监视事件Prepare to monitor events

你将在 IoT Edge 模块上使用实时视频分析来检测传入的实时视频流中的运动并将事件发送到 IoT 中心。You'll use the Live Video Analytics on IoT Edge module to detect motion in the incoming live video stream and send events to IoT Hub. 若要查看这些事件,请执行以下步骤:To see these events, follow these steps:

  1. 在 Visual Studio Code 中打开“资源管理器”窗格,然后在左下角查找“Azure IoT 中心”。Open the Explorer pane in Visual Studio Code and look for Azure IoT Hub in the lower-left corner.

  2. 展开“设备”节点。Expand the Devices node.

  3. 右键单击“lva-sample-device”,然后选择“开始监视内置事件终结点” 。Right-click lva-sample-device and select Start Monitoring Built-in Event Endpoint.

    开始监视内置事件终结点

备注

系统可能会要求你提供 IoT 中心的内置终结点信息。You might be asked to provide Built-in endpoint information for the IoT Hub. 若要获取此信息,请在 Azure 门户中导航到 IoT 中心,然后在左侧导航窗格中查找“内置终结点”选项。To get that information, in Azure portal, navigate to your IoT Hub and look for Built-in endpoints option in the left navigation pane. 单击此处,在“与事件中心兼容的终结点”部分下查找“与事件中心兼容的终结点” 。Click there and look for the Event Hub-compatible endpoint under Event Hub compatible endpoint section. 复制并使用框中的文本。Copy and use the text in the box. 终结点将如下所示:The endpoint will look something like this:
Endpoint=sb://iothub-ns-xxx.servicebus.chinacloudapi.cn/;SharedAccessKeyName=iothubowner;SharedAccessKey=XXX;EntityPath=<IoT Hub name>

运行示例程序Run the sample program

若要运行该示例代码,请按照以下步骤执行:Follow these steps to run the sample code:

  1. 在 Visual Studio Code 中,打开“扩展”选项卡(或按 Ctrl+Shift+X),然后搜索“Azure IoT 中心”。In Visual Studio Code, open the Extensions tab (or press Ctrl+Shift+X) and search for Azure IoT Hub.

  2. 右键单击并选择“扩展设置”。Right click and select Extension Settings.

    扩展设置

  3. 搜索并启用“显示详细消息”。Search and enable "Show Verbose Message".

    显示详细消息

  4. 在 Visual Studio Code 中,转到 src/cloud-to-device-console-app/operations.json。In Visual Studio Code, go to src/cloud-to-device-console-app/operations.json.

  5. 在 GraphTopologySet 节点上,确保你看到以下值:On the GraphTopologySet node, make sure you see the following value:

    "topologyUrl" : "https://raw.githubusercontent.com/Azure/live-video-analytics/master/MediaGraph/topologies/motion-detection/2.0/topology.json"

  6. 在节点 GraphInstanceSet 和 GraphTopologyDelete 节点上,确保 topologyName 的值与图形拓扑中 name 属性的值匹配 :On the GraphInstanceSet and GraphTopologyDelete nodes, ensure that the value of topologyName matches the value of the name property in the graph topology:

    "topologyName" : "MotionDetection"

  7. 通过选择 F5 键启动调试会话。Start a debugging session by selecting the F5 key. “终端”窗口将显示一些消息。The TERMINAL window will display some messages.

  8. operations.json 文件首先调用 GraphTopologyListGraphInstanceListThe operations.json file starts off with calls to GraphTopologyList and GraphInstanceList. 如果在完成先前的快速入门后清理了资源,则该过程将返回空列表,然后暂停。If you cleaned up resources after you finished previous quickstarts, then this process will return empty lists and then pause. 若要继续,请选择 Enter 键。To continue, select the Enter key.

    --------------------------------------------------------------------------
    Executing operation GraphTopologyList
    -----------------------  Request: GraphTopologyList  --------------------------------------------------
    {
        "@apiVersion": "2.0"
    }
    ---------------  Response: GraphTopologyList - Status: 200  ---------------
    {
        "value": []
    }
    --------------------------------------------------------------------------
    Executing operation WaitForInput
    Press Enter to continue
    

    “终端”窗口将显示下一组直接方法调用:The TERMINAL window shows the next set of direct method calls:

    • GraphTopologySet 的调用,该调用使用前面的 topologyUrlA call to GraphTopologySet that uses the preceding topologyUrl
    • GraphInstanceSet 的调用,该调用使用以下正文:A call to GraphInstanceSet that uses the following body:
    {
      "@apiVersion": "2.0",
      "name": "Sample-Graph",
      "properties": {
        "topologyName": "MotionDetection",
        "description": "Sample graph description",
        "parameters": [
          {
            "name": "rtspUrl",
            "value": "rtsp://rtspsim:554/media/camera-300s.mkv"
          },
          {
            "name": "rtspUserName",
            "value": "testuser"
          },
          {
            "name": "rtspPassword",
            "value": "testpassword"
          }
        ]
      }
    }
    
    • GraphInstanceActivate 的调用,用于启动图形实例和视频流。A call to GraphInstanceActivate that starts the graph instance and the flow of video.
    • GraphInstanceList 的第二次调用,显示图形实例处于正在运行状态。A second call to GraphInstanceList that shows that the graph instance is in the running state.
  9. “终端”窗口中的输出会在出现 Press Enter to continue 时暂停。The output in the TERMINAL window pauses at Press Enter to continue. 暂时不要选择 Enter。Don't select Enter yet. 向上滚动,查看调用的直接方法的 JSON 响应有效负载。Scroll up to see the JSON response payloads for the direct methods you invoked.

  10. 切换到 Visual Studio Code 中的“输出”窗口。Switch to the OUTPUT window in Visual Studio Code. 可看到 IoT Edge 模块上的实时视频分析正发送到 IoT 中心的消息。You see messages that the Live Video Analytics on IoT Edge module is sending to the IoT hub. 本快速入门中的以下部分将讨论这些消息。The following section of this quickstart discusses these messages.

  11. 媒体图将继续运行并打印结果。The media graph continues to run and print results. RTSP 模拟器不断循环源视频。The RTSP simulator keeps looping the source video. 若要停止媒体图,请返回“终端”窗口,并选择 Enter。To stop the media graph, return to the TERMINAL window and select Enter.

    接下来会执行一系列调用,以清理资源:The next series of calls cleans up resources:

    • 调用 GraphInstanceDeactivate 停用图形实例。A call to GraphInstanceDeactivate deactivates the graph instance.
    • 调用 GraphInstanceDelete 删除该实例。A call to GraphInstanceDelete deletes the instance.
    • 调用 GraphTopologyDelete 删除拓扑。A call to GraphTopologyDelete deletes the topology.
    • GraphTopologyList 的最后一次调用显示该列表为空。A final call to GraphTopologyList shows that the list is empty.

解释结果Interpret results

运行媒体图时,来自运动检测器处理器节点的结果将通过 IoT 中心接收器节点发送到 IoT 中心。When you run the media graph, the results from the motion detector processor node pass through the IoT Hub sink node to the IoT hub. Visual Studio Code 的“输出”窗口中显示的消息包含 body 部分和 applicationProperties 部分。The messages you see in the OUTPUT window of Visual Studio Code contain a body section and an applicationProperties section. 有关详细信息,请参阅创建和读取 IoT 中心消息For more information, see Create and read IoT Hub messages.

在下面的消息中,实时视频分析模块定义了应用程序属性和正文内容。In the following messages, the Live Video Analytics module defines the application properties and the content of the body.

MediaSessionEstablished 事件MediaSessionEstablished event

对媒体图进行实例化后,RTSP 源节点尝试连接到在 rtspsim-live555 容器上运行的 RTSP 服务器。When a media graph is instantiated, the RTSP source node attempts to connect to the RTSP server that runs on the rtspsim-live555 container. 如果连接成功,则打印以下事件。If the connection succeeds, then the following event is printed.

[IoTHubMonitor] [9:42:18 AM] Message received from [lvaedgesample/lvaEdge]:  
{  
"body": {
"sdp": "SDP:\nv=0\r\no=- 1586450538111534 1 IN IP4 xxx.xxx.xxx.xxx\r\ns=Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server\r\ni=media/camera-300s.mkv\r\nt=0 0\r\na=tool:LIVE555 Streaming Media v2020.03.06\r\na=type:broadcast\r\na=control:*\r\na=range:npt=0-300.000\r\na=x-qt-text-nam:Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server\r\na=x-qt-text-inf:media/camera-300s.mkv\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:500\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=4D0029;sprop-parameter-sets={SPS}\r\na=control:track1\r\n"  
},  
"applicationProperties": {  
    "dataVersion": "1.0",  
    "topic": "/subscriptions/{subscriptionID}/resourceGroups/{name}/providers/microsoft.media/mediaservices/hubname",  
    "subject": "/graphInstances/GRAPHINSTANCENAMEHERE/sources/rtspSource",  
    "eventType": "Microsoft.Media.MediaGraph.Diagnostics.MediaSessionEstablished",  
    "eventTime": "2020-04-09T16:42:18.1280000Z"  
    }  
}

在以上脚本中:In the preceding output:

  • 消息为诊断事件 MediaSessionEstablishedThe message is a diagnostics event, MediaSessionEstablished. 它指示 RTSP 源节点(使用者)与 RTSP 模拟器连接,并已开始接收(模拟的)实时馈送。It indicates that the RTSP source node (the subject) connected with the RTSP simulator and has begun to receive a (simulated) live feed.
  • applicationProperties 中的 subject 引用生成消息的图形拓扑中的节点。In applicationProperties, subject, references the node in the graph topology from which the message was generated. 在本例中,该消息来自 RTSP 源节点。In this case, the message originates from the RTSP source node.
  • applicationProperties 中的 eventType 指示此事件是诊断事件。In applicationProperties, eventType indicates that this event is a diagnostics event.
  • eventTime 值指示事件发生的时间。The eventTime value indicates the time when the event occurred.
  • body 部分包含有关诊断事件的数据。The body section contains data about the diagnostics event. 在本例中,数据包含会话描述协议 (SDP) 详细信息。In this case, the data comprises the Session Description Protocol (SDP) details.

MotionDetection 事件MotionDetection event

当检测到运动时,IoT Edge 模块上的实时视频分析将发送推理事件。When motion is detected, the Live Video Analytics on IoT Edge module sends an inference event. type 设置为 motion,指示它是运动检测处理器的结果。The type is set to motion to indicate that it's a result from the motion detection processor. eventTime 值告知运动发生的时间 (UTC)。The eventTime value tells you when (in UTC) the motion occurred.

以下是此消息的示例:Here's an example of this message:

  {  
  "body": {  
    "timestamp": 142843967343090,
    "inferences": [  
      {  
        "type": "motion",  
        "motion": {  
          "box": {  
            "l": 0.573222,  
            "t": 0.492537,  
            "w": 0.141667,  
            "h": 0.074074  
          }  
        }  
      }  
    ]  
  } 
}  

在本示例中:In this example:

  • eventTime 值为事件发生的时间。The eventTime value is the time when the event occurred.

  • body 值包含有关分析事件的数据。The body value is data about the analytics event. 在本例中,该事件是推理事件,因此正文包含 timestampinferences 数据。In this case, the event is an inference event, so the body contains timestamp and inferences data.

  • inferences 数据指示 typemotionThe inferences data indicates that the type is motion. 它包含有关该 motion 事件的其他数据。It has additional data about that motion event.

  • box 部分包含移动对象周围的边界框的坐标。The box section contains the coordinates for a bounding box around the moving object. 值按视频的宽度和高度(以像素为单位)进行规范化。The values are normalized by the width and height of the video, in pixels. 例如,宽度为 1920,高度为 1080。For example, the width is 1920 and the height is 1080.

    l - distance from left of image
    t - distance from top of image
    w - width of bounding box
    h - height of bounding box
    

清理资源Clean up resources

如果想学习其他快速入门,则请保留所创建的资源。If you intend to try the other quickstarts, then you should keep the resources you created. 否则,请在 Azure 门户中,转到资源组,选择运行本快速入门所用的资源组,然后删除所有资源。Otherwise, in the Azure portal, go to your resource groups, select the resource group where you ran this quickstart, and then delete all of the resources.

后续步骤Next steps

运行其他快速入门,如检测实时视频源中的对象。Run the other quickstarts, such as detecting an object in a live video feed.