1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AI_INFER_PROCESS_H 17 #define AI_INFER_PROCESS_H 18 19 #include <stdint.h> 20 #include "sample_comm_nnie.h" 21 22 #if __cplusplus 23 extern "C" { 24 #endif 25 26 #define HI_PER_BASE 100 27 #define HI_OVEN_BASE 2 // Even base 28 29 /* 30 * 矩形框坐标定义 31 * Definition of rectangular box coordinates 32 */ 33 typedef struct RectBox { 34 int xmin; 35 int xmax; 36 int ymin; 37 int ymax; 38 } RectBox; 39 40 /* 41 * 识别的结果信息 42 * Recognized number information 43 */ 44 typedef struct RecogNumInfo { 45 uint32_t num; // Recognized numeric value, 0~9 46 uint32_t score; // The credibility score of a number, the value range of which is defined by a specific model 47 } RecogNumInfo; 48 49 /* 50 * 与插件有关的信息 51 * Plug related information 52 */ 53 typedef struct AiPlugLib { 54 int width; 55 int height; 56 uintptr_t model; 57 } AiPlugLib; 58 59 /* 60 * 检测对象信息 61 * Information of detected objects 62 */ 63 typedef struct DetectObjInfo { 64 int cls; // The category of the object, an integer> 0 65 RectBox box; // The rectangular area of the object (pixels) 66 float score; // Object's credibility score 67 } DetectObjInfo; 68 69 /* 70 * 销毁CNN模型 71 * Destroy CNN model 72 */ 73 void CnnDestroy(SAMPLE_SVP_NNIE_CFG_S *self); 74 75 /* 76 * 基于模型文件创建CNN模型 77 * Create CNN model based mode file 78 */ 79 int CnnCreate(SAMPLE_SVP_NNIE_CFG_S **model, const char* modelFile); 80 81 /* 82 * 对一帧图像进行推理 83 * Calculate a frame of image 84 */ 85 int CnnCalImg(SAMPLE_SVP_NNIE_CFG_S* self, 86 const IVE_IMAGE_S *img, RecogNumInfo resBuf[], int resSize, int* resLen); 87 88 /* 89 * 函数:基于模型文件创建Yolov2模型 90 * function : Creat Yolov2 model basad mode file 91 */ 92 int Yolo2Create(SAMPLE_SVP_NNIE_CFG_S **model, const char* modelFile); 93 94 /* 95 * 销毁Yolov2模型 96 * Destroy Yolov2 model 97 */ 98 void Yolo2Destory(SAMPLE_SVP_NNIE_CFG_S *self); 99 100 /* 101 * 对一帧yuv图片进行推理 102 * Calculation yuv image 103 */ 104 int Yolo2CalImg(SAMPLE_SVP_NNIE_CFG_S* self, 105 const IVE_IMAGE_S *img, DetectObjInfo resBuf[], int resSize, int* resLen); 106 107 #ifdef __cplusplus 108 } 109 #endif 110 #endif 111