hailo-inference/cpp_inference/yolov5.hpp
2022-03-31 11:10:10 +02:00

57 lines
1.7 KiB
C++

#ifndef _YOLOV5M_
#define _YOLOV5M_
#include <stdint.h>
#if 0
#define FEATURE_MAP_SIZE1 20
#define FEATURE_MAP_SIZE2 40
#define FEATURE_MAP_SIZE3 80
#endif
#if 1
#define FEATURE_MAP_SIZE1 80
#define FEATURE_MAP_SIZE2 40
#define FEATURE_MAP_SIZE3 20
#endif
//#define FEATURE_MAP_CHANNELS 85
#define FEATURE_MAP_CHANNELS 8
#define IMAGE_SIZE 640
#define ANCHORS_NUM 3
#define IOU_THRESHOLD 0.45f
#define CONFIDENCE_THRESHOLD 0.7f
#define MAX_BOXES 100
#define CLASSES_COUNT 3
//#define CLASSES_COUNT 90
#define CONF_CHANNEL_OFFSET 4
#define CLASS_CHANNEL_OFFSET 5
#define YMIN 0
#define XMIN 1
#define YMAX 2
#define XMAX 3
#define CONFIDENCE 4
#define CLASS_ID 5
typedef float float32_t;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
static uint8_t g_feature_map_size[ANCHORS_NUM] = {FEATURE_MAP_SIZE1, FEATURE_MAP_SIZE2, FEATURE_MAP_SIZE3};
#if 1
static int32_t g_anchors[ANCHORS_NUM][6] = {{10, 13, 16, 30, 33, 23},
{30, 61, 62, 45, 59, 119},
{116, 90, 156, 198, 373, 326}};
#endif
#if 0
static int32_t g_anchors[ANCHORS_NUM][6] = {{116, 90, 156, 198, 373, 326},
{30, 61, 62, 45, 59, 119},
{10, 13, 16, 30, 33, 23}};
#endif
#pragma GCC diagnostic pop
void extract_boxes(uint8_t *fm, float32_t qp_zp, float32_t qp_scale, uint32_t feature_map_size,
int* anchors, float32_t thr, uint32_t *box_index, float32_t (*box_array)[6]);
float32_t iou_calc_c(float32_t *box_1, float32_t *box_2);
float fix_scale(float32_t input, float32_t qp_scale, float32_t qp_zp);
#endif /* _YOLOV5M_ */