【Atlas200】使用sendData及getResult接口进行pipline目标检测框数据读取(C++)

本文介绍了在华为Atlas 200上使用sendData和getResult接口进行目标检测数据读取的方法。通过RapidJSON库解析pipeline返回的JSON格式目标检测框数据,并在OpenCV中展示检测结果。
摘要由CSDN通过智能技术生成

简介

当今,人工智能技术已经渗透到我们生活的方方面面,其中目标检测技术是非常重要的一种技术。目标检测技术可以对图像或视频中的物体进行识别和定位,是实现自动驾驶、智能监控等众多应用的基础。
华为 Atlas 200 是一款高性能的人工智能处理器,支持多种神经网络架构和算法,包括目标检测算法。在 Atlas 200 上进行目标检测,可以利用其强大的计算能力和低延迟的数据传输性能,实现高效的物体识别和定位。
在本文中,我们将介绍如何使用 Atlas 200 提供的 sendData 和 getResult 接口,实现对 Pieline 模型的目标检测框数据读取。我们将使用 RapidJSON 库解析返回的 JSON 数据,并在 OpenCV 中绘制矩形框,以便更直观地观察目标检测的结果。

读取主函数

传入数据时使用SendData,对应取出推理结果时使用GetResult。读取图片的相关函数忽略。

std::cout << "Start reading pipeline config file." << std::endl;
    std::string pipelinePath = "/home/HwHiAiUser/selfwork/MyFirstApp3/pipeline/Sample.pipeline";
    std::string pipelineConfigStr = ReadPipeline(pipelinePath);
    // init stream manager
    MxStream::MxStreamManager mxStreamManager;
    if (mxStreamManager.InitManager() != APP_ERR_OK) {
   
        LogError << "Failed to init Stream manager.";
        return APP_ERR_COMM_INIT_FAIL;
    }
    // create stream by pipeline config file
    if (mxStreamManager.CreateMultipleStreams(pipelineConfigStr) != APP_ERR_OK) {
   
        LogError << "Failed to create Stream.";
        return APP_ERR_COMM_INIT_FAIL;
    }
    std::cout << "Start reading image file and building stream input." << std::endl;
    MxStream::MxstDataInput dataBuffer;
    if (ReadFile("/home/HwHiAiUser/selfwork/MyFirstApp3/data/1.jpg", dataBuffer) != APP_ERR_OK) {
   
        LogError << "Failed to read image file.";
        return APP_ERR_COMM_INIT_FAIL;
    }
    std::string streamName = "yolox";
    int inPluginId = 0;
    std::cout << "Start sending data into stream." << std::endl;
    APP_ERROR ret = mxStreamManager.SendData(streamName, inPluginId, dataBuffer);
    if (ret != APP_ERR_OK) {
   
        LogError << GetError(ret) << "Failed to send data to stream.";
        delete dataBuffer.dataPtr;
        dataBuffer.dataPtr = nullptr;
        return ret;
    }
    std::cout << "Getting output result from stream." << std::endl;

    std::vector<std<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

颢师傅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值