vpc_util.h 1.39 KB
#ifndef ___VPC_UTIL_H__
#define ___VPC_UTIL_H__

#include "acl/acl.h"
#include "acl/ops/acl_dvpp.h"
#include "acl/dvpp/hi_dvpp.h"
#include "../ai_platform/header.h"

#include <string>
#include <vector>

using namespace std;

struct vpc_img_info{
    acldvppPicDesc* pic_desc{nullptr};
    string task_id;              //该物体属于的任务ID号
    int task_frame_count;     //该物体当前出现的帧号
    int object_id;            //该物体的ID号
    int index;                //该物体所属类别的编号
    double confidence;        //该物体的置信度
};

class DeviceMemory;

class VPCUtil {

public:
    static VPCUtil* getInstance(){
		static VPCUtil* singleton = nullptr;
		if (singleton == nullptr){
			singleton = new VPCUtil();
		}
		return singleton;
	}

    ~VPCUtil()
    {
        release();
    }

    static void vpc_pic_desc_release(acldvppPicDesc* );

    static void vpc_img_release(vpc_img_info );

    static void vpc_imgList_release(vector<vpc_img_info>& );

    static vpc_img_info vpc_devMem2vpcImg(DeviceMemory *devMem);

public:
    vpc_img_info crop(DeviceMemory *devMem, video_object_info obj);

    int init(int32_t devId);

    vector<vpc_img_info> crop_batch(DeviceMemory *devMem, vector<video_object_info> objs);

    void release();

private:
    int32_t deviceId_;
    aclrtContext context_;

    acldvppChannelDesc *dvppChannelDesc_;
};



#endif  //___VPC_UTIL_H__