下载
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
昇腾小AI

C++样例

样例一

函数原型:

APP_ERROR SendData(const std::string& streamName, int inPluginId, MxstDataInput& dataBuffer);

样例代码参考“{sdk_install_path}/samples/mxVision/C++”目录下的样例代码“main.cpp”

样例二

函数原型:

APP_ERROR SendData(const std::string& streamName, const std::string& elementName, MxstDataInput& dataBuffer);
std::string inElementName = "appsrc0"
APP_ERROR ret = mxStreamManager->SendData(streamName, inElementName, mxstDataInput);
if (ret != APP_ERR_OK) {
    LogError << GetError(ret) << "SendData two failed.";
    return ret;
}
MxStream::MxstDataOutput *mxstDataOutput = mxStreamManager->GetResult(streamName, outPluginId);
if (mxstDataOutput == nullptr) {
    LogError << "SendDataAndGetResult mxstDataOutput is nullptr.";
    return APP_ERR_COMM_INVALID_POINTER;
}
std::string result((char *) mxstDataOutput->dataPtr, mxstDataOutput->dataSize);
std::cout << "result:" << result << std::endl;

delete mxstDataOutput;
mxstDataOutput = nullptr;

样例三

函数原型:

APP_ERROR SendData(const std::string& streamName, const std::string& elementName, MxstDataInput& dataBuffer);
std::string inElementName = "appsrc0"
APP_ERROR ret = mxStreamManager->SendData(streamName, inElementName, mxstDataInput);
if (ret != APP_ERR_OK) {
    LogError << GetError(ret) << "SendData two failed.";
    return ret;
}
auto mxstDataOutput = mxStreamManager->GetResultSP(streamName, outPluginId);
if (mxstDataOutput == nullptr) {
    LogError << "SendDataAndGetResult mxstDataOutput is nullptr.";
    return APP_ERR_COMM_INVALID_POINTER;
}
std::string result((char *) mxstDataOutput->dataPtr, mxstDataOutput->dataSize);
std::cout<< "result:" << result << std::endl;

样例四

函数原型:

APP_ERROR SendData(const std::string& streamName, const std::string& elementName,std::vector<MxstMetadataInput>& metadataVec, MxstBufferInput& bufferInput);
APP_ERROR ret = mxStreamManager->SendData(streamName, "appsrc0", mxstMetadataInputVec, mxstBufferInput);
if (ret != APP_ERR_OK) {
    LogError << GetError(ret) << "SendData failed.";
    return ret;
}
std::vector<std::string> dataSourceVec = {"appsrc0"};
MxStream::MxstBufferAndMetadataOutput mxstBufferAndMetadataOutput =
        mxStreamManager->GetResult(streamName, "appsink0", dataSourceVec);
if (mxstBufferAndMetadataOutput.errorCode != APP_ERR_OK) {
    LogError << GetError(mxstBufferAndMetadataOutput.errorCode) << "GetResult failed";
    return mxstBufferAndMetadataOutput.errorCode;
}
if (mxstBufferAndMetadataOutput.bufferOutput.get() == nullptr) {
    LogError << "bufferOutput nullptr";
    return APP_ERR_COMM_INVALID_POINTER;
}
std::string outBuffer((char *) mxstBufferAndMetadataOutput.bufferOutput->dataPtr,
                      mxstBufferAndMetadataOutput.bufferOutput->dataSize);
LogInfo << "result:" << outBuffer ;
for (uint32_t i = 0; i < mxstBufferAndMetadataOutput.metadataVec.size(); i++) {
    auto metaData = mxstBufferAndMetadataOutput.metadataVec[i];
    std::cout << metaData.dataPtr->DebugString() << std::endl;;
}
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词