Obtaining Input Data

The data transmitted between plugins is defined by protobuf. For details about the data format, see Metadata and Metadata Proto File. The input data is parsed by protobuf, and the output result is assembled by protobuf. For details about the plugin code, see Sample Plugin Head File (MxpiSamplePlugin.h) and Sample Plugin Source File (MxpiSamplePlugin.cpp).

The SDK uses the Process() function of the plugin to transfer the input data as the input parameter (mxpiBuffer) and provides the data by using the GetMetadata API.

The procedure is as follows:

// Get the data from buffer
MxpiBuffer * buffer = mxpiBuffer[0];                 // 0 indicates the input port number, which is fixed to 0 in the current version.
MxpiMetadataManager mxpiMetadataManager(buffer);     // Get metadata by key.
std::shared_ptr<void> metadata = mxpiMetadataManager.GetMetadata(key);
std::shared_ptr<MxpiVisionList> srcVisionListSptr = std::static_pointer_cast<MxpiVisionList>(metadata);

key indicates the string used when the upstream plugin mounts the output result (usually the upstream element name, for example, vpcresize0). The obtained input data is converted into the corresponding data format (obtain the data structure by querying the description document of the upstream plugin, for example, MxpiVisionList).