CleanRobot-UESTC/融合/rknn_sdk.h

111 lines
3.0 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __RKNN_SDK_H__
#define __RKNN_SDK_H__
#include <stdint.h>
// 返回错误码
enum XErrorCode {
RKNN_SUCCEED = 0,
RKNN_NOT_INIT = -1, //SDK未初始化
RKNN_INVAILD_IMGSIZE = -2, //输入图像尺寸不匹配模型输入要求
RKNN_INVAILD_PARAM = -3, //参数无效
};
enum ObjCls {
OBJ_Unknown = -1, //未知
OBJ_MaoGouWan = 0, //猫碗/狗碗
OBJ_BTYDiZuo = 1, //吧台椅底座
OBJ_FSDiZuo = 2, //风扇底座
OBJ_XiYiJi = 3, //洗衣机
OBJ_BingXiang = 4, //冰箱
OBJ_MaTong = 5, //马桶
OBJ_TiZhongCheng = 6, //体重秤
OBJ_DianXian = 7, //电线
OBJ_DianShiJi = 8, //电视机
OBJ_CanZhuo = 9, //餐桌
OBJ_DiTan = 10, //地毯
OBJ_MaBu = 11, //抹布
OBJ_ChaJi = 12, //茶几
OBJ_DianShiGui = 13, //电视柜
OBJ_XieZi = 14, //拖鞋/鞋子
OBJ_WaZi = 15, //袜子
OBJ_YiGui = 16, //衣柜
OBJ_Chuang = 17, //床
OBJ_ShaFa = 18, //沙发
OBJ_YiZi = 19, //椅子
OBJ_Men = 20, //门
OBJ_DLS = 21, //da li shi
OBJ_DiBan = 22 //di ban
//OBJ_Xiang = 21 //宠物粪便
};
// 图像信息与buffer
typedef struct _InputData {
int shape[4]; // Num, Channel, Height, Width
void* data; // img.data
} InputData;
// 检测结果
typedef struct _DetRet
{
int nID; //图像ID
int nLabel; //物体类别 ObjCls nLabel; //物体类别
float fConf; //置信度
float fLeft; //检测框左上角比例坐标x_min -> int(x_min*width) 获取像素坐标
float fTop; //检测框左上角比例坐标y_min -> int(y_min*height) 获取像素坐标
float fRight; //检测框右下角比例坐标x_max -> int(x_max*width) 获取像素坐标
float fBottom; //检测框右下角比例坐标y_max -> int(y_max*height) 获取像素坐标
} DetRet;
#define RKNNSDK_API(retType) retType
///
#ifdef __cplusplus
extern "C" {
#endif
typedef uint64_t rknn_handle;
/* RKNN_Create
SDK加载模型仅初始化一次;
input:
rknn_handle hd 句柄
const char* model_path 模型路径
return:
int 错误码
*/
RKNNSDK_API(int) RKNN_Create(rknn_handle* hd, const char* model_path);
/* RKNN_ObjDet
输入图像,获取检测结果和检测目标数量;
input:
rknn_handle hd 句柄
const InputData* input_data 输入图像数据
DetRet** det_ret 获取检测结果
int* det_num 获取检测目标数量
return:
int 错误码
*/
RKNNSDK_API(int) RKNN_ObjDet(rknn_handle hd, const InputData* input_data, DetRet** det_ret, int* det_num);
/* RKNN_Release
SDK资源释放仅在程序退出前调用;
input:
rknn_handle hd 句柄
return:
int 错误码
*/
RKNNSDK_API(int) RKNN_Release(rknn_handle hd);
#ifdef __cplusplus
}
#endif
#endif //__RKNN_SDK_H__