业务集成
SendData/GetResult数据流图
用户使用SendData接口将图片数据发送给appsrc元件,inPluginId指定appsrc元件的编号,appsrc元件发送数据给pipeline中的其他元件处理,处理结果发送给appsink元件,用户使用GetResult接口获取appsink元件的数据,其中outPluginId指定appsink元件编号。
本套接口可以用于没有appsrc元件或appsink元件的场景(即不需要外部输入数据或调接口获取结果),例如将appsrc元件改成视频取流元件mxpi_rtspsrc时,不需要通过SendData接口发送数据,输出结果可以用GetResult或GetResultSP接口获取。


SendDataWithUniqueId/GetResultWithUniqueId数据流图
用户使用SendDataWithUniqueId接口将图片数据发送给appsrc元件,inPluginId(当前固定为“0”)指定appsrc元件的编号,返回整数uniqueId给用户,appsrc发送数据给pipeline处理,将处理结果以uniqueId为key保存在outputMap中,用户使用GetResultWithUniqueId或GetResultWithUniqueIdSP接口(使用发送时获得的uniqueId作为入参)取出与SendDataWithUniqueId对应的推理结果。


SendMultiDataWithUniqueId/GetMultiResultWithUniqueId数据流图
用户使用SendMultiDataWithUniqueId接口将图片数据发送给appsrc元件,inPluginId(当前固定为“0”)指定appsrc元件的编号,返回整数uniqueId给用户,appsrc发送数据给pipeline处理,将处理结果以uniqueId为key保存在outputMap中,用户使用GetMultiResultWithUniqueId或GetMultiResultWithUniqueIdSP接口(使用发送时获得的uniqueId作为入参)取出与SendMultiDataWithUniqueId对应的推理结果。


SendProtobuf/GetProtobuf数据流图
用户使用接口SendProtobuf将protobuf数据和key(用于将protobuf数据挂载至元数据中,使用该数据的元件可以通过这个key获取数据)批量或单个发送给appsrc元件,inPluginId指定appsrc的编号,appsrc发送数据给其他元件处理。元件处理完数据后,以元件名为key将处理结果保存至元数据中,最后通过GetProtobuf接口从元数据中取出想要获取的元件结果,输入一组key,便能获取key对应的protobuf数据。
本套接口可以用于没有appsrc或appsink元件的场景(即不需要外部输入数据或调接口获取结果),例如将appsrc改成视频取流元件mxpi_rtspsrc时,不需要通过SendProtobuf发送数据,输出结果可以用GetProtobuf获取。

当多个线程同时调用SendProtobuf接口时,GetProtobuf获取的结果顺序不确定。SendProtobuf接口支持多个appsrc输入插件,GetProtobuf支持多个appsink输出元件。

接口对比表
接口名称 |
输入数据类型 |
输出数据类型 |
输入和输出是否有序 |
是否支持多输入多输出 |
是否必须配对使用 |
使用场景 |
---|---|---|---|---|---|---|
SendData/GetResult |
图片 |
序列化输出结果、protobuf |
否 |
是 |
否 |
支持单线程有序或多线程输出结果无序。 |
SendDataWithUniqueId/GetDataWithUniqueId |
图片 |
序列化输出结果 |
是 |
否 |
是 |
支持输入输出有序的单线程或多线程。例如,创建推理服务,不同客户端并发向其发送请求。 |
SendMultiDataWithUniqueId/GetMultiResultWithUniqueId |
多张图片 |
序列化输出结果 |
是 |
否 |
是 |
支持一次性输入多张图片并输入输出有序的单线程或多线程。例如,创建推理服务,不同客户端并发向其发送请求。 |
SendProtobuf/GetProtobuf |
protobuf |
protobuf |
否 |
是 |
否 |
支持单线程有序或多线程输出结果无序。 |