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 /* rect box */ 30 typedef struct RectBox { 31 int xmin; 32 int xmax; 33 int ymin; 34 int ymax; 35 } RectBox; 36 37 /* recognized number information */ 38 typedef struct RecogNumInfo { 39 uint32_t num; // Recognized numeric value, 0~9 40 uint32_t score; // The credibility score of a number, the value range of which is defined by a specific model 41 } RecogNumInfo; 42 43 /* plug related information */ 44 typedef struct AiPlugLib { 45 int width; 46 int height; 47 uintptr_t model; 48 } AiPlugLib; 49 50 /* Information of detected objects */ 51 typedef struct DetectObjInfo { 52 int cls; // The category of the object, an integer> 0 53 RectBox box; // The rectangular area of the object (pixels) 54 float score; // Object's credibility score 55 } DetectObjInfo; 56 57 void CnnDestroy(SAMPLE_SVP_NNIE_CFG_S *self); 58 int CnnCreate(SAMPLE_SVP_NNIE_CFG_S **model, const char* modelFile); 59 60 /* Calculate a U8C1 image */ 61 int CnnCalU8c1Img(SAMPLE_SVP_NNIE_CFG_S* self, 62 const IVE_IMAGE_S *img, RecogNumInfo resBuf[], int resSize, int* resLen); 63 64 /* creat yolo2 model basad mode file */ 65 int Yolo2Create(SAMPLE_SVP_NNIE_CFG_S **model, const char* modelFile); 66 67 /* destory yolo2 model */ 68 void Yolo2Destory(SAMPLE_SVP_NNIE_CFG_S *self); 69 70 /* cal U8C3 image */ 71 int Yolo2CalImg(SAMPLE_SVP_NNIE_CFG_S* self, 72 const IVE_IMAGE_S *img, DetectObjInfo resBuf[], int resSize, int* resLen); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 #endif 78