在不录制的情况下分析实时视频Analyzing live video without any recording

建议的读前准备Suggested pre-reading

概述Overview

可以使用媒体图来分析实时视频,而不将视频的任何部分录制到文件或资产。You can use a media graph to analyze live video, without recording any portions of the video to a file or an asset. 下方显示的媒体图与基于事件的视频录制一文中的关系图类似,但不包含资产接收器节点或文件接收器节点。The media graphs shown below are similar to the ones in the article on Event-Based Video Recording, but without an asset sink node or file sink node.

动作检测Motion detection

下方显示的媒体图包含一个 RTSP 源节点、一个动作检测处理器节点和一个IoT 中心消息接收器节点。The media graph shown below consists of a RTSP source node, a motion detection processor node, and an IoT Hub message sink node. 可在此处找到此类媒体图的图形拓扑的 JSON 表示形式。The JSON representation of the graph topology of such a media graph can be found here. 此图让你可以检测传入实时视频流中的运动,并通过 IoT 中心消息接收器节点将动作事件中继到其他应用和服务。This graph enables you to detect motion in the incoming live video stream and relay the motion events to other apps and services via the IoT Hub message sink node. 外部应用或服务可以触发警报,或向相应人员发送通知。The external apps or services can trigger an alert or send a notification to appropriate personnel.

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

使用自定义视觉模型分析视频Analyzing video using a custom vision model

下方显示的媒体图让你可以使用打包在不同模块中的自定义视觉模型来分析实时视频流。The media graph shown below enables you to analyze a live video stream using a custom vision model packaged in a separate module. 可在此处找到此类媒体图的图形拓扑的 JSON 表示形式。The JSON representation of the graph topology of such a media graph can be found here. 可在此处查看一些示例,了解如何将模型包装到作为推理服务运行的 IoT Edge 模块中。You can see some examples here on wrapping models into IoT Edge modules that run as an inference service.

基于外部推理模块的实时视频分析

在此媒体图中,RTSP 源的视频输入将发送到 HTTP 扩展处理器节点,该节点将图像帧(采用 JPEG、BMP 或 PNG 格式)通过 REST 发送到外部推理服务。In this media graph, the video input from the RTSP source is sent to a HTTP extension processor node, which sends image frames (in JPEG, BMP, or PNG formats) to an external inference service over REST. 来自外部推理服务的结果由 HTTP 扩展节点检索,并通过 IoT 中心消息接收器节点中继到 IoT Edge 中心。The results from the external inference service are retrieved by the HTTP extension node, and relayed to the IoT Edge hub via IoT Hub message sink node. 这种类型的媒体图可用于为各种场景构建解决方案,例如了解路口车辆的时序分布、了解零售商店中的消费者流量模式等。This type of media graph can be used to build solutions for a variety of scenarios, such as understanding the time-series distribution of vehicles at an intersection, understanding the consumer traffic pattern in a retail store, and so on.

提示

你可以使用“samplingOptions字段管理 HTTP 扩展处理器节点内的帧速率,然后将其发送到下游。You can manage the frame rate within the HTTP extension processor node using the samplingOptions field before sending it downstream.

增强此示例的一种方法是,在抵达 HTTP 扩展处理器节点之前使用动作检测器处理器。An enhancement to this example is to use a motion detector processor ahead of the HTTP extension processor node. 这将减少推理服务上的负载,因为仅在视频中有运动活动时使用它。This will reduce the load on the inference service, since it is used only when there is motion activity in the video.

基于通过外部推理模块实现的运动检测帧的实时视频分析

后续步骤Next steps

连续视频录制Continuous video recording