|
| 1 | +/* |
| 2 | + * ESPRESSIF MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD> |
| 5 | + * |
| 6 | + * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, |
| 7 | + * it is free of charge, to any person obtaining a copy of this software and associated |
| 8 | + * documentation files (the "Software"), to deal in the Software without restriction, including |
| 9 | + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished |
| 11 | + * to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all copies or |
| 14 | + * substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 18 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 19 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 20 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 21 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | + * |
| 23 | + */ |
| 24 | +#pragma once |
| 25 | + |
| 26 | +#ifdef __cplusplus |
| 27 | +extern "C" |
| 28 | +{ |
| 29 | +#endif |
| 30 | +#include "dl_lib_matrix3d.h" |
| 31 | +#include "dl_lib_matrix3dq.h" |
| 32 | +#include "freertos/FreeRTOS.h" |
| 33 | + |
| 34 | + typedef enum |
| 35 | + { |
| 36 | + Anchor_Point, /*<! Anchor point detection model*/ |
| 37 | + Anchor_Box /*<! Anchor box detection model */ |
| 38 | + } detection_model_type_t; |
| 39 | + |
| 40 | + typedef struct |
| 41 | + { |
| 42 | + int **anchors_shape; /*<! Anchor shape of this stage */ |
| 43 | + int stride; /*<! Zoom in stride of this stage */ |
| 44 | + int boundary; /*<! Detection image low-limit of this stage */ |
| 45 | + int project_offset; /*<! Project offset of this stage */ |
| 46 | + } detection_stage_config_t; |
| 47 | + |
| 48 | + typedef struct |
| 49 | + { |
| 50 | + dl_matrix3dq_t *score; /*<! score feature map of this stage*/ |
| 51 | + dl_matrix3dq_t *box_offset; /*<! box_offset feature map of this stage*/ |
| 52 | + dl_matrix3dq_t *landmark_offset; /*<! landmark_offset feature map of this stage */ |
| 53 | + } detection_stage_result_t; |
| 54 | + |
| 55 | + typedef struct |
| 56 | + { |
| 57 | + int resized_height; /*<! The height after resized */ |
| 58 | + int resized_width; /*<! The width after resized */ |
| 59 | + fptp_t y_resize_scale; /*<! resized_height / input_height */ |
| 60 | + fptp_t x_resize_scale; /*<! resized_width / input_width */ |
| 61 | + qtp_t score_threshold; /*<! Score threshold of detection model */ |
| 62 | + fptp_t nms_threshold; /*<! NMS threshold of detection model */ |
| 63 | + bool with_landmark; /*<! Whether detection with landmark, true: with, false: without */ |
| 64 | + bool free_image; /*<! Whether free the resized image */ |
| 65 | + int enabled_top_k; /*<! The number of enabled stages */ |
| 66 | + } detection_model_config_t; |
| 67 | + |
| 68 | + typedef struct |
| 69 | + { |
| 70 | + detection_stage_config_t *stage_config; /*<! Configuration of each stage */ |
| 71 | + int stage_number; /*<! The number of stages */ |
| 72 | + detection_model_type_t model_type; /*<! The type of detection model */ |
| 73 | + detection_model_config_t model_config; /*<! Configuration of detection model */ |
| 74 | + detection_stage_result_t *(*op)(dl_matrix3dq_t *, detection_model_config_t *); /*<! The function of detection inference */ |
| 75 | + void *(*get_boxes)(detection_stage_result_t *, detection_model_config_t *, detection_stage_config_t *, int); /*<! The function of how to get real boxes */ |
| 76 | + } detection_model_t; |
| 77 | + |
| 78 | + /** |
| 79 | + * @brief free 'detection_stage_result_t' type value |
| 80 | + * |
| 81 | + * @param value A 'detection_stage_result_t' type value |
| 82 | + */ |
| 83 | + void free_detection_stage_result(detection_stage_result_t value); |
| 84 | + |
| 85 | +#ifdef __cplusplus |
| 86 | +} |
| 87 | +#endif |
0 commit comments